SlideShare a Scribd company logo
1 of 18
Download to read offline
R Studio
R Basics
Packages
Workshop Preliminaries
Introduction to R
Olga Scrivner
1 / 17
R Studio
R Basics
Packages
R software
R is a free software for statistical analysis, text mining and
graphics.
To install R on Window:
1 Download the binary file for R https://cran.
r-project.org/bin/windows/base/R-3.3.1-win.exe
2 Open the downloaded .exe file and Install R
To install R on Mac:
1 Download the appropriate version of .pkg file
https://cran.r-project.org/bin/macosx/
2 Open the downloaded .pkg file and Install R
2 / 17
R Studio
R Basics
Packages
R Studio
RStudio is a free user interface for R.
1 Install the appropriate RStudio version https:
//www.rstudio.com/products/rstudio/download/
2 Run it to install R-studio
3 / 17
R Studio
R Basics
Packages
R Studio Structure
For more details - see handout RStudio101 (by Oscar
Torres-Reyna)
4 / 17
R Studio
R Basics
Packages
Creating Scripts
Create R File: File → New File → R Script
Save R File: File → Save - name it (ex. myscript1.r)
Close R File: File → Close
Open R File: File → Open
5 / 17
R Studio
R Basics
Packages
Creating Files
6 / 17
R Studio
R Basics
Packages
Learning R Syntax
Assignment of a value to a variable is done with <- (no
space).
variable <- value
7 / 17
R Studio
R Basics
Packages
Learning R Syntax
Assignment of a value to a variable is done with <- (no
space).
variable <- value
NB: Compare this structure to a factor and its values: factor
(variable) is a fixed name, while factor values can change.
gender <-“m”
gender <-“f”
7 / 17
R Studio
R Basics
Packages
Strings
Strings (characters) are enclosed in quotation marks:
mystring <-“This is my string”
Numbers are without quotation marks:
mynumber <- 5
8 / 17
R Studio
R Basics
Packages
Run - Practice
To execute your commands you need to click run
Open your R file
Type mystring <-“This is my string”
Keep your cursor on the same line and click run
Type print(mystring)
Look at your console (bottom left)
9 / 17
R Studio
R Basics
Packages
Vector
Vector is a sequence of strings (or numbers)
vector <- c(“string1”,“string2”,“string3”)
vector <- c(1,2,3,4)
Practice:
Type mywords <-c(“These”, “are”,“my”,“words”)
Keep your cursor on the same line and click run
Type print(mywords)
10 / 17
R Studio
R Basics
Packages
Length
Length of string vector - how many elements (words) are in
the vector
mywords <-c(“These”, “are”,“my”,“words”)
1 How many words in mywords?
Type length(mywords) and Run
2 What is the first word in mywords?
Type mywords[1] and Run
3 What are the second and third words in mywords?
Type mywords[2:3] and Run
11 / 17
R Studio
R Basics
Packages
Installing Packages
In your bottom left window - go to Packages
12 / 17
R Studio
R Basics
Packages
Selecting Packages - Practice
13 / 17
R Studio
R Basics
Packages
Package = Library
In your Packages window scroll down until you see languageR
and click inside the box:
14 / 17
R Studio
R Basics
Packages
Package Content
To access package description and its content, click on the
package name.
New window Help will open up:
15 / 17
R Studio
R Basics
Packages
Accessing Info from Packages
Scroll down and select languageR-package
You will see the list of available functions from this package
16 / 17
R Studio
R Basics
Packages
Quick Help
Type in the console (bottom left):
?length
Instead of Run - click enter-key
17 / 17

More Related Content

More from Olga Scrivner

The Impact of Language Requirement on Students' Performance, Retention, and M...
The Impact of Language Requirement on Students' Performance, Retention, and M...The Impact of Language Requirement on Students' Performance, Retention, and M...
The Impact of Language Requirement on Students' Performance, Retention, and M...Olga Scrivner
 
If a picture is worth a thousand words, Interactive data visualizations are w...
If a picture is worth a thousand words, Interactive data visualizations are w...If a picture is worth a thousand words, Interactive data visualizations are w...
If a picture is worth a thousand words, Interactive data visualizations are w...Olga Scrivner
 
