I am working with multiple dataframes in R and I want to access those dataframes with a single command. I used the ls command to capture the dataframes by their name but I am not sure how to access the dataframe itself.
first_df <- data.frame(y1 <- c(1, 2, 3), y2 <- c(4, 5, 6))
second_df <- data.frame(y1 <- c(7, 8, 9), y2 <- c(10, 11, 12))
ls(pattern = "_df")
print(class(ls(pattern = "_df")[1]))
print(class(ls(pattern = "_df")[[1]]))
# I want to see the 2 rows of the dataset here.
head(ls(pattern = "_df")[[1]])