I would like to transform values from a dataset to a list as numeric values.
Here is a sample dataset:
df <- data.frame(
a = c(5.5, 6, 7),
b = c(1.1, 2.5, 3.5))
# convert dataframe to list
df.list <- split(df, seq(nrow(df)))
The list looks like the above in the R environment. My desired output in the R environment is like below by getting rid of the $s, as, and bs.
I tried this below but it did not really give what I wanted.
for (i in 1:length(df.list)) {
df.list[[i]] <- lapply(df.list[[i]], function(x) as.numeric(as.character(df.list[[i]])))
}
Does ANyone have any ideas?
Thanks!


