In this post, I will record some common R’s packages and functions.
- drake_plan(): create a workflow data frame
- make(): build your project
- vis_drake_graph(): show an interactive visual network representation of your workflow
- drake_history(): show what you built, when you built in, and the function arguments you used
- loadd(): load one or more built targets into your R session
- readd(): read and return a built target
- outdated(): see which targets will be built in the next make()
- deps(): check the dependencies of a command or function
- failed(): list the targets that failed to build in the last make()
- diagnose(): return the full context of a build, including errors, warnings, and messages
- comment style
Use GET() function to connect with website and get data from it.
never use these two commands in the head of R script
- first (instead use here::here())
rm(list = ls())
Don’t try to change the .Rprofile and affect the data
check the loaded packages
set the working directory
I custom the shortcuting in R with *Cmd+Shift+H*.
tidy code’s formatation
Here I just introduce the tidy method in RStudio.
- select the region, e.g. *Cmd + A*
- print shortcuting *Cmd + Shift + A* to format the code or run *style active file* in addin
get file’s path
full_path <- normalizePath(file_eg) dir_name<-dirname() file_name<-basename()
Run R Code
library("ggplot2") ggplot(mpg) + geom_point(aes(x = displ, y = hwy, colour = cty, size = cty))