[R] How to extract same columns from identical dataframes in a list?
Wolfgang Waser
waser at frankenfoerder-fg.de
Mon Feb 8 14:33:21 CET 2016
Hello,
I have a list of 7 data frames, each data frame having 24 rows (hour of
the day) and 5 columns (weeks) with a total of 5 x 24 values
I would like to combine all 7 columns of week 1 (and 2 ...) in a
separate data frame for hourly calculations, e.g.
> apply(new.data.frame,1,mean)
In some way sapply (lapply) works, but I cannot directly select columns
of the original data frames in the list. As a workaround I have to
select a range of values:
> sapply(list_of_dataframes,"[",1:24)
Values 1:24 give the first column, 25:48 the second and so on.
Is there an easier / more direct way to select for specific columns
instead of selecting a range of values, avoiding loops?
Cheers,
Wolfgang
More information about the R-help
mailing list