Introduction to Interactive Shiny Web Application
Introduction to Interactive Shiny Web ApplicationIntroduction to Interactive Shiny Web Application
Introduction to Interactive Shiny Web ApplicationOlga Scrivner
 
Introduction to Overleaf Workshop
Introduction to Overleaf WorkshopIntroduction to Overleaf Workshop
Introduction to Overleaf WorkshopOlga Scrivner
 
R crash course for Business Analytics Course K303
R crash course for Business Analytics Course K303R crash course for Business Analytics Course K303
R crash course for Business Analytics Course K303Olga Scrivner
 
Workshop nwav 47 - LVS - Tool for Quantitative Data Analysis
Workshop nwav 47 - LVS - Tool for Quantitative Data AnalysisWorkshop nwav 47 - LVS - Tool for Quantitative Data Analysis
Workshop nwav 47 - LVS - Tool for Quantitative Data AnalysisOlga Scrivner
 
Gender Disparity in Employment and Education
Gender Disparity in Employment and EducationGender Disparity in Employment and Education
Gender Disparity in Employment and EducationOlga Scrivner
 
CrashCourse: Python with DataCamp and Jupyter for Beginners
CrashCourse: Python with DataCamp and Jupyter for BeginnersCrashCourse: Python with DataCamp and Jupyter for Beginners
CrashCourse: Python with DataCamp and Jupyter for BeginnersOlga Scrivner
 
Optimizing Data Analysis: Web application with Shiny
Optimizing Data Analysis: Web application with ShinyOptimizing Data Analysis: Web application with Shiny
Optimizing Data Analysis: Web application with ShinyOlga Scrivner
 
Data Analysis and Visualization: R Workflow
Data Analysis and Visualization: R WorkflowData Analysis and Visualization: R Workflow
Data Analysis and Visualization: R WorkflowOlga Scrivner
 
Reproducible visual analytics of public opioid data
Reproducible visual analytics of public opioid dataReproducible visual analytics of public opioid data
Reproducible visual analytics of public opioid dataOlga Scrivner
 
Building Effective Visualization Shiny WVF
Building Effective Visualization Shiny WVFBuilding Effective Visualization Shiny WVF
Building Effective Visualization Shiny WVFOlga Scrivner
 
Building Shiny Application Series - Layout and HTML
Building Shiny Application Series - Layout and HTMLBuilding Shiny Application Series - Layout and HTML
Building Shiny Application Series - Layout and HTMLOlga Scrivner
 
Introduction to R - from Rstudio to ggplot
Introduction to R - from Rstudio to ggplotIntroduction to R - from Rstudio to ggplot
Introduction to R - from Rstudio to ggplotOlga Scrivner
 
Visual Analytics for Linguistics - Day 5 ESSLLI 2017
Visual Analytics for Linguistics - Day 5 ESSLLI 2017Visual Analytics for Linguistics - Day 5 ESSLLI 2017
Visual Analytics for Linguistics - Day 5 ESSLLI 2017Olga Scrivner
 
Visual Analytics for Linguistics - Day 4 ESSLLI - structured data
Visual Analytics for Linguistics - Day 4 ESSLLI - structured dataVisual Analytics for Linguistics - Day 4 ESSLLI - structured data
Visual Analytics for Linguistics - Day 4 ESSLLI - structured dataOlga Scrivner
 
Visual Analytics for Linguistics - Day 3 ESSLLI
Visual Analytics for Linguistics - Day 3 ESSLLIVisual Analytics for Linguistics - Day 3 ESSLLI
Visual Analytics for Linguistics - Day 3 ESSLLIOlga Scrivner
 
Visualization Design, Methods and Tools - ESSLLI 2017 Workshop Day 2
Visualization Design, Methods and Tools - ESSLLI 2017 Workshop Day 2Visualization Design, Methods and Tools - ESSLLI 2017 Workshop Day 2
Visualization Design, Methods and Tools - ESSLLI 2017 Workshop Day 2Olga Scrivner
 
