This function returns a data frame containing the data from a data worksheet in a SAFE dataset. Note that SAFE dataset .xlsx files include the other (non-data) worksheets Summary, Taxa, Locations that contain metadata: see get_taxa, get_locations, add_taxa and add_locations for accessing and using this metadata.

load_safe_data(record_id, worksheet)

# S3 method for safedata
str(object, ...)

# S3 method for safedata
print(x, n = 10, ...)

Arguments

record_id

A SAFE dataset record id

worksheet

The name of the worksheet to load

...

Further arguments to str and print methods.

x, object

A safedata object.

n

The number of rows to show in the print method.

Value

A data frame with the additional safedata class and additional attribute data containing metadata for the data.

Details

In particular, the large amount of data worksheet summary metadata is not attached as attributes to the data frame returned by this function. This is largely to avoid excessive output to the console during normal use of the data frame: an extended description of a worksheet can be displayed using show_worksheet.

Currently, this function only loads data from SAFE formatted .xlsx files - data stored in external files is not yet handled.

Methods (by generic)

  • str: Display structure of a safedata data frame

  • print: Print safedata data frame

Examples

   set_example_safe_dir()
#> Loading and caching index
#> Validating directory
   beetle_abund <- load_safe_data(1400562, "Ant-Psel")
   str(beetle_abund)
#> SAFE dataset
#> Concept: 1400561; Record 1400562; Worksheet: Ant-Psel
#> 'data.frame':	20 obs. of  3 variables:
#>  $ Site                : chr  "SAFE_E" "SAFE_D" "SAFE_F" "SAFE_C" ...
#>  $ ant.species.richness: num  31 31 27 29 31 21 31 25 32 26 ...
#>  $ ant.abundance       : num  561 713 392 481 1036 ...
   # See also the show_worksheet function for further worksheet metadata
   show_worksheet(beetle_abund)
#> Record ID: 1400562
#> Worksheet name: Ant-Psel
#> Number of data rows: 20
#> Number of data fields: 3
#> Description:
#> Ant-Pselaphine data
#> Status: open
#> 
#> Fields:
#>   field_name           field_type description                    
#> 1 Site                 Location   Site where sample was collected
#> 2 ant species richness Numeric    Number of ant species in sample
#> 3 ant abundance        Abundance  Total number of ants in sample 
   unset_example_safe_dir()
#> Loading and caching index
#> Validating directory