Introduction to R: The Basics
-
Upload
isadora-figueroa -
Category
Documents
-
view
65 -
download
1
description
Transcript of Introduction to R: The Basics
![Page 1: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/1.jpg)
Introduction to R: The Basics
Rosales de Veliz L., David S.L., McElhiney D., Price E., & Brooks G.
Contributions from Ragan. M., Terzi. F., & Smith. E.
Midwestern Educational Research Association in Illinois, November 2012.
![Page 2: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/2.jpg)
Overview1. Getting Started
2. The Basics
3. Data Input
4. R Commander
5. Descriptive Statistics
6. Means Comparisons
7. Relationships
8. Factor Analysis
![Page 3: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/3.jpg)
Getting Started• To install R on your MAC or PC you first need to go to
http://www.r-project.org/.•
![Page 4: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/4.jpg)
![Page 5: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/5.jpg)
![Page 6: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/6.jpg)
![Page 7: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/7.jpg)
![Page 8: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/8.jpg)
![Page 9: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/9.jpg)
![Page 10: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/10.jpg)
Installing Packages
![Page 11: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/11.jpg)
![Page 12: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/12.jpg)
Using Help Command
• ?solve• help.search or ??
– allows searching for help in various ways
![Page 13: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/13.jpg)
R Basics
• R is object base– Types of objects (scalar, vector, matrices
and arrays– Assignment of objects
• Building a data frame
![Page 14: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/14.jpg)
R as a Calculator
> 1550+2000
[1] 3550
or various calculations in the same row
> 2+3; 5*9; 6-6
[1] 5
[1] 45
[1] 0
![Page 15: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/15.jpg)
Operation Symbols
Symbol Meaning
+ Addition
- Subtraction
* Multiplication
/ Division
%%Modulo (estimates
remainder in a division)^ Exponential
![Page 16: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/16.jpg)
Numbers in R: NAN and NA
• NAN (not a number)
• NA (missing value)– Basic handling of missing values
> x
[1] 1 2 3 4 5 6 7 8 NA
> mean(x)
[1] NA
> mean(x,na.rm=TRUE)
[1] 4.5
![Page 17: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/17.jpg)
Objects in R
• Objects in R obtain values by assignment.
• This is achieved by the gets arrow, <-, and not the equal sign, =.
• Objects can be of different kinds.
![Page 18: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/18.jpg)
Built in Functions
• R has many built in functions that compute different statistical procedures.
• Functions in R are followed by ( ).
• Inside the parenthesis we write the object (vector, matrix, array, dataframe) to which we want to apply the function.
![Page 19: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/19.jpg)
Vectors• Vectors are variables with one or more
values of the same type. • A variable with a single value is known as
scalar. In R a scalar is a vector of length 1. • There are at least three ways to create
vectors in R: (a) sequence, (b) concatenation function, and (c) scan function.
![Page 20: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/20.jpg)
Arrays
• Arrays are numeric objects with dimension attributes.
• The difference between a matrix and an array is that arrays have more than two dimensions.
![Page 21: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/21.jpg)
Matrices
• A matrix is a two dimensional array.
• The command colnames
![Page 22: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/22.jpg)
String Characters
• In R, string variables are defined by double quotation marks.
> letters
[1] "a" "b" "c"
![Page 23: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/23.jpg)
Subscripts and Indices
• Select only one or some of the elements in a vector, a matrix or an array.
• We can do this by using subscripts in square brackets [ ].
• In matrices or dataframes the first subscript refers to the row and the second to the column.
![Page 24: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/24.jpg)
Dataframe
• Researchers work mostly with dataframes .
• With previous knowledge you can built dataframes in R
• Also, import dataframes into R.
![Page 25: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/25.jpg)
R Commander• Loading R Commander
– Packages -> Install Packages -> Cran Mirror Selection -> Rcmdr
![Page 26: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/26.jpg)
Opening R CommanderOpen R -> Packages -> Load Packages -> Rcmdr
![Page 27: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/27.jpg)
Loading Data with R Commander• Data -> Load data
![Page 28: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/28.jpg)
Active Data with R Commander
Data ->Active data set -> Select active data set
![Page 29: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/29.jpg)
File/Edit Options
![Page 30: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/30.jpg)
SummariesStatistics -> Summaries
![Page 31: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/31.jpg)
Descriptive Statistics
![Page 32: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/32.jpg)
Mean, Standard Deviation, Skewness, Kurtosis
![Page 33: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/33.jpg)
![Page 34: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/34.jpg)
Contingency Tables
![Page 35: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/35.jpg)
![Page 36: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/36.jpg)
![Page 37: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/37.jpg)
Correlations in R Commander
![Page 38: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/38.jpg)
Correlations in R Commander
![Page 39: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/39.jpg)
Independent T-TestStatistics -> Independent T Test
![Page 40: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/40.jpg)
![Page 41: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/41.jpg)
![Page 42: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/42.jpg)
One Way ANOVAStatistics -> One Way ANOVA
![Page 43: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/43.jpg)
![Page 44: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/44.jpg)
Factor Analysis
![Page 45: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/45.jpg)
![Page 46: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/46.jpg)
![Page 47: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/47.jpg)
Graphs in R CommanderBox Plot
Graphs -> Box Plots
![Page 48: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/48.jpg)
Graphs in R CommanderScatter Plot
Graphs -> Scatter Plot
![Page 49: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/49.jpg)
Helpful ResourcesFox, J. (2005). R commander: A basic-statistics user interface to R. Journal of Statistical Software. 14, (9), 1-42.
Teetor, P. (2011). 25 Recipes for Getting Started with R. Sebastopol, CA: O’Reilly Media Inc.
Teetor, P. (2011). R cookbook. Sebastopol, CA: O’Reilly Media Inc.
Crowley, M. J. (2007). The R Book. Chichester, New England: John Wiley & Sons, Ltd.
![Page 50: Introduction to R: The Basics](https://reader035.fdocuments.net/reader035/viewer/2022062304/56812cd1550346895d918c07/html5/thumbnails/50.jpg)
Questions
Thank you for your time!!
Leslie Rosales de Veliz [email protected] Shannon David [email protected] Mc Elhiney [email protected] Price [email protected] Gordon Brooks [email protected]