Data Visualization Workshop Day 1 - ESSLLI 2017
Data Visualization Workshop Day 1 - ESSLLI 2017Data Visualization Workshop Day 1 - ESSLLI 2017
Data Visualization Workshop Day 1 - ESSLLI 2017Olga Scrivner
 
Data Visualization for Literary Analysis
Data Visualization for Literary AnalysisData Visualization for Literary Analysis
Data Visualization for Literary AnalysisOlga Scrivner
 

More from Olga Scrivner (20)

The Impact of Language Requirement on Students' Performance, Retention, and M...
The Impact of Language Requirement on Students' Performance, Retention, and M...The Impact of Language Requirement on Students' Performance, Retention, and M...
The Impact of Language Requirement on Students' Performance, Retention, and M...
 
If a picture is worth a thousand words, Interactive data visualizations are w...
If a picture is worth a thousand words, Interactive data visualizations are w...If a picture is worth a thousand words, Interactive data visualizations are w...
If a picture is worth a thousand words, Interactive data visualizations are w...
 
Introduction to Interactive Shiny Web Application
Introduction to Interactive Shiny Web ApplicationIntroduction to Interactive Shiny Web Application
Introduction to Interactive Shiny Web Application
 
Introduction to Overleaf Workshop
Introduction to Overleaf WorkshopIntroduction to Overleaf Workshop
Introduction to Overleaf Workshop
 
R crash course for Business Analytics Course K303
R crash course for Business Analytics Course K303R crash course for Business Analytics Course K303
R crash course for Business Analytics Course K303
 
Workshop nwav 47 - LVS - Tool for Quantitative Data Analysis
Workshop nwav 47 - LVS - Tool for Quantitative Data AnalysisWorkshop nwav 47 - LVS - Tool for Quantitative Data Analysis
Workshop nwav 47 - LVS - Tool for Quantitative Data Analysis
 
Gender Disparity in Employment and Education
Gender Disparity in Employment and EducationGender Disparity in Employment and Education
Gender Disparity in Employment and Education
 
CrashCourse: Python with DataCamp and Jupyter for Beginners
CrashCourse: Python with DataCamp and Jupyter for BeginnersCrashCourse: Python with DataCamp and Jupyter for Beginners
CrashCourse: Python with DataCamp and Jupyter for Beginners
 
Optimizing Data Analysis: Web application with Shiny
Optimizing Data Analysis: Web application with ShinyOptimizing Data Analysis: Web application with Shiny
Optimizing Data Analysis: Web application with Shiny
 
Data Analysis and Visualization: R Workflow
Data Analysis and Visualization: R WorkflowData Analysis and Visualization: R Workflow
Data Analysis and Visualization: R Workflow
 
Reproducible visual analytics of public opioid data
Reproducible visual analytics of public opioid dataReproducible visual analytics of public opioid data
Reproducible visual analytics of public opioid data
 
Building Effective Visualization Shiny WVF
Building Effective Visualization Shiny WVFBuilding Effective Visualization Shiny WVF
Building Effective Visualization Shiny WVF
 
Building Shiny Application Series - Layout and HTML
Building Shiny Application Series - Layout and HTMLBuilding Shiny Application Series - Layout and HTML
Building Shiny Application Series - Layout and HTML
 
Introduction to R - from Rstudio to ggplot
Introduction to R - from Rstudio to ggplotIntroduction to R - from Rstudio to ggplot
Introduction to R - from Rstudio to ggplot
 
Visual Analytics for Linguistics - Day 5 ESSLLI 2017
Visual Analytics for Linguistics - Day 5 ESSLLI 2017Visual Analytics for Linguistics - Day 5 ESSLLI 2017
Visual Analytics for Linguistics - Day 5 ESSLLI 2017
 
Visual Analytics for Linguistics - Day 4 ESSLLI - structured data
Visual Analytics for Linguistics - Day 4 ESSLLI - structured dataVisual Analytics for Linguistics - Day 4 ESSLLI - structured data
Visual Analytics for Linguistics - Day 4 ESSLLI - structured data
 
Visual Analytics for Linguistics - Day 3 ESSLLI
Visual Analytics for Linguistics - Day 3 ESSLLIVisual Analytics for Linguistics - Day 3 ESSLLI
Visual Analytics for Linguistics - Day 3 ESSLLI
 
