Skip to content
Prev 277479 / 398506 Next

Reading a specific column of a csv file in a loop

Yet another solution. This time using the LaF package:

library(LaF)
d<-c(1,4,7,8)
P1 <- laf_open_csv("M1.csv", column_types=rep("double", 10), skip=1)
P2 <- laf_open_csv("M2.csv", column_types=rep("double", 10), skip=1)
for (i in d) {
   M<-data.frame(P1[, i],P2[, i])
}

(The skip=1 is needed as laf_open_csv doesn't read headers)

Jan
On 11/08/2011 11:04 AM, Sergio Ren? Araujo Enciso wrote: