sdc_agrisvy.Rmd
#Introduction
One of the main use of the agrisvy
package is to
facilitate files and data management during anonymization of dataset,
spacially from household survey including agricultural survey
the package allow to create all the folders you need, it generate initial,pre-populated, R scripts you need for deta pre-processing and anonymization. It also generate an initial sample report in R markdown format and contains function that appends the report during the anonymizaion process.
This article shows howe to setup the anonymization files, folders, scripts and reports.
library(agrisvyr)
agrisvy <- agrisvyr::createAgrisvy(
svyName = "AGRIS survey 2023",
author = "AgriSvey Team",
language = "en",
workingDir = "C:/Users/USER/Documents/agrisvyr/anonymization",
dataDir = "C:/Users/USER/Documents/agrisvyr/example data",
type = ".dta"
)
print(agrisvy)
there two main inputs here: the path to the folder wher the microdata are located and the working directory for the aanonymization. All the working folders and files will be created in the working directory. However,the microdata can be in a different location. There are other input such as the names of the folders (if we want to use another language),the data type.
In order to facilitate the initial settings, we should create an
agrisvy object to store all this information once for all and then apply
the function setup_anonymization()
to the object to create
the folder and files.
# agrisvyr::setup_anonymization(agrisvy,overwrite = TRUE)
Now let us see the different folders and files created in our specified working directory
preProcScriptDir(agrisvy)
folder
showFolderTree(agrisvy,preProcScriptDir(agrisvy))
Template of the R script to be pre-populated
You have the possibility to inline data without opening the script of the corresponding data.
First you need to archive all the datasets (saving them in the agrisvy object)
agrisvyr::ArchiveCleanData(agrisvy)
Let us inline one dataset
library(data.tree)
FromListSimple(agrisvy@cleanData)
library(flextable)
library(magrittr)
head(agrisvy@cleanData$`Season 1_PH`$SEC2_V1_MEMBERS) %>% flextable()
It is possible to do the same for the pre-processed data and the
anonymized data with the functions ArchiveAnoData()
and
ArchiveProcData()
respectively