Visualization Design, Methods and Tools - ESSLLI 2017 Workshop Day 2
Visualization Design, Methods and Tools - ESSLLI 2017 Workshop Day 2Visualization Design, Methods and Tools - ESSLLI 2017 Workshop Day 2
Visualization Design, Methods and Tools - ESSLLI 2017 Workshop Day 2
 
Data Visualization Workshop Day 1 - ESSLLI 2017
Data Visualization Workshop Day 1 - ESSLLI 2017Data Visualization Workshop Day 1 - ESSLLI 2017
Data Visualization Workshop Day 1 - ESSLLI 2017
 
Data Visualization for Literary Analysis
Data Visualization for Literary AnalysisData Visualization for Literary Analysis
Data Visualization for Literary Analysis
 

Recently uploaded

Real-Time AI Streaming - AI Max Princeton
Real-Time AI  Streaming - AI Max PrincetonReal-Time AI  Streaming - AI Max Princeton
Real-Time AI Streaming - AI Max PrincetonTimothy Spann
 
Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...
Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...
Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...Boston Institute of Analytics
 
Digital Marketing Plan, how digital marketing works
Digital Marketing Plan, how digital marketing worksDigital Marketing Plan, how digital marketing works
Digital Marketing Plan, how digital marketing worksdeepakthakur548787
 
Student profile product demonstration on grades, ability, well-being and mind...
Student profile product demonstration on grades, ability, well-being and mind...Student profile product demonstration on grades, ability, well-being and mind...
Student profile product demonstration on grades, ability, well-being and mind...Seán Kennedy
 
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...Boston Institute of Analytics
 
What To Do For World Nature Conservation Day by Slidesgo.pptx
What To Do For World Nature Conservation Day by Slidesgo.pptxWhat To Do For World Nature Conservation Day by Slidesgo.pptx
What To Do For World Nature Conservation Day by Slidesgo.pptxSimranPal17
 
Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...
Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...
Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...Thomas Poetter
 
FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024
FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024
FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024Susanna-Assunta Sansone
 
6 Tips for Interpretable Topic Models _ by Nicha Ruchirawat _ Towards Data Sc...
6 Tips for Interpretable Topic Models _ by Nicha Ruchirawat _ Towards Data Sc...6 Tips for Interpretable Topic Models _ by Nicha Ruchirawat _ Towards Data Sc...
6 Tips for Interpretable Topic Models _ by Nicha Ruchirawat _ Towards Data Sc...Dr Arash Najmaei ( Phd., MBA, BSc)
 
Conf42-LLM_Adding Generative AI to Real-Time Streaming Pipelines
Conf42-LLM_Adding Generative AI to Real-Time Streaming PipelinesConf42-LLM_Adding Generative AI to Real-Time Streaming Pipelines
Conf42-LLM_Adding Generative AI to Real-Time Streaming PipelinesTimothy Spann
 
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...Boston Institute of Analytics
 
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...Amil Baba Dawood bangali
 
Cyber awareness ppt on the recorded data
Cyber awareness ppt on the recorded dataCyber awareness ppt on the recorded data
Cyber awareness ppt on the recorded dataTecnoIncentive
 
wepik-insightful-infographics-a-data-visualization-overview-20240401133220kwr...
wepik-insightful-infographics-a-data-visualization-overview-20240401133220kwr...wepik-insightful-infographics-a-data-visualization-overview-20240401133220kwr...
wepik-insightful-infographics-a-data-visualization-overview-20240401133220kwr...KarteekMane1
 
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default  Presentation : Data Analysis Project PPTPredictive Analysis for Loan Default  Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPTBoston Institute of Analytics
 
Bank Loan Approval Analysis: A Comprehensive Data Analysis Project
Bank Loan Approval Analysis: A Comprehensive Data Analysis ProjectBank Loan Approval Analysis: A Comprehensive Data Analysis Project
Bank Loan Approval Analysis: A Comprehensive Data Analysis ProjectBoston Institute of Analytics
 
