xlff_to_output: Read and wrangle excel-FastField and output dataframes or...

Description Usage Arguments Details Value Acknowledgment Author(s) Examples

Description

These functions read and wrangle excel workbooks produced by the FastField app and output a list of dataframes (xlff_to_list()), .csv files (xlff_to_csv()) or .xlsx files (xlff_to_xl()). Each dataframe or file combines all spreadsheets from a single excel workbook in the input directory. If the input directory has multiple workbooks, the output will be multiple dataframes, multiple .csv files, or multiple .excel files.

Usage

1
2
3
4
5
xlff_to_csv(dir_in, dir_out = "./", first_census = FALSE)

xlff_to_xl(dir_in, dir_out = "./", first_census = FALSE)

xlff_to_list(dir_in, first_census = FALSE, root_columns = NULL)

Arguments

dir_in

String giving the directory containing the excel workbooks to read from.

dir_out

String giving the directory where to write .csv files to.

first_census

Use TRUE if this is your first census. Use FALSE (default) if this is not your first census but a recensus.

root_columns

String. Lowercase name of column(s) in the root sheet ( e.g. c("date", "team")). This is useful when you data has non-standard columns.

Details

This is a rigid function with a very specific goal: To process data from FastField forms. Specifically, this is what this function does:

Value

xlff_to_csv() and xlff_to_xl() write a .csv or excel (.xlsx) file per workbook – combining all spreadsheets. xlff_to_list outputs a list where each dataframes combines all spreadsheeets of a workbook.

Acknowledgment

Author(s)

Mauro Lepore and Jessica Shue.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
library(fs)
library(readr)
library(readxl)

# NOT A FIRST CENSUS
# Path to the folder I want to read excel files from
dir_in <- dirname(misc_example("two_files/new_stem_1.xlsx"))
dir_in

# Files I want to read
dir(dir_in, pattern = "xlsx")

# Path to the folder I want to write .csv files to
dir_out <- tempdir()

# Output a csv file
xlff_to_csv(dir_in, dir_out)

# Confirm
path_file(dir_ls(dir_out, regexp = "new_stem.*csv$"))

# Also possible to output excel and a list of dataframe. See next section.

# FIRST CENSUS
dir_in <- dirname(misc_example("first_census/census.xlsx"))
# As a reminder you will get a warning of missing sheets
# Output list of dataframes (one per input workbook -- here only one)
lst <- xlff_to_list(dir_in, first_census = TRUE)
str(lst, give.attr = FALSE)

# Output excel
xlff_to_xl(dir_in, dir_out, first_census = TRUE)
# Read back
filename <- path(dir_out, "census.xlsx")
out <- read_excel(filename)
str(out, give.attr = FALSE)

forestgeo/fgeo.misc documentation built on June 23, 2019, 6:26 p.m.