Here is another approach. The lines where I load the data sets mtcars, iris and iris3 are only there to provide some objects for the reproducible example. You can write the object TBL as a csv or an Excel file.
library(tibble)
library(purrr)
M <- mtcars
I <- iris
I3 <- iris3 #not a data frame
DataNames <- ls()
GetInfo <- function(x) {
Obj <- get(x)
if (grepl("data.frame", class(Obj))) {
Name <- x
Obs <- nrow(Obj)
Vars <- ncol(Obj)
} else {
Name <- x
Obs <- NA
Vars <- NA
}
tibble(Name = Name, Observations = Obs, Variables = Vars)
}
TBL <- map_dfr(DataNames, GetInfo )
TBL
#> # A tibble: 3 x 3
#> Name Observations Variables
#> <chr> <int> <int>
#> 1 I 150 5
#> 2 I3 NA NA
#> 3 M 32 11
Created on 2020-05-16 by the reprex package (v0.3.0)