Skip to content

Instantly share code, notes, and snippets.

View akshat3096's full-sized avatar

Akshat arora akshat3096

View GitHub Profile
install.packages("ggplot2")
library(ggplot2)
ggplot(data = data) +
aes(x = num_orders) +
geom_density(adjust = 1, fill = "#0c4c8a") +
theme_minimal()
ggplot(data = data) +
aes(x = num_orders, y = num_orders) +
geom_violin(scale = "area", adjust = 1, fill = "#0c4c8a") +
theme_minimal()
ggplot(data = data) +
aes(x = checkout_price, y = base_price) +
geom_point(color = "#1f9e89") +
theme_minimal()
library(dplyr)
joined_data <- left_join(data,fc,by="center_id")
data %>%
select(center_type,num_orders) %>%
filter(center_type=="TYPE_A") %>%
summarise(avg_A=mean(num_orders))
data %>%
unite_(.,"email_home",c("emailer_for_promotion","homepage_featured")) %>%
head()
str_c("x", "y")
> "xy" #output
str_c("x", "y", "z")
>"xyz" #output
x <- c("Apple", "Banana", "Pear")
str_sub(x, 1, 3)
> "App" "Ban" "Pea" #output
center <- factor(data$center_type)
levels(center)
fct_count(center) #counts the number of categories
install.packages("lubridate")
library(lubridate)
dates <- c("January 11,2019" , "September 12, 2018", "April 1, 2019")
dates <- mdy(dates)