[1] 2
[1] "beta"
[1] 0 1 2 3 4 5 6 7 8 9 10
[1] "alpha" "beta" "gamma" "delta" "epsilon"
Day 1 of the RII workshop, summer 2025
FSU
This workshop is a course on using R to prepare you for MLE, causal inference, and the rest of your lives as political scientists
By the end of this workshop, you should be at least familiar with:
for loopsnumeric, character, factor, etc.), how the data is actually structured is going to determine how we can use the datavectors, lists, matrices, and data frames[1] 2
[1] "beta"
[1] 0 1 2 3 4 5 6 7 8 9 10
[1] "alpha" "beta" "gamma" "delta" "epsilon"
as.numeric(), as.character(), as.double(), and as.factor() functions to force the vector to be a certain type of objectfilter() function)Individually, construct both a character and numeric vector. Practice extracting data from both types.
matrixmatrix() function in Rvectors manuallydataframe into a matrix using as.matrixvectors (and with lists) we can use []’s to extract data
, to distinguish between rows and columnsIndividually, construct a 4x4 matrix (or larger) – that is not the identity matrix. Practice extracting a row, a column, and a single data point from the matrix you created. (You can also practice naming rows and columns if you want to.)
%*%, t(), and solve()
%*% matrix multiplicationt() transposesolve() take the inverse of any invertible matrixUSJudgeRatings dataset, predict a judge’s “worthy of retention” rating (RTEN)lm() functionUSJudgeRatings dataset, predict a judge’s “worthy of retention” rating (RTEN)lists are another way of storing datadataframes, or vectors, or listsDataframes (and/or tibbles) are the most commonly used data structure in rdataframes can be selected using the $ function or with the select functionselect is slightly easier, but $ is more flexible because it can be used on lists as well[], just like with matrices and vectorsselect() and filter() and subset() for this if we have the right packages loaded[] is especially beneficial for instances where we’re looping through data[], however, these may need to be nested further ([[]]) due to how complex lists can getlm() or glm() are lists as wellUSJudgeRatings data using complex logical conditions
[[#]][#])for loops to do sofor loop is as follows:vec_4 from earlier, if we want to print each observation individually, we can do the followingUSJudgeRatings dataframe, storing that mean in a vector.
variables and one named means with the variable names and their meansmaximums instead