Extract as.numeric value from CSV

97 views Asked by At

Recently I created a huge dataset which i'd like to put into R and re-design value's. The problem I have is getting the values, which I have putten in via a .csv file.

In 1 row I have 5 columns numbered from 0 to 100 (I.E. 0, 34, 56, 78, 100) When I want to read these values I use:

as.numeric(MyData[1,1]) = 0
as.numeric(MyData[1,2]) = 34

etc.. but when gather the value as.numeric(MyData[1,5]) = 4, instead of 100. The same things happen with several other numbers. Is as.numeric the right way to go? If not, does anyone have a solution to this?

1

There are 1 answers

0
Daniel Jansen On

The problem is solved. For some reason saving .XLSX as .CSV, numbers are not corresponding correctly. Likely due to file format change. Solution:

#install.packages("readxl")
library(readxl)
data <- read_excel("excel_file.xlsx",1)

No more .csv, but .xlsx