In this video, I'd like to show you the bare minimum of what we need to know to render a visualization in ggplot. The bare minimum is that we need to use the three essential layers (three out of seven possible). Those three essential layers are data, aesthetics, and giome (short for geometries...
David introduces the package that's called readr, which is part of the tidy verse, and this is the package that we would use to import external files into our R environment as usable R objects. In the tidy verse those would be called Tibbles, but a Tibble is just an enhanced user-friendly...
read.table() is the core function for loading files external file into R dataframes; it is part of the utils package which is automatically loaded when you start R. Aside from the header argument, the sep and quote arguments define the field separators. The read.csv() function is a wrapper...
Tidy data meets three conditions: 1. Each variable must have its own column; 2. each observation must have its own row; and 3. Each value must have its own cell.
R has three subset operators: [, [[, and $. Given data frame df, both of these return a data frame: df["z"], df[3]. Given a data frame df, all three of these commands are identical and return a vector: df$z, df[["z"]], df[[3]].
David's script is here...
In R a matrix is an atomic vector with the dimension attribute. In this example, the correlation matrix is entered as a vector with sixteen elements: rho_v <-c(1.000, ...). Then the vector is translated into a matrix with rho <- matrix(rho_v, nrow = 4, ncol =4). Now it is a matrix because it has...
Factors are categorical vectors. Specifically, they are (integer) vectors that store categorical values, or ordinal values. Ordinal values are *ranked* categories (but they are not intervals). Factors can only contain predefined values. A classic example of a factor are male/female. An example...
Data frames are the most common structure in R. A data frame is a list of equal-length vectors; ie, it's a rectangle. Create a data frame with data.frame(). Single-brackets, stocks[1], returns a dataframe. Double-brackets, stocks[[1]], returns a vector and is equivalent to stocks$ticker. We can...
Unlike atomic vectors, list (vectors) are flexible: each element can be a different type (char, integer, numeric, logical or even a sub-list!). List returns the i-th element as a list, while list[] returns the element as a vector. If the element is named, then list[["name"]] = list[] =...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.