knitr::opts_chunk$set(echo = TRUE)
First load in common libraries used by this package.
library(ggplot2) library(tidyverse) library(pkgdown)
you might need to install some genomics R Packages for this package to run.
now, we install my R package ``````r devtools::install_github("mniculai/R_package_Niculai") library(projects)
Let us download some crab data for our package: ```r download.file(url = "https://raw.githubusercontent.com/mniculai/R_package_Niculai/master/vignettes/Data/crabs_data.csv", destfile = "/cloud/project/data/crabs_data.csv")
Now, we read the crab data with the tidyverse library
surveys <- read_csv("data/crabs_data.csv")
BOXPLOT Fucntion :
boxplot_length <- function(.,color,carapace_length){ if(!is.data.frame(crabs_data)){ return("this is not a dataframe") } plot <- ggplot(data = crabs_data, mapping = aes(x = color, y = carapace_length)) + geom_boxplot(alpha = 0) + geom_jitter(alpha = 0.3, color = "tomato") return(plot) }
Output of the boxplot_length function paired with the piped code will return a box plot with carapace length goruped by color.
crabs_data%>% select(color,carapace_length)%>% boxplot_length(color = color, carapace_length = carapace_length)
SCATTER PLOT FUNCTION :
crab_plot <- function(., carapace_length, carapace_width){ if(!is.data.frame(crabs_data)){ return("this is not a dataframe") } plot_scatter <- ggplot(data = crabs_data, mapping = aes(x = carapace_length, y = carapace_width)) + geom_point() return(plot_scatter) }
crabs_data%>% select(carapace_length, carapace_width)%>% crab_plot(carapace_length = carapace_length, carapace_width = carapace_width)
liNEAR REGRESSION PLOT:
crab_regression <- function(.,carapace_length, body_depth){ if(!is.data.frame(crabs_data)){ return("this is not a dataframe") } plot_regression <- ggplot(., aes(x = carapace_length, y = body_depth)) + geom_point(size=.25) + geom_smooth(method = "lm",color= "blue", size=.5, fill="black") return(plot_regression) }
crabs_data%>% select(carapace_length, body_depth)%>% crab_regression(carapace_length = carapace_length, body_depth = body_depth)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.