read_vft() and read_taxa() help you to read ViewFullTable and ViewTaxonomy data from text files delivered by the ForestGEO database. These functions avoid common problems about column separators, missing values, column names, and column types.

read_vft(file, delim = NULL, na = c("", "NA", "NULL"), ...)

read_taxa(file, delim = NULL, na = c("", "NA", "NULL"), ...)

Arguments

file

A path to a file.

delim

Single character used to separate fields within a record. The default (delim = NULL) is to guess between comma or tab ("," or "\t").

na

Character vector of strings to interpret as missing values. Set this option to character() to indicate no missing values.

...

Other arguments passed to readr::read_delim().

Value

A tibble.

Acknowledgments

Thanks to Shameema Jafferjee Esufali for inspiring the feature that automatically detects delim (issue 65).

See also

readr::read_delim(), type_vft(), type_taxa().

Other functions to read text files delivered by ForestgGEO's database: type_vft()

Examples

assert_is_installed("fgeo.x")
library(fgeo.x)

example_path()
#>  [1] "csv"           "mixed_files"   "rdata"         "rdata_one"    
#>  [5] "rds"           "taxa.csv"      "tsv"           "vft_4quad.csv"
#>  [9] "view"          "weird"         "xl"           

file_vft <- example_path("view/vft_4quad.csv")
read_vft(file_vft)
#> # A tibble: 500 × 32
#>     DBHID PlotName PlotID Family   Genus Speci…¹ Mnemo…² Subsp…³ Speci…⁴ Subsp…⁵
#>     <int> <chr>     <int> <chr>    <chr> <chr>   <chr>   <chr>     <int> <chr>  
#>  1 385164 luquillo      1 Rubiace… Psyc… brachi… PSYBRA  NA          185 NA     
#>  2 385261 luquillo      1 Urticac… Cecr… schreb… CECSCH  NA           74 NA     
#>  3 384600 luquillo      1 Rubiace… Psyc… brachi… PSYBRA  NA          185 NA     
#>  4 608789 luquillo      1 Rubiace… Psyc… berter… PSYBER  NA          184 NA     
#>  5 388579 luquillo      1 Arecace… Pres… acumin… PREMON  NA          182 NA     
#>  6 384626 luquillo      1 Araliac… Sche… moroto… SCHMOR  NA          196 NA     
#>  7 410958 luquillo      1 Rubiace… Psyc… brachi… PSYBRA  NA          185 NA     
#>  8 385102 luquillo      1 Piperac… Piper glabre… PIPGLA  NA          174 NA     
#>  9 353163 luquillo      1 Arecace… Pres… acumin… PREMON  NA          182 NA     
#> 10 481018 luquillo      1 Salicac… Case… arborea CASARB  NA           70 NA     
#> # … with 490 more rows, 22 more variables: QuadratName <chr>, QuadratID <int>,
#> #   PX <dbl>, PY <dbl>, QX <dbl>, QY <dbl>, TreeID <int>, Tag <chr>,
#> #   StemID <int>, StemNumber <int>, StemTag <int>, PrimaryStem <chr>,
#> #   CensusID <int>, PlotCensusNumber <int>, DBH <dbl>, HOM <dbl>,
#> #   ExactDate <date>, Date <int>, ListOfTSM <chr>, HighHOM <int>,
#> #   LargeStem <chr>, Status <chr>, and abbreviated variable names ¹​SpeciesName,
#> #   ²​Mnemonic, ³​Subspecies, ⁴​SpeciesID, ⁵​SubspeciesID

file_taxa <- example_path("view/taxa.csv")
read_taxa(file_taxa)
#> # A tibble: 163 × 21
#>    ViewID SpeciesID Subspec…¹ Family Mnemo…² Genus Speci…³ Rank  Subsp…⁴ Autho…⁵
#>     <int>     <int> <chr>     <chr>  <chr>   <chr> <chr>   <chr> <chr>   <chr>  
#>  1      1        56 NA        Fabac… AESAME  Aesc… americ… NA    NA      (Poir.…
#>  2      2        57 NA        Eupho… ALCFLO  Alch… florib… NA    NA      (Benth…
#>  3      3        58 NA        Eupho… ALCLAT  Alch… latifo… NA    NA      Sw.    
#>  4      4        59 NA        Fabac… ANDINE  Andi… inermis NA    NA      (W. Wr…
#>  5      5        60 NA        Rubia… ANTOBT  Sten… obtusi… NA    NA      (Urb.)…
#>  6      6        61 NA        Myrsi… ARDGLA  Ardi… glauci… NA    NA      Urb.   
#>  7      7        62 NA        Morac… ARTALT  Arto… altilis NA    NA      (Parki…
#>  8      8        63 NA        Laura… BEIPEN  Beil… pendula NA    NA      (Sw.) …
#>  9      9        64 NA        Solan… BRUPOR  Brun… portor… NA    NA      Krug &…
#> 10     10        65 NA        Combr… BUCTET  Buch… tetrap… NA    NA      (Aubl.…
#> # … with 153 more rows, 11 more variables: IDLevel <chr>, subspMnemonic <chr>,
#> #   subspAuthority <chr>, FieldFamily <chr>, Lifeform <chr>, Description <chr>,
#> #   wsg <dbl>, wsglevel <chr>, ListOfOldNames <chr>, Specimens <chr>,
#> #   Reference <chr>, and abbreviated variable names ¹​SubspeciesID, ²​Mnemonic,
#> #   ³​SpeciesName, ⁴​Subspecies, ⁵​Authority