split_data_to_sheets: Split data to sheets within Excel workbook depending on the...

View source: R/split_data_to_sheets.R

split_data_to_sheetsR Documentation

Split data to sheets within Excel workbook depending on the config specified

Description

Split data to sheets within Excel workbook depending on the config specified

Usage

split_data_to_sheets(SLA_split, XL_wb, SLA_data, allDataSheet, outputCols)

Arguments

SLA_split

config for the split rules

XL_wb

Excel workbook

SLA_data

data

allDataSheet

name of the sheet to copy all data to

outputCols

columns to output

Examples

a <- c('','BirdsDir-A2.2')
b <- c('','')
c <- c('','')
d <- c('insect - butterfly','bird')
e <- c('Pieris rapae','Turdus merula')
f <- c('Small White','Blackbird')
g <- c('Mike Jeffries','Alnwick Wildlife Group')
h <- c('Morpeth Town','Morpeth Town')
i <- c('04/09/2010','04/09/2010')
j <- c('NZ18X','NZ18X')
k <- c('Butterfly Conservation','Alnwick Wildlife Group')
l <- c('Butterfly Conservation','Alnwick Wildlife Group')
m <- c('2 Count','1 Count')
n <- c('Considered Correct','Considered Correct')
o <- c(419000,419000)
p <- c(585000,585000)
q <- c(1000,1000)
r <- c('layer','layer')
s <- c('path','path')
df <- data.frame(a,b,c,d,e,f,a,g,h,h,i,j,k,l,m,n,o,p,q,r,s,s,s,s,s,s)
names(df) <- c('Designations', 'All UK Legally Protected (W&C Act, Badgers and Cons Regs) - Taxon Designated', 'Wildlife & Countryside Act Sch 9 Part 1', 'Wildlife & Countryside Act Sch 9 Part 2', 'Taxon group', 'Latin Name', 'Abundances', ',Determination Type','Comments', 'Recorder', 'Location Name', 'Date', 'Grid Reference','Cent_East', 'Cent_North',' Buffer',' Precision','Survey Run By', 'Survey Name', 'North East LBAP - Short Names', 'Common Name', 'England NERC S.41', 'Obs Changed Date', 'Obs Entry  Date', 'Obs Key', 'Additional Information'  )
outputCols <- c("Designations" , "Taxon group" , "Latin Name" , "Abundances" , "Determination Type", "Comments" , "Recorder" , "Location Name", "Date" , "Grid Reference", "Cent_East" , "Cent_North" , "Buffer" , "Precision" , "Survey Run By", "Survey Name" , "Common Name" , "Obs Changed Date", "Obs Entry Date", "Obs Key" , "Additional Information")

SLA_split <- tibble::tribble(~SheetLabel, ~FilterString,'Reptiles_data','tolower(SLA_data$`Taxon group`)=="reptile"')
XL_wb <- openxlsx::createWorkbook()

split_data_to_sheets(SLA_split,XL_wb,df,"All_data",outputCols)

ERICNorthEast/ERIC_Data_Proc documentation built on Dec. 5, 2023, 12:19 p.m.