% Generated by roxygen2: do not edit by hand % Please edit documentation in R/convert_data.R \name{convert.to.fadn.str.rds} \alias{convert.to.fadn.str.rds} \title{Converts an fadn.raw.rds file to fadn.str.rds file using a raw_str_map.json file} \usage{ convert.to.fadn.str.rds( fadn.country = NA, fadn.year = NA, raw_str_map.file = NULL, force_external_raw_str_map = FALSE, str.name = NULL, DEBUG = F ) } \arguments{ \item{fadn.country}{string with the country to extract the str data} \item{fadn.year}{the year to extract the structured data} \item{raw_str_map.file}{the full path to the raw_str_map file.} \item{DEBUG}{if TRUE, prints more details on the conversion process} \item{str.short_name}{the short name of the str data. No spaces and text up to 20 characters} } \value{ Saves the rds.str.fadn and returns TRUE if everything goes well } \description{ The raw_str_map.json specification is as follows: } \details{ { "id": { "COLUMN in every list member in RDS": "COLUMN IN CSV", ....}, "info": { "COLUMN in info RDS": "COLUMN IN CSV", ....}, "livestock": {} "crops": { "CROP NAME 1": {"description": "description of crop name", "columns": {"VARIABLE NAME": COLUMN IN CSV", ....} }, "CROP NAME 2": {"description": "description of crop name", "columns": {"VARIABLE NAME": COLUMN IN CSV", ....} }, .... } } The structure of the str.dir: - A data.dir can hold more than one extractions. - Each extraction has a short name (20 or less characters, whitespace is not allowed) - Each extraction is stored in the data.dir/rds/ - That folder contains the following files: + raw_str_map.json: the raw_str_map + fadn.str.<4-digit YEAR>.<3-letter COUNTRY>.rds: the extracted data Notes: 1) The computed RDS file contains a list structure with the following keys: info, costs, livestock-animals and crops All are data.tables. For all of them, the first columns are those that are contained in the "id" object "info" and "costs" are in table format, i.e. each farm is one row and data is on columns, as defined in the related raw_str_map.json file. "crops" and "livestock-animals" are in wide data format (https://tidyr.tidyverse.org/), where one farm lies accross many rows, and each row is a farm-crop-variableName-value combination 2) In $id, $info and $costs, "COLUMN IN CSV" can have two forms i) a single column name in the fadn.raw csv file or a combination, e.g. "K120SA+K120FC+K120FU+K120CV-K120BV" ii) the form of an object {"source": "the column in the csv", "description": "a description of what this column is about"} 3) We attach certain attributes that are useful for identifying informations: i) In $info and $costs, the attribute "column description" provide information of the formula and the description of each column ii) In $crops and $livestock-animals, the attribute "$crops.descriptions" and "$livestock.descriptions", provide the description of each CROP contained there iii) In $crops and $ the attribute "$column.formulas" provide the formulas used in order to derive the VALUE }