I want to combine data from several csv files with the same format so I can analyse them, but I cannot remove the headers/column names from the several combined files.
I have used the lapply function in order to take a list of the context of all these files and it looks something like:
ID X1 X2 ---> header of 1st csv file
1 5 6
2 6 9
.......
10 7 8
.
ID X1 X2 --> headers 2nd csv file
1 5 6
2 6 9
.......
10 7 8
e.t.c
How can I remove the header characters in order to apply mathematical operations to these data?
My code:
data<-lapply(files, read.csv)
mean <-(mean(data$column2, na.rm=TRUE))
I also tried read.csv(headers=FALSE) but R do not accept this when the function is inside the lapply
I expect the mean of the data frame of the combined files but I get the error:
In mean.default(data$column2, na.rm = TRUE) : argument is not numeric or logical: returning NA
datais a list of dataframes. Eventually you want something likesapply(data, function(d) mean(d$X2))orsapply(data, function(d) mean(d[[3]]))- jogo