Week 1 of the Computing for Data Analysis course focused mostly on getting R and RStudio installed. Then it focused on some of the basics of the R language. Here are some of the topics
- History of R
- How to get help
help()
- Data types in R
- numeric (real numbers)
- character (strings)
- integer (counting numbers)
- complex (imaginary)
- logical (TRUE/FALSE)
- Groupings of data
- vector (all the same data type)
v <- c(1.4, 2.5, 1.7)
v <- 1:10 - list (NOT all same data type)
lst <- list("a", 3.5, TRUE, "word", 4+5i) - matrix (2-dimensional vector)
m <- matrix(1:20, nrow=4, ncol=5)
- vector (all the same data type)
- Factor is for categorical data
f <- factor(c("big","small","big","big"))
table(f) - Missing Values
- NaN
is.nan()
(Not a Number) - NA
is.na()
(Not Available)
- NaN
- Reading/Writing data
d <- read.table("file.txt")
d <- read.csv("file.csv")
write.table("outFile.txt")
- Better Reading data
initial <- read.csv("data.csv", nrow=10)
classes <- sapply(initial, class)
fullData <- read.csv("data.csv", nrow=2000, colClasses=classes) - The
str()
function for displaying information about the structure of an object
If you hurry, there still might be time to enroll in the class and finish the homework for full credit. Week 1 was not too intensive.
Leave a Reply