How to create a List of 3?

97 Views Asked by At

What I´m looking for is a way to create data like the one resulting from the following code:

## import packages
library(iNEXT)

#data(spider)
data(ciliates)
str(ciliates)

How to create a "List of 3" like the resulting ciliates from scratch?

What I have are two .csv-files like the following:

species <- c("species_1","species_2","species_3","species_4")
plot.1 <- c(0, 1, 0, 0)
plot.2 <- c(0, 0, 1, 0)

MyData.1 <- data.frame(species, plot.1, plot.2)

write.csv(MyData.1, file = "MyData_1.csv")

species <- c("species_1","species_2","species_3","species_4")
plot.3 <- c(0, 1, 0, 1)
plot.4 <- c(1, 0, 1, 0)

MyData.2 <- data.frame(species, plot.3, plot.4)

write.csv(MyData.2, file = "MyData_2.csv")

read.csv(file = "MyData_1.csv")
read.csv(file = "MyData_2.csv")

I hope my question is clear. Otherwise please ask to clarify it.

1

There are 1 best solutions below

0
Michael Roswell On

I think your question is clear. Assuming you're simply asking how to concatenate several dataframes into a list, you can use the list function, e.g. list(MyData.1, MyData.2, MyData.2). This returns

[[1]] species plot.1 plot.2 1 species_1 0 0 2 species_2 1 0 3 species_3 0 1 4 species_4 0 0

[[2]] species plot.3 plot.4 1 species_1 0 1 2 species_2 1 0 3 species_3 0 1 4 species_4 1 0

[[3]] species plot.3 plot.4 1 species_1 0 1 2 species_2 1 0 3 species_3 0 1 4 species_4 1 0

Let me know if you're looking for something more, and we can go from there!