I have a data set with multiple treatments that I imported into R with read.csv. I then manipulated the data (normalized them in various ways) and now have 4 lists of independent, normalized observations for my 4 treatments (listA, listB, listC, listD). These data are not paired and represent independent observations (e.g. sample size in a= 5 and in b =6). I want to combine these lists into a new data file (maybe a .csv or a data frame) from which I can do statistics (ANOVA) and graphing (box plots). The final data set should NOT be a list simply appending all values in one list but should list each value in one column according to which list it came from. E.g. a 5.5 a 5 a 4.8 a 5.5 a 5.3 b 2.2 b 3.1 etc.
I have tried appending but the output only lists the values, not the names of the samples (a - d) next to the values.
my_list <- list(a= listA, b= listB, c= listC, d=listD)
my_list
I get this result:
$a
[1] 5.5 5 4.8 5.5 5.3 5.5 5.3
$b
[1] 2.2 3.1
but I would like to see a table with two columns
a 5.5
a 5
a 4.8
a 5.5
a 5.3
b 2.2
b 3.1
etc.
Trying to do as.data.frame creates this error:
my_df <- as.data.frame(my_list) Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE, : arguments imply differing number of rows: