Using R Modules
What You Will Learn In This Course:
Using R Modules
CLC 0301 (Advanced)
Installing and running R and RStudio
- What is R
- What is RStudio
- Downloading and installing R
- Downloading and installing RStudio
- Running RStudio and describing its various windows
- Setting the working directory
- Getting help
Data Frames
- Creating data frames from vectors
- Renaming columns
- Adding new columns or rows to a data frame
- Removing a column from a data frame
- Various ways of accessing columns and subsetting data frames
- Summarizing data frames
- Extracting certain columns from a data frame
- Querying data frame
- Functions to cover: data.frame, names, class, nrow, ncol, summary, dim
Basic data types: integers, numerics, characters, logicals, and factors
- Numeric
- Character
- Logical
- Factor
- Talk about what these variables are good for and what their values look like
- Variables of these types
- Convert between from one type to another
Descriptive Statistics with R
Descriptive statistics allow us to describe the central tendencies and variability of a data-set. Measures of central tendency include the mean, median, and mode, while measures of variability include frequency distribution, quantiles, variance, standard deviation, and range. In this video, we use R to execute commands that quickly calculate each of these.
Random Samples and Probability Distributions
In this tutorial, we explore R's random sample and probability distribution functions. These functions allow R users to generate random numerical and probability distribution data, which can be used to simulate and make preparations for the future.
Data structures: vectors and matrices
- What vectors are
- Ways of creating vectors: c, ranges, seq, rep
- Everything in R is a vectorized
- Applying operations and functions to vectors
- What matrices are
- Creating a matrix
- Various ways of accessing and subsetting a matrix
- cbind and rbind
Variables and Operators
- Arithmetic operations (+, -, *, /, %%, ^
- Relational operators
- Logical operators
- Variables
- Assignments
Importing data into R
- Setting working directory
- Importing txt files
- Importing csv files
- Importing Excel files
- Importing from other statistical software like SAS, SPSS
Correlations
In this video, we use R to get a sense of the correlation that exists between two variables. We plot dependent variables as functions of the independent variables, quantify a correlation using the correlation coefficient and the coefficient of determination, and take a look at several examples of strong and weak correlations.
Packages
What is a package
Where to look up packages
Displaying package documentation
Installing a package: command-line and using RStudio user interface
Updating, removing, and checking installed packages
Loading packages: require and library
Frequency Tables and Histograms
- Frequency tables of categorical data (use length and table functions with and without data frames)
- Frequency tables with numeric data
- Creating histograms with the hist function
- Customizing histograms using the hist function options (colors, names, axes ranges, # of bars)
- Indicating means and quantiles on histogram
- Adding lines and curves to histograms (using lines and abline function)
Exporting data from R
- Setting the working directory
- Saving and loading workspace
- Exporting data frames to tab delimited and CSV text files
- Exporting to Excel spreadsheets
- The package foreign for exporting to SPSS, SAS, and Stata
- Saving graphs into pdfs and/or images(PNG, JPEG, SVG)
Multiple Linear Regression & Curve Fitting
In this video, we cover how R’s lm() function can be used to create multivariate linear models and fit polynomial curves to data. We begin by using R to explain and predict batting averages for a baseball team using many other variables. Next, we use R to fit several polynomial curves to a data set showing how housing prices change depending on the amount of time they spend on the market. We then use one of these curves to predict future data.
Simple Linear Regression
In this tutorial, we use R to perform a linear regression that uses just one dependent and one independent variable. We build a linear model using the lm function, use R to find its coefficients and make predictions based on it, and then check how well the model fits our data using residual analysis and the coefficient of determination.
Visualizing Data
This video is an introduction to R's data visualization tools. In it, we create column and bar charts, box and whisker plots, scatter plots, and line plots.
