Skip to content

Set of R functions and scripts to automate daily tasks such as creating project directory folder structure or binding several csv files into one master file

License

Notifications You must be signed in to change notification settings

Pablo-source/R-Automation-Functions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

R GitHub all releases GitHub language count

R-Automation-Functions

Set of R functions and scripts to automate daily tasks such as creating project directory folders structure or binding several csv files into one master file

  • 00.Setup project structure.R

    • Build a function to be used across different projects
    • It creates a set of folders and sub-folders (data,Output,Shapefiles,Checks,Maps,Archive)
    • We make use of here() function from here package, to ensure we use relative paths to the Project tolder
    • The last action included in the function will create sub-folders based on pre-existing folders
    • This project_setup function has no argumentas as we want it to be the first step on ny given project

    01. Add columns to dataframe specific order.R

    02. Combine csv files into master one.R

    • How to read in several .csv files into R
    • How to append them to create a single combined file

    03. Install several packages at once.R

    04. Working with files and folders.R

    05. Relative paths using HERE package.R

  • The here package creates paths relative to the top-level directory. The package displays the top-level of the current project on load or any time you call here():

here::i_am("README.Rmd") #> here() starts at /home/kirill/git/R/here here() #> [1] "/home/kirill/git/R/here"

  • You can build a path relative to the top-level directory in order to read or write a file: here("inst", "demo-project", "data", "penguins.csv")

#> [1] "/home/kirill/git/R/here/inst/demo-project/data/penguins.csv"

readr::write_csv(palmerpenguins::penguins, here("inst", "demo-project", "data", "penguins.csv"))

  • These relative paths work regardless of where the associated source file lives inside your project, like analysis projects with data and reports in different subdirectories. See the included demo project for an example.

06. Read and write CSV files using relative paths There is a brief description of each script aim below the first initial comit label at the top

DPLYR verbs folder

Set of tricks and advanced data wrangling manipulation verbs using DPLYR, some of these scrips refer to data preparation whilst others refer to how to perform variable calculations or softs searhcs when using where statements.

  • Soft searches using str_detect with long variable names and FILTER verb

  • Recode variables using CASE WHEN in DPLYR

  • Subset rows based on variable values ising %IN verb

  • Subset rows using FILTER with string patterns usnig CASE WHEN verb

  • How to use FILTER with IN and NOT IN verbs to subset rows

About

Set of R functions and scripts to automate daily tasks such as creating project directory folder structure or binding several csv files into one master file

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published