statistics - How to read large files(with rownames) with scan in this situation in R? -
i have text file 1000 row * 40001 column table.
the first column of file string , other columns float
numbers, such this:
a 2 3 4.54 .... 11.23 b 6 6 7 .... 23.45
i want read file matice read.table
seems not efficient large files, think scan
may right tool that?
however, scan
can accept numbers input default. if want non-number input, need change what
parameter. there're 40000+ columns, can't assign type of input each input..
does know how use it? thanks!
you use what
argument , specify list of types (like colclasses
).
lines <- "a 2 3 4.54 11.23 b 6 6 7 23.45" data <- (scan(textconnection(lines), what=c(list(null), rep(0,4)))) (data <- do.call(cbind, data)) # [,1] [,2] [,3] [,4] # [1,] 2 3 4.54 11.23 # [2,] 6 6 7.00 23.45
Comments
Post a Comment