- Tiny Desk & Activity (10 min)
- New material + discussions (50 min)
- Break (5 min)
- Additional material + discussions (25 min?)
- Problem set / final project questions (remainder)
2023-06-22
print.data.frame(groups)
## group 1 group 2 group 3 ## 1 Widodo, Ignazio Marco Alsayegh, Aisha E H M I Saccone, Alexander Connor ## 2 Cai, Qingyuan Tian, Zerui Shah, Jainam ## 3 Dotson, Bianca Ciara Jun, Ernest Ng Wei ## 4 Albertini, Federico Lim, Fang Jan Huynh Le Hue Tam, Vivian ## group 4 group 5 group 6 ## 1 Crawford, John Alexander Gupta, Umang Spindler, Laine Addison ## 2 Su, Barry Cortez, Hugo Alexander Ning, Zhi Yan ## 3 Premkrishna, Shrish Tan, Zheng Yang Ng, Michelle ## 4 Knutson, Blue C Leong, Wen Hou Lester ## group 7 ## 1 Wan Rosli, Nadia ## 2 ## 3 Andrew Yu Ming Xin, ## 4 Gnanam, Akash Y
source: bing AI art generator
##################################################### ## title: a new R script! ## author: you! ## purpose: to try out R ## date: today's date ##################################################### # you can start coding below
# what does R do with numbers? 2
## [1] 2
# what if we try adding or multiplying? 4+3
## [1] 7
53*2
## [1] 106
# what if we put all the previous results together? c(2, 3, 4+3, 53*2, 90*4/5)
## [1] 2 3 7 106 72
as.integer, as.numeric, as.character, as.logical)<, >, ==, !=, >=, <=) with different character and numeric values# what if we put all the previous results together?
matrix(c(2, 3, 4+3, 53*2, 90*4/5),
nrow = 5)
## [,1] ## [1,] 2 ## [2,] 3 ## [3,] 7 ## [4,] 106 ## [5,] 72
? sends you to the help page of whatever function follows it?matrix and then hit ctrl + entermatrix() functionc(your numbers here) inside? will give you more info on how a function works (i.e. ?matrix)list(c(2, 3, 4+3),
53*2,
90*4/5)
## [[1]] ## [1] 2 3 7 ## ## [[2]] ## [1] 106 ## ## [[3]] ## [1] 72
# assign "sum" to the sum of a few numbers penguin <- c(2, 3, 4+3, 53*2, 90*4/5) # now take a look at the result penguin
## [1] 2 3 7 106 72
# let's have R sum the numbers sum(c(2, 3, 4+3, 53*2, 90*4/5))
## [1] 190
# we'll call our function 'addition'
addition <- function(x, y){
return(x+y)
}
addition(2, 2)
## [1] 4
function(x))function(x,y))# try printing each of the first 10 numbers
for(i in 1:10){
print(i)
}
## [1] 1 ## [1] 2 ## [1] 3 ## [1] 4 ## [1] 5 ## [1] 6 ## [1] 7 ## [1] 8 ## [1] 9 ## [1] 10
i?1:10?# vector with 1-10 ten <- c(1:10) # try adding one ten + 1
## [1] 2 3 4 5 6 7 8 9 10 11
# vector with 1-10 ten <- c(1:10) sapply(ten, function(x) x + 1)
## [1] 2 3 4 5 6 7 8 9 10 11
#’s# first, we want to install the readr package
# note that i have commented out the following line,
# but you want to uncomment it the first time you run this code
#install.packages("readr")
# read as csv
library(readr)
temps <- read_csv("G:/My Drive/Data_Disasters/Course_site/Data/temps.csv")
## # A tibble: 10 × 2 ## Year `Annual Average Temperature (F)` ## <chr> <dbl> ## 1 1875 52.5 ## 2 1876 51.5 ## 3 1877 52 ## 4 1878 52.5 ## 5 1879 52.7 ## 6 1880 48.6 ## 7 1881 52.3 ## 8 1882 49.6 ## 9 1883 50.8 ## 10 1884 51
View() function“the initial environmental justice spark sprang from a Warren County, North Carolina, protest. In 1982, a small, predominately African-American community was designated to host a hazardous waste landfill. This landfill would accept PCB-contaminated soil that resulted from illegal dumping of toxic waste along roadways. After removing the contaminated soil, the state of North Carolina considered a number of potential sites to host the landfill, but ultimately settled on this small African-American community.”