I tried to assign a data frame as an element to a list, but after the assignment I found that the data frame has been changed to a list with values from the first column of the data frame.
For example the following code :
dfm <- data.frame(x=1:2, y=3:4)
print(dfm)
l <- list()
l['Key'] <- dfm
print(l)
gives the output:
x y
1 1 3
2 2 4
$Key
[1] 1 2
Is there a way to keep the data frame the way it is in a list ?
It would benefit you to pay attention to the warning message:
You want to use
[[instead of[(read?Extractto understand why):