Skip to contents

Reads and imports items and farm metadata from .xls, .xlsx or .json files containing IDEA4 data.

Usage

read_idea(input)

Arguments

input

a system path to the file containing the IDEA data. The file extension can either be json or xls(x). For the latter, the version number must be >= 4.2.0

Value

An object of class IDEA_items with two attributes :

metadata

a named list containing the 17 metadata entries about the farm

items

a tibble with the extracted 118 items found in the input

Details

This function is designed to import items and farm metadata from a single IDEA data file. Errors will be produced if the input file does not contain any "metadonnees" field in the case of a json file or any "Notice" sheet in the case of an excel file.

The R code has been developed according to the newest versions of IDEA data collecting files (version numbers >= 4.2.0) and will produce an error if the version number is lower than 4.2.0 or can't be found in the 'Notice$K4' cell of the input in the case of excel input. There are no limitations for json input files as they were introduced after version number 4.2.0.

For some older versions (from about 2019-01-01), you can replace the " read_idea() |> compute_idea() " pipeline by "old_idea()" which will focus on indicators rather than items.

Examples

library(IDEATools)
path <- system.file("example_data/idea_example_1.json", package = "IDEATools")
my_data <- read_idea(path)
my_data
#> $metadata
#> $metadata$MTD_00
#> [1] "4.2.1"
#> 
#> $metadata$MTD_01
#> [1] "100001"
#> 
#> $metadata$MTD_02
#> [1] 77
#> 
#> $metadata$MTD_03
#> [1] 2
#> 
#> $metadata$MTD_04
#> [1] 0
#> 
#> $metadata$MTD_05
#> [1] "36-45"
#> 
#> $metadata$MTD_06
#> [1] "6184 - Polyculture et/ou polyélevage (et apiculture)"
#> 
#> $metadata$MTD_07
#> [1] 0
#> 
#> $metadata$MTD_08
#> [1] 647629
#> 
#> $metadata$MTD_09
#> [1] 111703.5
#> 
#> $metadata$MTD_10
#> [1] 64404.5
#> 
#> $metadata$MTD_11
#> [1] "32 - Gers"
#> 
#> $metadata$MTD_12
#> [1] "1"
#> 
#> $metadata$MTD_13
#> [1] "2019"
#> 
#> $metadata$MTD_14
#> [1] "1"
#> 
#> $metadata$MTD_15
#> [1] 0
#> 
#> $metadata$MTD_16
#> [1] "1"
#> 
#> 
#> $items
#> # A tibble: 118 × 2
#>    item  value
#>    <chr> <int>
#>  1 A1_1      3
#>  2 A1_2      0
#>  3 A2_1      0
#>  4 A2_2      2
#>  5 A2_3      0
#>  6 A3_1      0
#>  7 A4_1      1
#>  8 A4_2      0
#>  9 A5_1      2
#> 10 A5_2      0
#> # ℹ 108 more rows
#> 
#> attr(,"class")
#> [1] "list"       "IDEA_items"