Editing Statistics and Statistical Programming (Winter 2017)/R lecture outline: Week 2
From CommunityData
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 6: | Line 6: | ||
*** make with factor("mako", "mika", "mako") | *** make with factor("mako", "mika", "mako") | ||
*** you can create factors from characters with as.factor() | *** you can create factors from characters with as.factor() | ||
** also think about: dates with POSIXct(), ordered() — really just a type of factor for ordinal data | |||
* matrix: lets create the table from the homework as a matrix | |||
** create from vectors: start with 1:9, then add real numbers: matrix(x, ncol=3) | |||
* lists: like vecotrs but can contains objects of any kind | * lists: like vecotrs but can contains objects of any kind | ||
** lets say we have two vectors: short.rivers (rivers * 0.5) and normal.rivers (rivers) | ** lets say we have two vectors: short.rivers (rivers * 0.5) and normal.rivers (rivers) | ||
Line 13: | Line 16: | ||
** index recursively: rivers.list$short.rivers[1] | ** index recursively: rivers.list$short.rivers[1] | ||
** some function work on lists: boxplot(rivers.list); some don't: hist(rivers) | ** some function work on lists: boxplot(rivers.list); some don't: hist(rivers) | ||
* data.frames: *the* most important data structure in R. we will be using them '''constantly''' | |||
* data.frames: | |||
**lets explore the faithful data.frame first | **lets explore the faithful data.frame first | ||
*** head(faithful); colnames(faithful); nrow(faithful); ncol(faithful) | *** head(faithful); colnames(faithful); nrow(faithful); ncol(faithful) |