How to import data into vector in R

I would like to import CSV data into R as a single dimension object like a vector. I only manage to import data as a table. I tried converting a table to a vector, but that not only challenges my lack of experience in R, but it also seems to be lacking in syntax for such a basic function.

Is there an easy way to accomplish this basic task similar to how c (x, y, z, ...) works?

My data looks like this (with 24,000 values): 1417656631000,0,0,3,20450,2,7,30798,2,2,7449,3,5,16002,2,1,77666,2,8, 7435.4

+3


source to share


1 answer


you can use scan



 op <- options(scipen=999)
 res <- scan('yourfile.csv', what=numeric(), sep=",", quiet=TRUE)
 res
 #[1] 1417656631000             0             0             3         20450
 #[6]             2             7         30798             2             2
 #[11]          7449             3             5         16002             2
 #[16]             1         77666             2             8          7435
 #[21]             4

      

+6


source







All Articles