# Good
x <- 42 + 18
# Bad
x<-42+18
snake_case
to stay consistent with tidyverse best practicessep.case
, but I think we should be consistent from here on outdf
or data
(bad Erin)Use “, not ’, for quoting text. The only exception is when the text already contains double quotes and no single quotes.
# Good
"Text"
## [1] "Text"
'Text with "quotes"'
## [1] "Text with \"quotes\""
# Bad
'Text'
## [1] "Text"
Use <-
not =
for assignment
I know it takes some time to get used to, but it makes your code look much cleaner.
# Good
x <- 42
# Bad
x = 42
# Really bad
x=42
Clean this piece of code up using these style suggestions.
library(tidyverse)
library(readxl)
df <- read_rds("S:/Data Analytics/State Test Analysis/2016-2017/Cross Regional Analyses/~Data/Processed/Output/historical_state_test_and_ias_cleaned.rds")
df_Math <- df %>% filter(Subject=="Math") %>% mutate(Score = as.numeric(Score), Overall=as.numeric(Overall))
Math_average_Cycle <- df_Math %>% group_by(Student.ID, Grade, School, Year) %>% dplyr::summarise(Score = max(Score, na.rm = T), Overall = mean(Overall, na.rm =T)) %>% mutate(Grade.Span = ifelse(Grade >= 5, "MS", "ES"))
praise::praise()
## [1] "You are charming!"