#rstats π¦.I'm looking for 2 class rep. Please nominate yourself over the chat.
student tests, titanic, wagesstudent test dataset?library(dplyr)starwars %>% group_by(species) %>% summarise( n = n(), mass = mean(mass, na.rm = TRUE) ) %>% filter(n > 1, mass > 50)
library(cowsay)say("Kia Ora!")
#> #> -------------- #> Kia Ora! #> --------------#> \#> \#> \#> |\___/|#> ==) ^Y^ (==#> \ ^ /#> )=*=(#> / \#> | |#> /| | | |\#> \| | |_|/\#> jgs //_// ___/#> \_)#>We'll learn each of these modules through the semester.
.html and .pdfR Markdown documents are fully reproducible: weaving narrative text and code together.



300, automatically grade your labs
If R were an airplane, RStudio would be the airport, providing many, many supporting services that make it easier for you, the pilot, to take off and go to awesome places. Sure, you can fly an airplane without an airport, but having those runways and supporting infrastructure is a game-changer.
-- Julie Lowndes
Hope you've downloaded r and rstudio

image credit: Stuart Lee
live
Go to Tools > Global Options:

Uncheck Workspace and History, which helps to keep R working environment fresh and clean every time you switch between projects.
Change the RStudio appearance up to your taste

01:00
1 minutes to choose your favourite theme
stats220/ π includes:stats220.Rprojdata/*.csv, *.xlsxlectures/01-intro.Rmd, 02-import-export.Rmdlabs/lab01.R, lab02.Rstats220/).Jenny Bryan will set your computer on fire π₯
setwd("C:\Users\jenny\path\that\only\I\have")
rm(list = ls())
.Rproj

akl_lon <- 174.76akl_lat <- -36.85
β¬οΈ read as "assign the value of 174.76 to an object called akl_lon".
An assignment consists of:
akl_lon)<- (RStudio shortcut: Alt + -)174.76)akl_lon
#> [1] 174.76akl_lat
#> [1] -36.85akl_Lon
#> Error in eval(expr, envir, enclos): object 'akl_Lon' not found+, -, *, /, ^, %% (modulo), %/% (integer division)==, !=, >, <, >=, <=, %in%akl_lon_region <- akl_lon + c(-1, 1)akl_lat_region <- akl_lat + c(-.5, .5)akl_lon_region
#> [1] 173.76 175.76akl_lat_region
#> [1] -37.35 -36.35Good coding style is like correct punctuation: you can manage without it, butitsuremakesthingseasiertoread.
-- The tidyverse style guide
snake_casecamelCase (Javascript)PascalCase (Python)
image credit: Hadley Wickham's Advanced R
TRUE or FALSE174.76, 1.7476e2, Inf, -Inf, NaN (Not a Number)174L"hello", 'world'lgl_vec <- c(TRUE, FALSE)int_vec <- c(174L, -36L)dbl_vec <- c(174.76, -36.85)chr_vec <- c("long", "lat")
NA # Not Applicable
#> [1] NAc(174.76, NA, -36.85)
#> [1] 174.76 NA -36.85length(NA)
#> [1] 1NULL objectNULL
#> NULLc(174.76, NULL, -36.85)
#> [1] 174.76 -36.85length(NULL)
#> [1] 0
[]x <- c(akl_lon_region, akl_lat_region)x
#> [1] 173.76 175.76 -37.35 -36.35x[c(1, 3)]
#> [1] 173.76 -37.35x[-c(3, 1)]
#> [1] 175.76 -36.35[]x[c(TRUE, FALSE, TRUE, FALSE)]
#> [1] 173.76 -37.35x[lgl_vec] # recycling
#> [1] 173.76 -37.35x[x > 0]
#> [1] 173.76 175.76x[0]
#> numeric(0)x[]
#> [1] 173.76 175.76 -37.35 -36.35[] on the LHSy <- xy
#> [1] 173.76 175.76 -37.35 -36.35y[1:3] <- y[1:3] %/% 2y
#> [1] 86.00 87.00 -19.00 -36.35[] subsets vector y[] modifies vector yA function call consists of the function name followed by one or more argument within parentheses.
mean(x = x)
#> [1] 68.955mean(), a built-in R function to compute mean of a vectorx) to specify the data (RHS x)+Check the function's help page with ?mean
mean(x, trim = 0, na.rm = FALSE, ...)
trim do?01:00
Match by positions
mean(x, 0.1, TRUE)
#> [1] 68.955
Match by names
mean(x, na.rm = TRUE, trim = 0.1)
#> [1] 68.955# install.packages("dplyr")library(dplyr)cummean(x)
#> [1] 173.7600 174.7600 104.0567 68.9550first(x)
#> [1] 173.76last(x)
#> [1] -36.35
# function_name <- function(arguments) {# function_body# }my_mean <- function(x, na.rm = FALSE) { summation <- sum(x, na.rm = na.rm) summation / length(x)}my_mean(x)
#> [1] 68.955#rstats community
#rstats π¦.Keyboard shortcuts
| β, β, Pg Up, k | Go to previous slide |
| β, β, Pg Dn, Space, j | Go to next slide |
| Home | Go to first slide |
| End | Go to last slide |
| Number + Return | Go to specific slide |
| b / m / f | Toggle blackout / mirrored / fullscreen mode |
| c | Clone slideshow |
| p | Toggle presenter mode |
| t | Restart the presentation timer |
| ?, h | Toggle this help |
| Esc | Back to slideshow |