I need explanation for data frame, sum, and mean commands If the code below is operated, I can get list of data files Preplist
. Yet, the commands I need explanations for does not work due to some errors.
My guess is that the data I load does not have data frame, but just list of numbers for each data file. To sum or take mean for each data file, I need data frame. (When I check number of rows there is nothing, but NULL).
I think I need to make data frame for loaded data (200x200 matrix), and also first row and column has to ignored in original data.
This is my code:
Prepfiles <- list.files(pattern=".csv")
Preplist <- lapply(Prepfiles, read.table, sep = '\t',
na.string = '', header = TRUE, skip=1)
bigPreplist <- do.call(rbind, Preplist)
I need to do load data at once, and plot data (sum every three data files together, and plot). However, I have trouble to run command sum()
and mean()
with my Preplist[1:24]
I am using are all numeric in 200 by 200 matrix. There are 24 data files. Also I want to keep 200 by 200 matrix form when I load data, but with my coding, there is are no number of rows if I check with nrow(Preplist[1])
Is it possible to keep same dataframe when you load data in? Or do I have to make new data frame?
Here are errors that I get with sum and mean commands:
> nrow(Preplist)
NULL
> sum(Preplist[1])
Error in sum(Preplist[1]) : invalid 'type' (list) of argument
> mean(Preplist[1])
[1] NA
Warning message:
In mean.default(Preplist[1]) :
argument is not numeric or logical: returning NA
[[
instead of[
? – sebastian-cPreplist[1]
? A column of data? A 200x200 data frame? – joran