This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
install.packages("ggplot2") | |
library(ggplot2) | |
ggplot(data = data) + | |
aes(x = num_orders) + | |
geom_density(adjust = 1, fill = "#0c4c8a") + | |
theme_minimal() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ggplot(data = data) + | |
aes(x = num_orders, y = num_orders) + | |
geom_violin(scale = "area", adjust = 1, fill = "#0c4c8a") + | |
theme_minimal() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ggplot(data = data) + | |
aes(x = checkout_price, y = base_price) + | |
geom_point(color = "#1f9e89") + | |
theme_minimal() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(dplyr) | |
joined_data <- left_join(data,fc,by="center_id") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data %>% | |
select(center_type,num_orders) %>% | |
filter(center_type=="TYPE_A") %>% | |
summarise(avg_A=mean(num_orders)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data %>% | |
unite_(.,"email_home",c("emailer_for_promotion","homepage_featured")) %>% | |
head() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
str_c("x", "y") | |
> "xy" #output | |
str_c("x", "y", "z") | |
>"xyz" #output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x <- c("Apple", "Banana", "Pear") | |
str_sub(x, 1, 3) | |
> "App" "Ban" "Pea" #output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
center <- factor(data$center_type) | |
levels(center) | |
fct_count(center) #counts the number of categories |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
install.packages("lubridate") | |
library(lubridate) | |
dates <- c("January 11,2019" , "September 12, 2018", "April 1, 2019") | |
dates <- mdy(dates) |