convolutional neural network and its applications.pdf
convolutional neural network and its applications.pdfconvolutional neural network and its applications.pdf
convolutional neural network and its applications.pdfSubhamKumar3239
 
Networking Case Study prepared by teacher.pptx
Networking Case Study prepared by teacher.pptxNetworking Case Study prepared by teacher.pptx
Networking Case Study prepared by teacher.pptxHimangsuNath
 
English-8-Q4-W3-Synthesizing-Essential-Information-From-Various-Sources-1.pdf
English-8-Q4-W3-Synthesizing-Essential-Information-From-Various-Sources-1.pdfEnglish-8-Q4-W3-Synthesizing-Essential-Information-From-Various-Sources-1.pdf
English-8-Q4-W3-Synthesizing-Essential-Information-From-Various-Sources-1.pdfblazblazml
 

Recently uploaded (20)

Real-Time AI Streaming - AI Max Princeton
Real-Time AI  Streaming - AI Max PrincetonReal-Time AI  Streaming - AI Max Princeton
Real-Time AI Streaming - AI Max Princeton
 
Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...
Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...
Data Analysis Project Presentation: Unveiling Your Ideal Customer, Bank Custo...
 
Digital Marketing Plan, how digital marketing works
Digital Marketing Plan, how digital marketing worksDigital Marketing Plan, how digital marketing works
Digital Marketing Plan, how digital marketing works
 
Student profile product demonstration on grades, ability, well-being and mind...
Student profile product demonstration on grades, ability, well-being and mind...Student profile product demonstration on grades, ability, well-being and mind...
Student profile product demonstration on grades, ability, well-being and mind...
 
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
Decoding the Heart: Student Presentation on Heart Attack Prediction with Data...
 
What To Do For World Nature Conservation Day by Slidesgo.pptx
What To Do For World Nature Conservation Day by Slidesgo.pptxWhat To Do For World Nature Conservation Day by Slidesgo.pptx
What To Do For World Nature Conservation Day by Slidesgo.pptx
 
Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...
Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...
Minimizing AI Hallucinations/Confabulations and the Path towards AGI with Exa...
 
Data Analysis Project: Stroke Prediction
Data Analysis Project: Stroke PredictionData Analysis Project: Stroke Prediction
Data Analysis Project: Stroke Prediction
 
FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024
FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024
FAIR, FAIRsharing, FAIR Cookbook and ELIXIR - Sansone SA - Boston 2024
 
6 Tips for Interpretable Topic Models _ by Nicha Ruchirawat _ Towards Data Sc...
6 Tips for Interpretable Topic Models _ by Nicha Ruchirawat _ Towards Data Sc...6 Tips for Interpretable Topic Models _ by Nicha Ruchirawat _ Towards Data Sc...
6 Tips for Interpretable Topic Models _ by Nicha Ruchirawat _ Towards Data Sc...
 
Conf42-LLM_Adding Generative AI to Real-Time Streaming Pipelines
Conf42-LLM_Adding Generative AI to Real-Time Streaming PipelinesConf42-LLM_Adding Generative AI to Real-Time Streaming Pipelines
Conf42-LLM_Adding Generative AI to Real-Time Streaming Pipelines
 
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...
 
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
 
Cyber awareness ppt on the recorded data
Cyber awareness ppt on the recorded dataCyber awareness ppt on the recorded data
Cyber awareness ppt on the recorded data
 
wepik-insightful-infographics-a-data-visualization-overview-20240401133220kwr...
wepik-insightful-infographics-a-data-visualization-overview-20240401133220kwr...wepik-insightful-infographics-a-data-visualization-overview-20240401133220kwr...
wepik-insightful-infographics-a-data-visualization-overview-20240401133220kwr...
 
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default  Presentation : Data Analysis Project PPTPredictive Analysis for Loan Default  Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
 
Bank Loan Approval Analysis: A Comprehensive Data Analysis Project
Bank Loan Approval Analysis: A Comprehensive Data Analysis ProjectBank Loan Approval Analysis: A Comprehensive Data Analysis Project
Bank Loan Approval Analysis: A Comprehensive Data Analysis Project
 
convolutional neural network and its applications.pdf
convolutional neural network and its applications.pdfconvolutional neural network and its applications.pdf
convolutional neural network and its applications.pdf
 
