Write a R program to create a list of dataframes and access each of those data frames from the list.
df1 = data.frame(y1 = c(0, 1, 2), y2 = c(3, 4, 5)) df2 = data.frame(y1 = c(6, 7, 8), y2 = c(9, 10, 11)) new_list = list(df1, df2) print("New list:") print(new_list) print("Data frame-1") print(new_list[[1]]) print("Data frame-2") print(new_list[[2]])
Sample Output:
[1] "New list:" [[1]] y1 y2 1 0 3 2 1 4 3 2 5 [[2]] y1 y2 1 6 9 2 7 10 3 8 11 [1] "Data frame-1" y1 y2 1 0 3 2 1 4 3 2 5 [1] "Data frame-2" y1 y2 1 6 9 2 7 10 3 8 11
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer