I would like to get the list of loaded dataframes (i.e., the names of the data frames) in an R session.
I wrote the following code but it only puts the last found data.frame
in variable y
and does not even print it out:
for(y in ls()){
if(is.data.frame(y) == TRUE){
print(y) }
}
If I use the following code, all data and values are printed:
for(z in ls()){
print(z)
}
My questions:
- How do I get to print only dataframes?
- Crucially, how do I put the result in a useable variable?
System used:
- R version: 4.1.1 (2021-08-10)
- RStudio version: 1.4.1717
- OS: macOS Catalina version 10.15.7