Networking Case Study prepared by teacher.pptx
Networking Case Study prepared by teacher.pptxNetworking Case Study prepared by teacher.pptx
Networking Case Study prepared by teacher.pptx
 
English-8-Q4-W3-Synthesizing-Essential-Information-From-Various-Sources-1.pdf
English-8-Q4-W3-Synthesizing-Essential-Information-From-Various-Sources-1.pdfEnglish-8-Q4-W3-Synthesizing-Essential-Information-From-Various-Sources-1.pdf
English-8-Q4-W3-Synthesizing-Essential-Information-From-Various-Sources-1.pdf
 

Data Visualization for Corpus Linguistics: Preliminary Instructions

  • 1. R Studio R Basics Packages Workshop Preliminaries Introduction to R Olga Scrivner 1 / 17
  • 2. R Studio R Basics Packages R software R is a free software for statistical analysis, text mining and graphics. To install R on Window: 1 Download the binary file for R https://cran. r-project.org/bin/windows/base/R-3.3.1-win.exe 2 Open the downloaded .exe file and Install R To install R on Mac: 1 Download the appropriate version of .pkg file https://cran.r-project.org/bin/macosx/ 2 Open the downloaded .pkg file and Install R 2 / 17
  • 3. R Studio R Basics Packages R Studio RStudio is a free user interface for R. 1 Install the appropriate RStudio version https: //www.rstudio.com/products/rstudio/download/ 2 Run it to install R-studio 3 / 17
  • 4. R Studio R Basics Packages R Studio Structure For more details - see handout RStudio101 (by Oscar Torres-Reyna) 4 / 17
  • 5. R Studio R Basics Packages Creating Scripts Create R File: File → New File → R Script Save R File: File → Save - name it (ex. myscript1.r) Close R File: File → Close Open R File: File → Open 5 / 17
  • 7. R Studio R Basics Packages Learning R Syntax Assignment of a value to a variable is done with <- (no space). variable <- value 7 / 17
  • 8. R Studio R Basics Packages Learning R Syntax Assignment of a value to a variable is done with <- (no space). variable <- value NB: Compare this structure to a factor and its values: factor (variable) is a fixed name, while factor values can change. gender <-“m” gender <-“f” 7 / 17
  • 9. R Studio R Basics Packages Strings Strings (characters) are enclosed in quotation marks: mystring <-“This is my string” Numbers are without quotation marks: mynumber <- 5 8 / 17
  • 10. R Studio R Basics Packages Run - Practice To execute your commands you need to click run Open your R file Type mystring <-“This is my string” Keep your cursor on the same line and click run Type print(mystring) Look at your console (bottom left) 9 / 17
  • 11. R Studio R Basics Packages Vector Vector is a sequence of strings (or numbers) vector <- c(“string1”,“string2”,“string3”) vector <- c(1,2,3,4) Practice: Type mywords <-c(“These”, “are”,“my”,“words”) Keep your cursor on the same line and click run Type print(mywords) 10 / 17
  • 12. R Studio R Basics Packages Length Length of string vector - how many elements (words) are in the vector mywords <-c(“These”, “are”,“my”,“words”) 1 How many words in mywords? Type length(mywords) and Run 2 What is the first word in mywords? Type mywords[1] and Run 3 What are the second and third words in mywords? Type mywords[2:3] and Run 11 / 17
  • 13. R Studio R Basics Packages Installing Packages In your bottom left window - go to Packages 12 / 17
  • 14. R Studio R Basics Packages Selecting Packages - Practice 13 / 17
  • 15. R Studio R Basics Packages Package = Library In your Packages window scroll down until you see languageR and click inside the box: 14 / 17
  • 16. R Studio R Basics Packages Package Content To access package description and its content, click on the package name. New window Help will open up: 15 / 17
  • 17. R Studio R Basics Packages Accessing Info from Packages Scroll down and select languageR-package You will see the list of available functions from this package 16 / 17
  • 18. R Studio R Basics Packages Quick Help Type in the console (bottom left): ?length Instead of Run - click enter-key 17 / 17