0% found this document useful (0 votes)
101 views50 pages

R Basics: Getting Started Guide

This document provides an introduction to the basics of R, including getting started with R, installing packages, using help commands, working with different data types like vectors, matrices, and data frames, importing and exploring data, and using R Commander for descriptive statistics and graphs. Key functions and operations in R are explained such as assignment with <-, built-in functions, subscripts and indices for selecting elements, and handling missing data. The document concludes with helpful R resources for learning more.

Uploaded by

raj28_999
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
101 views50 pages

R Basics: Getting Started Guide

This document provides an introduction to the basics of R, including getting started with R, installing packages, using help commands, working with different data types like vectors, matrices, and data frames, importing and exploring data, and using R Commander for descriptive statistics and graphs. Key functions and operations in R are explained such as assignment with <-, built-in functions, subscripts and indices for selecting elements, and handling missing data. The document concludes with helpful R resources for learning more.

Uploaded by

raj28_999
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd

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.
Overview
1. Getting Started
2. The Basics
3. Data Input
4. R Commander
5. Descriptive Statistics
6. Means Comparisons
7. Relationships
8. Factor Analysis
Getting Started
To install R on your MAC or PC you first need to go to
[Link]

Installing Packages
Using Help Command

?solve
[Link] or ??
allows searching for help in various ways
R Basics
R is object base
Types of objects (scalar, vector, matrices
and arrays
Assignment of objects
Building a data frame
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
Operation Symbols
Symbol Meaning
+ Addition
- Subtraction
* Multiplication

/ Division
Modulo (estimates
%%
remainder in a division)
^ Exponential
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,[Link]=TRUE)
[1] 4.5
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.
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.
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.
Arrays
Arrays are numeric objects with
dimension attributes.
The difference between a matrix and
an array is that arrays have more than
two dimensions.
Matrices
A matrix is a two dimensional array.
The command colnames
String Characters
In R, string variables are defined by
double quotation marks.
> letters
[1] "a" "b" "c"
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.
Dataframe
Researchers work mostly with
dataframes .
With previous knowledge you can built
dataframes in R
Also, import dataframes into R.
R Commander
Loading R Commander
Packages -> Install Packages -> Cran Mirror Selection -> Rcmdr
Opening R Commander
Open R -> Packages
-> Load Packages ->
Rcmdr
Loading Data with R Commander
Data -> Load data
Active Data with R Commander
Data ->Active data
set -> Select active
data set
File/Edit Options
Summaries
Statistics -> Summaries
Descriptive Statistics
Mean, Standard Deviation,
Skewness, Kurtosis
Contingency Tables
Correlations in R Commander
Correlations in R Commander
Independent T-Test
Statistics -> Independent T Test
One Way ANOVA
Statistics -> One Way ANOVA
Factor Analysis
Graphs in R Commander
Box Plot
Graphs -> Box Plots
Graphs in R Commander
Scatter Plot
Graphs -> Scatter Plot
Helpful Resources
Fox, 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: OReilly Media Inc.
Teetor, P. (2011). R cookbook. Sebastopol, CA: OReilly Media Inc.
Crowley, M. J. (2007). The R Book. Chichester, New England: John Wiley & Sons, Ltd.
Questions

Thank you for your time!!

Leslie Rosales de Veliz lr236007@[Link]


Shannon David sd156409@[Link]
Danielle Mc Elhiney dm356310@[Link]
Emily Price ep311508@[Link]
Gordon Brooks brooksg@[Link]

Common questions

Powered by AI

The mean() function in R is used to calculate the average of a numeric vector, often with the additional option of excluding NA values . In contrast, summary() provides a more comprehensive overview of an object's data, including the minimum, maximum, mean, and quartiles . While mean() is ideal for straightforward averaging tasks, summary() is more suited for exploratory data analysis due to its detailed data description .

R's help features, such as the help() function, question mark notation ?function, and help.search, provide comprehensive documentation and examples that are invaluable for learning the language and troubleshooting issues . They offer immediate guidance on function usage, parameter specifications, and code examples, thus facilitating self-directed learning and problem-solving .

R accommodates missing data handling through the use of the NA symbol, representing missing values, and built-in functions like mean() that have options such as na.rm=TRUE to exclude these values from calculations . Handling missing data is crucial because it ensures the accuracy and reliability of statistical analyses, allowing researchers to make valid conclusions from incomplete datasets .

Vectors in R are significant because they handle data sequences of the same type and are fundamental in performing vectorized operations, which enhance computation efficiency . Methods to create vectors include sequences using the colon operator, the c() concatenation function, and the scan() function for direct input, providing flexibility in data handling and initialization .

R Commander simplifies the use of R for statistical analysis by providing a graphical user interface that eliminates the need to write code for basic statistical tasks . Its core functionalities include loading data, performing descriptive statistics, conducting independent t-tests and one-way ANOVA, and creating various types of plots such as box plots and scatter plots . This interface is particularly helpful for users who are less familiar with programming, as it makes complex analyses more accessible .

Matrices in R are two-dimensional arrays, meaning they have rows and columns, while arrays can have more than two dimensions . Both structures are integral for data manipulation, as matrices are useful for linear algebra calculations, while arrays allow for multi-dimensional data analysis by providing a structured format to organize data efficiently .

Built-in functions in R, like mean(), sum(), and lm(), enhance its statistical computing capabilities by providing predefined tools for common analyses and data operations . For instance, mean() calculates the average of a numeric vector, sum() adds numbers together, and lm() performs linear modeling, allowing users to conduct complex statistical analyses efficiently without extensive coding .

Subscripts in R allow users to access specific elements within vectors, matrices, and arrays using square brackets []. Their importance lies in facilitating precise data manipulation, enabling operations on specific data subsets, which is essential for efficient data analysis and manipulation, especially in large datasets .

Distinguishing between NA (missing value) and NaN (Not a Number) is important because they represent different data issues; NA indicates unavailable data, while NaN signifies the result of undefined mathematical operations, like 0/0 . These distinctions impact data analysis as they require different handling techniques to ensure validity and reliability of statistical inferences .

In R, the assignment operator '<-' is crucial for assigning values to objects. This differs from other languages, which often use the '=' sign for assignment . Proper value assignment is essential in R because it maintains the integrity of data operations and ensures that the results of computations are stored correctly .

You might also like