Get information of a .Rda file stored inside the 'data/' folder

get_data_info(name, description, source)

Arguments

name

name of the file that exists in "data/"

description

description for the data

source

source of data

Value

list of information from a data.frame

See also

use_data_doc() to add the information directly as roxygen documentation in your package.

Examples

# Store a dataset as rda file
path_project <- tempfile(pattern = "data-")
path_data <- file.path(path_project, "data")
dir.create(path_data, recursive = TRUE)
path_rda <- file.path(path_data, "iris.rda")
save(iris, file = path_rda)

# Get its information
withr::with_dir(
  path_project,
  {
    get_data_info("iris", "Iris data frame", source = "ThinkR")
  }
)
#> $name
#> [1] "iris"
#> 
#> $description
#> [1] "Iris data frame"
#> 
#> $rows
#> [1] 150
#> 
#> $cols
#> [1] 5
#> 
#> $items
#> $items[[1]]
#> $items[[1]]$name
#> [1] "Sepal.Length"
#> 
#> $items[[1]]$class
#> [1] "numeric"
#> 
#> 
#> $items[[2]]
#> $items[[2]]$name
#> [1] "Sepal.Width"
#> 
#> $items[[2]]$class
#> [1] "numeric"
#> 
#> 
#> $items[[3]]
#> $items[[3]]$name
#> [1] "Petal.Length"
#> 
#> $items[[3]]$class
#> [1] "numeric"
#> 
#> 
#> $items[[4]]
#> $items[[4]]$name
#> [1] "Petal.Width"
#> 
#> $items[[4]]$class
#> [1] "numeric"
#> 
#> 
#> $items[[5]]
#> $items[[5]]$name
#> [1] "Species"
#> 
#> $items[[5]]$class
#> [1] "factor"
#> 
#> 
#> 
#> $source
#> [1] "ThinkR"
#> 

# Clean userspace
unlink(path_project, recursive = TRUE)