Extracting plant number from usms.xml or new_travail.usm file data

get_plants_nb(
  usms_file,
  usms_list = c(),
  usm_file_path = lifecycle::deprecated()
)

Arguments

usms_file

Path (including name) of a USM xml file or of a new_travail.usm file

usms_list

Usm(s) name(s) (optional, see details)

usm_file_path

[Deprecated] usm_file_path is no longer supported, use usms_file instead.

Value

A named numeric vector of plants number per usm

Details

Use get_usms_list() to get the list of the usm names for an usms.xml file.

Examples

# Xml case
xml_usms <- file.path(get_examples_path(file_type = "xml"), "usms.xml")
get_plants_nb(xml_usms)
#>            SugarCane               potato               banana 
#>                    1                    1                    1 
#>              sorghum            sugarbeet                wheat 
#>                    1                    1                    1 
#>                maize              soybean              lettuce 
#>                    1                    1                    1 
#>               tomato           DurumWheat             rapeseed 
#>                    1                    1                    1 
#>            sunflower                grass             BareSoil 
#>                    1                    1                    1 
#>          demo_Wheat1       demo_BareSoil2          demo_maize3 
#>                    1                    1                    1 
#>    DurumWheat_4years         maize_4years           strawberry 
#>                    1                    1                    1 
#>                 vine               fescue                 flax 
#>                    1                    1                    1 
#> intercrop_pea_barley              timothy      DurumWheat_snow 
#>                    2                    1                    1 
#>             Turmeric        cc_BristleOat           cc_mustard 
#>                    1                    1                    1 
#>   cc_ItalianRyegrass             cc_vetch     cc_CrimsonClover 
#>                    1                    1                    1 
#>           proto_rice      Miscanthus_2006      Miscanthus_2007 
#>                    1                    1                    1 
#>      Miscanthus_2008      Miscanthus_2009      Miscanthus_2010 
#>                    1                    1                    1 
#>      Miscanthus_2011      Miscanthus_2012      Miscanthus_2013 
#>                    1                    1                    1 
#>      Miscanthus_2014      Miscanthus_2015 
#>                    1                    1 
get_plants_nb(xml_usms, "wheat")
#> wheat 
#>     1 
get_plants_nb(xml_usms, c("wheat", "intercrop_pea_barley"))
#>                wheat intercrop_pea_barley 
#>                    1                    2 

# Txt case
txt_usm <- file.path(get_examples_path(file_type = "txt"), "new_travail.usm")
get_plants_nb(txt_usm)
#> Warning: The `filepath` argument of `get_usm_txt()` is deprecated as of SticsRFiles
#> 1.0.0.
#>  Please use the `file` argument instead.
#>  The deprecated feature was likely used in the SticsRFiles package.
#>   Please report the issue at
#>   <https://github.com/SticsRPacks/SticsRFiles/issues>.
#> maize 
#>     1