SlideShare a Scribd company logo
1 of 55
Download to read offline
Dr Nisha Arora
Getting started with R
Contents
2
Download & Install R
Download & install R Studio
Install Packages in R/ R Studio
Set or change working directory
Get help in R
Import & Export data sets
Shortcuts & Tips
References & Resources
Why R?
3
ALGORITHM
4
Word used by programmers whenthey do
notwant to explainwhatthey did!
5
The only programmingJOKE, I know is
my code.
Just like that
6
To download & install R
 https://cran.r-project.org/
 Operating system
 Sub-directory: base
 install R for the first time.
7
8
To download & install R
9
To download & install R
10
To download & install R
11
To download & install R
12
To download & install R
13
To download & install R
14
To download & install R
15
To download & install R
16
To download & install R
17
To download & install R
18
To download & install R
19
To download & install R
20
R GUI
R studio
Includes a console, editor, as well as tools for plotting, history,
debugging and workspace management
R Commander
Enables analysts to access a selection of commonly-used R commands
using a simple interface
Rattle
A data mining toolkit which was designed to analyze large data sets
Deducer
Designed to be a easy to use alternative to proprietary data analysis
software such as SPSS and Minitab
21
Download & install R Studio
 Open the URL: www.rstudio.com
 Click on “Download Rstudio” button.
 Click on "Download RStudio Desktop”.
 Click on the version recommended for your system, or the
latest
 Windows version, and save the executable file.
 Run the .exe file and follow the installation instructions.
22
R packages
Base packages
Which come with R automatically
Contributed packages
Which must be downloaded for installation
To find the list of default base packages loaded at start-up
getOption("defaultPackages")
"datasets" "utils" "grDevices" "graphics" "stats" "methods"
23
To install packages in R
24
To install packages in R Studio
25
To install packages in R Studio
26
To install packages in R Studio
27
To install packages in R Studio
# To see all packages installed
library()
#To see packages currently loaded
search()
#To install a package ‘caret’
install.packages(“caret”, dependencies=TRUE)
#To load a package ‘caret’
library(caret)
#To discover the contents of library package ‘caret’
library(help=caret)
28
Working Directory
29
Working Directory
# To check the current working directory
getwd()
# To set a new working directory
setwd("D:NISHAR CourseraR_programming")
Note: use '' or '/' in the path of directory
# The shortcut (to get/change the current working directory)
"ctr+shift+h“
30
To get help in R
 Click on the 'Help' menu.
 If you want help on a specific command you can enter a search
directly from the keyboard: help(keyword), e.g., help(mean)
 A shortcut is to type: ?keyword
 If you are not sure of the command you can try the following:
apropos("part.word"), e.g., apropos(wd); apropos(“mean")
 To invoke a built-in help browser, you can type: help.start()
Data Sets
31
#To see the list of available data sets in R
data()
#To load an available data sets in R
data(name_of_dataset)
#For example;
data(airquality)
Data Sets
33
Import Data Sets
34
#To import Text data file in R
myTEXTdata = read.table("mydata.txt“, header = TRUE)
Make sure to set your working directory
Import Data Sets
35
#To import CSV data file in R
myCSVdata <- read.table("c:/mydata.csv", header=TRUE,
sep=",", row.names="id")
# note the / instead of  on Windows systems
Or myCSVdata = read.csv("mydata.csv")
Import Data Sets
36
#To import Excel data file in R
# read in the first worksheet from the workbook myexcel.xlsx
# first row contains variable names
library(xlsx)
mydata <- read.xlsx("c:/myexcel.xlsx", 1)
# read in the worksheet named mysheet
mydata <- read.xlsx("c:/myexcel.xlsx", sheetName = "mysheet")
Import Data Sets
37
#To import Excel data file in R
# read in the first worksheet from the workbook myexcel.xlsx
# first row contains variable names
library(readxl)
mydata <- read_excel("c:/myexcel.xlsx", sheet =1)
# read in the worksheet named mysheet
mydata <- read_excel("c:/myexcel.xlsx", sheet = "mysheet")
Import Data Sets
38
To import SPSS data file in R
library(foreign); mySPSSdata <- read.spss("Housing Pricing
Data.sav“)
If SPSS dataset is in trasport format
library(Hmisc); mySPSSdata <- spss.get("c:/mydata.por",
use.value.labels=TRUE)
Import Data Sets
39
#To import SAS data file in R
install.packages("sas7bdat"); library(sas7bdat)
mySASdata <- read.sas7bdat("d1.sas7bdat")
If SAS dataset is in trasport format
library(Hmisc); mySASdata <- sasxport.get("c:/mydata.xpt")
# character variables are converted to R factors
Import Data Sets
40
#To import STATA data file in R
install.packages(“foreign")
library(foreign)
mySTATAdata <- read.dta("D://Learning//Learn
R//R_programming data and codes//sales.dta")
Data Sets
41
Export Data Sets
42
#To export R data file to a tab delimited text file
write.table(mydata, "c:/mydata.txt", sep="t")
Export Data Sets
43
#To export R data file CSV format
write.csv(MyData, file = "MyData.csv")
write.table(MyData, file = "MyData.csv",row.names=FALSE,
na="",col.names=FALSE, sep=",")
Export Data Sets
44
#To export R data file to an Excel spreadsheet
library(xlsx)
write.xlsx(mydata, "c:/mydata.xlsx")
Export Data Sets
45
To export R data file to SPSS
# write out text data file and an SPSS program to read it
library(foreign)
write.foreign(mydata, “D:/mydata.txt",
D:/mydata.sps", package="SPSS")
Export Data Sets
46
#To export R data file to SAS
# write out text datafile and an SAS program to read it
library(foreign)
write.foreign(mydata, "c:/mydata.txt",
"c:/mydata.sas", package="SAS")
Export Data Sets
47
#To export R data file to STATA
# export data frame to Stata binary format
library(foreign)
write.dta(mydata, "c:/mydata.dta")
Helpful Tips
48
#To see the list of key board shortcuts
alt + shift + k
#To save a file
ctr + s
#To run selected piece of code
ctr + r
Short-cuts
49
Edit -> Folding:
Collapse — Alt+L
Expand — Shift+Alt+L
Collapse All — Alt+O
Expand All — Shift+Alt+O
Code:
Insert Section — Ctrl+Shift+R
(Cmd+Shift+R on the Mac)
Jump To — Shift+Alt+J
Short-cuts
https://support.rstudio.com/hc/en-us/articles/200711853-Keyboard-
Shortcuts
50
Description Windows & Linux Mac
Goto File/Function Ctrl+. Ctrl+.
Move cursor to Source Editor Ctrl+1 Ctrl+1
New document (except on
Chrome/Windows)
Ctrl+Shift+N Command+Shift+N
New document (Chrome only) Ctrl+Alt+Shift+N Command+Shift+Alt+N
Open document Ctrl+O Command+O
Save active document Ctrl+S Command+S
Close active document (except
on Chrome)
Ctrl+W Command+W
Goto File/Function Ctrl+. Ctrl+.
51
Get your hands dirty
 R & R Studio
 Install & Load Packages
 Arithmetic in R
 Numbers in R (NAN & NA)
 Import data to R
 Export data from R
 Descriptive Statistics
 Basic Plots
References
52
• Crowley, M. J. (2007). The R Book. Chichester, New
England: John Wiley & Sons, Ltd.
• An Introduction to R by W. N. Venables, D. M. Smith
and the R Core Team
• R in a Nutshell by Joseph Adler: O’Reilly
• Teetor, P. (2011). R cookbook. Sebastopol, CA:
O’Reilly Media Inc.
References
53
http://www.r-bloggers.com/
http://www.inside-r.org/blogs
https://blog.rstudio.org/
http://www.statmethods.net/
http://stats.stackexchange.com
https://www.researchgate.net
https://www.quora.com
https://github.com
References
54
https://rpubs.com/
https://www.datacamp.com/
https://www.dataquest.io/
https://www.codeschool.com/
55
Reach Out to Me
http://stats.stackexchange.com/users/79100/learner
https://www.researchgate.net/profile/Nisha_Arora2/contributions
https://www.quora.com/profile/Nisha-Arora-9
nishaarora4@gmail.com
Thank You

More Related Content

What's hot

RHive tutorials - Basic functions
RHive tutorials - Basic functionsRHive tutorials - Basic functions
RHive tutorials - Basic functionsAiden Seonghak Hong
 
Distrubuted database connection with oracle
Distrubuted database connection with oracleDistrubuted database connection with oracle
Distrubuted database connection with oracleashrafulais
 
Installing Apache Hive, internal and external table, import-export
Installing Apache Hive, internal and external table, import-export Installing Apache Hive, internal and external table, import-export
Installing Apache Hive, internal and external table, import-export Rupak Roy
 
Big Data - In-Memory Index / Sub Second Query engine - Roxie - HPCC Systems
Big Data - In-Memory Index / Sub Second Query engine - Roxie - HPCC SystemsBig Data - In-Memory Index / Sub Second Query engine - Roxie - HPCC Systems
Big Data - In-Memory Index / Sub Second Query engine - Roxie - HPCC SystemsFujio Turner
 
Hive Functions Cheat Sheet
Hive Functions Cheat SheetHive Functions Cheat Sheet
Hive Functions Cheat SheetHortonworks
 
Scoop Job, import and export to RDBMS
Scoop Job, import and export to RDBMSScoop Job, import and export to RDBMS
Scoop Job, import and export to RDBMSRupak Roy
 
Standby db creation commands
Standby db creation commandsStandby db creation commands
Standby db creation commandsPiyush Kumar
 
DHWI Linked Open Data - What I Did
DHWI Linked Open Data - What I DidDHWI Linked Open Data - What I Did
DHWI Linked Open Data - What I DidGeorgina Goodlander
 
Massively Distributed Backups at Facebook Scale - Shlomo Priymak, Facebook - ...
Massively Distributed Backups at Facebook Scale - Shlomo Priymak, Facebook - ...Massively Distributed Backups at Facebook Scale - Shlomo Priymak, Facebook - ...
Massively Distributed Backups at Facebook Scale - Shlomo Priymak, Facebook - ...DevOpsDays Tel Aviv
 
R hive tutorial - apply functions and map reduce
R hive tutorial - apply functions and map reduceR hive tutorial - apply functions and map reduce
R hive tutorial - apply functions and map reduceAiden Seonghak Hong
 
R data-import, data-export
R data-import, data-exportR data-import, data-export
R data-import, data-exportFAO
 
Collections Framework Begineers guide 2
Collections Framework Begineers guide 2Collections Framework Begineers guide 2
Collections Framework Begineers guide 2Kenji HASUNUMA
 

What's hot (15)

RHive tutorials - Basic functions
RHive tutorials - Basic functionsRHive tutorials - Basic functions
RHive tutorials - Basic functions
 
Sql cheat sheet
Sql cheat sheetSql cheat sheet
Sql cheat sheet
 
Perl Programming - 04 Programming Database
Perl Programming - 04 Programming DatabasePerl Programming - 04 Programming Database
Perl Programming - 04 Programming Database
 
Distrubuted database connection with oracle
Distrubuted database connection with oracleDistrubuted database connection with oracle
Distrubuted database connection with oracle
 
Installing Apache Hive, internal and external table, import-export
Installing Apache Hive, internal and external table, import-export Installing Apache Hive, internal and external table, import-export
Installing Apache Hive, internal and external table, import-export
 
Devtools cheatsheet
Devtools cheatsheetDevtools cheatsheet
Devtools cheatsheet
 
Big Data - In-Memory Index / Sub Second Query engine - Roxie - HPCC Systems
Big Data - In-Memory Index / Sub Second Query engine - Roxie - HPCC SystemsBig Data - In-Memory Index / Sub Second Query engine - Roxie - HPCC Systems
Big Data - In-Memory Index / Sub Second Query engine - Roxie - HPCC Systems
 
Hive Functions Cheat Sheet
Hive Functions Cheat SheetHive Functions Cheat Sheet
Hive Functions Cheat Sheet
 
Scoop Job, import and export to RDBMS
Scoop Job, import and export to RDBMSScoop Job, import and export to RDBMS
Scoop Job, import and export to RDBMS
 
Standby db creation commands
Standby db creation commandsStandby db creation commands
Standby db creation commands
 
DHWI Linked Open Data - What I Did
DHWI Linked Open Data - What I DidDHWI Linked Open Data - What I Did
DHWI Linked Open Data - What I Did
 
Massively Distributed Backups at Facebook Scale - Shlomo Priymak, Facebook - ...
Massively Distributed Backups at Facebook Scale - Shlomo Priymak, Facebook - ...Massively Distributed Backups at Facebook Scale - Shlomo Priymak, Facebook - ...
Massively Distributed Backups at Facebook Scale - Shlomo Priymak, Facebook - ...
 
R hive tutorial - apply functions and map reduce
R hive tutorial - apply functions and map reduceR hive tutorial - apply functions and map reduce
R hive tutorial - apply functions and map reduce
 
R data-import, data-export
R data-import, data-exportR data-import, data-export
R data-import, data-export
 
Collections Framework Begineers guide 2
Collections Framework Begineers guide 2Collections Framework Begineers guide 2
Collections Framework Begineers guide 2
 

Similar to 1 Installing & getting started with R

Calling r from sas (msug meeting, feb 17, 2018) revised
Calling r from sas (msug meeting, feb 17, 2018)   revisedCalling r from sas (msug meeting, feb 17, 2018)   revised
Calling r from sas (msug meeting, feb 17, 2018) revisedBarry DeCicco
 
R Introduction
R IntroductionR Introduction
R Introductionschamber
 
RDataMining slides-r-programming
RDataMining slides-r-programmingRDataMining slides-r-programming
RDataMining slides-r-programmingYanchang Zhao
 
Introduction to Data Mining with R and Data Import/Export in R
Introduction to Data Mining with R and Data Import/Export in RIntroduction to Data Mining with R and Data Import/Export in R
Introduction to Data Mining with R and Data Import/Export in RYanchang Zhao
 
Workshop presentation hands on r programming
Workshop presentation hands on r programmingWorkshop presentation hands on r programming
Workshop presentation hands on r programmingNimrita Koul
 
Draft sas and r and sas (may, 2018 asa meeting)
Draft sas and r and sas (may, 2018 asa meeting)Draft sas and r and sas (may, 2018 asa meeting)
Draft sas and r and sas (may, 2018 asa meeting)Barry DeCicco
 
BUSINESS ANALYTICS WITH R SOFTWARE DIAST
BUSINESS ANALYTICS WITH R SOFTWARE DIASTBUSINESS ANALYTICS WITH R SOFTWARE DIAST
BUSINESS ANALYTICS WITH R SOFTWARE DIASTHaritikaChhatwal1
 
Reproducible Computational Research in R
Reproducible Computational Research in RReproducible Computational Research in R
Reproducible Computational Research in RSamuel Bosch
 
R - Get Started I - Sanaitics
R - Get Started I - SanaiticsR - Get Started I - Sanaitics
R - Get Started I - SanaiticsVijith Nair
 
Quantitative Data Analysis using R
Quantitative Data Analysis using RQuantitative Data Analysis using R
Quantitative Data Analysis using RTaddesse Kassahun
 
Language-agnostic data analysis workflows and reproducible research
Language-agnostic data analysis workflows and reproducible researchLanguage-agnostic data analysis workflows and reproducible research
Language-agnostic data analysis workflows and reproducible researchAndrew Lowe
 

Similar to 1 Installing & getting started with R (20)

Devtools cheatsheet
Devtools cheatsheetDevtools cheatsheet
Devtools cheatsheet
 
Aggregate.pptx
Aggregate.pptxAggregate.pptx
Aggregate.pptx
 
Calling r from sas (msug meeting, feb 17, 2018) revised
Calling r from sas (msug meeting, feb 17, 2018)   revisedCalling r from sas (msug meeting, feb 17, 2018)   revised
Calling r from sas (msug meeting, feb 17, 2018) revised
 
R Introduction
R IntroductionR Introduction
R Introduction
 
PMED Undergraduate Workshop - R Tutorial for PMED Undegraduate Workshop - Xi...
PMED Undergraduate Workshop - R Tutorial for PMED Undegraduate Workshop  - Xi...PMED Undergraduate Workshop - R Tutorial for PMED Undegraduate Workshop  - Xi...
PMED Undergraduate Workshop - R Tutorial for PMED Undegraduate Workshop - Xi...
 
R- Introduction
R- IntroductionR- Introduction
R- Introduction
 
Rbootcamp Day 1
Rbootcamp Day 1Rbootcamp Day 1
Rbootcamp Day 1
 
R stata
R stataR stata
R stata
 
RDataMining slides-r-programming
RDataMining slides-r-programmingRDataMining slides-r-programming
RDataMining slides-r-programming
 
Introduction to Data Mining with R and Data Import/Export in R
Introduction to Data Mining with R and Data Import/Export in RIntroduction to Data Mining with R and Data Import/Export in R
Introduction to Data Mining with R and Data Import/Export in R
 
Workshop presentation hands on r programming
Workshop presentation hands on r programmingWorkshop presentation hands on r programming
Workshop presentation hands on r programming
 
Draft sas and r and sas (may, 2018 asa meeting)
Draft sas and r and sas (may, 2018 asa meeting)Draft sas and r and sas (may, 2018 asa meeting)
Draft sas and r and sas (may, 2018 asa meeting)
 
Getting Started with R
Getting Started with RGetting Started with R
Getting Started with R
 
BUSINESS ANALYTICS WITH R SOFTWARE DIAST
BUSINESS ANALYTICS WITH R SOFTWARE DIASTBUSINESS ANALYTICS WITH R SOFTWARE DIAST
BUSINESS ANALYTICS WITH R SOFTWARE DIAST
 
Reproducible Computational Research in R
Reproducible Computational Research in RReproducible Computational Research in R
Reproducible Computational Research in R
 
R - Get Started I - Sanaitics
R - Get Started I - SanaiticsR - Get Started I - Sanaitics
R - Get Started I - Sanaitics
 
Statistical computing 01
Statistical computing 01Statistical computing 01
Statistical computing 01
 
Quantitative Data Analysis using R
Quantitative Data Analysis using RQuantitative Data Analysis using R
Quantitative Data Analysis using R
 
Rmarkdown cheatsheet-2.0
Rmarkdown cheatsheet-2.0Rmarkdown cheatsheet-2.0
Rmarkdown cheatsheet-2.0
 
Language-agnostic data analysis workflows and reproducible research
Language-agnostic data analysis workflows and reproducible researchLanguage-agnostic data analysis workflows and reproducible research
Language-agnostic data analysis workflows and reproducible research
 

Recently uploaded

Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...
Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...
Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...ThinkInnovation
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptxthyngster
 
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfLars Albertsson
 
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...dajasot375
 
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...Suhani Kapoor
 
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPramod Kumar Srivastava
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort servicejennyeacort
 
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...Florian Roscheck
 
9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home Service9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home ServiceSapana Sha
 
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样vhwb25kk
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998YohFuh
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingNeil Barnes
 
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)jennyeacort
 
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptdokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptSonatrach
 
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptx
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptxAmazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptx
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptxAbdelrhman abooda
 

Recently uploaded (20)

Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...
Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...
Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
 
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
 
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdf
 
Decoding Loan Approval: Predictive Modeling in Action
Decoding Loan Approval: Predictive Modeling in ActionDecoding Loan Approval: Predictive Modeling in Action
Decoding Loan Approval: Predictive Modeling in Action
 
E-Commerce Order PredictionShraddha Kamble.pptx
E-Commerce Order PredictionShraddha Kamble.pptxE-Commerce Order PredictionShraddha Kamble.pptx
E-Commerce Order PredictionShraddha Kamble.pptx
 
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
 
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
 
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
 
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
 
9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home Service9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home Service
 
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data Storytelling
 
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
 
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
 
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptdokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
 
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptx
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptxAmazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptx
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptx
 

1 Installing & getting started with R

  • 1. Dr Nisha Arora Getting started with R
  • 2. Contents 2 Download & Install R Download & install R Studio Install Packages in R/ R Studio Set or change working directory Get help in R Import & Export data sets Shortcuts & Tips References & Resources
  • 4. ALGORITHM 4 Word used by programmers whenthey do notwant to explainwhatthey did!
  • 5. 5 The only programmingJOKE, I know is my code. Just like that
  • 6. 6
  • 7. To download & install R  https://cran.r-project.org/  Operating system  Sub-directory: base  install R for the first time. 7
  • 8. 8 To download & install R
  • 9. 9 To download & install R
  • 10. 10 To download & install R
  • 11. 11 To download & install R
  • 12. 12 To download & install R
  • 13. 13 To download & install R
  • 14. 14 To download & install R
  • 15. 15 To download & install R
  • 16. 16 To download & install R
  • 17. 17 To download & install R
  • 18. 18 To download & install R
  • 19. 19 To download & install R
  • 20. 20 R GUI R studio Includes a console, editor, as well as tools for plotting, history, debugging and workspace management R Commander Enables analysts to access a selection of commonly-used R commands using a simple interface Rattle A data mining toolkit which was designed to analyze large data sets Deducer Designed to be a easy to use alternative to proprietary data analysis software such as SPSS and Minitab
  • 21. 21 Download & install R Studio  Open the URL: www.rstudio.com  Click on “Download Rstudio” button.  Click on "Download RStudio Desktop”.  Click on the version recommended for your system, or the latest  Windows version, and save the executable file.  Run the .exe file and follow the installation instructions.
  • 22. 22 R packages Base packages Which come with R automatically Contributed packages Which must be downloaded for installation To find the list of default base packages loaded at start-up getOption("defaultPackages") "datasets" "utils" "grDevices" "graphics" "stats" "methods"
  • 24. 24 To install packages in R Studio
  • 25. 25 To install packages in R Studio
  • 26. 26 To install packages in R Studio
  • 27. 27 To install packages in R Studio # To see all packages installed library() #To see packages currently loaded search() #To install a package ‘caret’ install.packages(“caret”, dependencies=TRUE) #To load a package ‘caret’ library(caret) #To discover the contents of library package ‘caret’ library(help=caret)
  • 29. 29 Working Directory # To check the current working directory getwd() # To set a new working directory setwd("D:NISHAR CourseraR_programming") Note: use '' or '/' in the path of directory # The shortcut (to get/change the current working directory) "ctr+shift+h“
  • 30. 30 To get help in R  Click on the 'Help' menu.  If you want help on a specific command you can enter a search directly from the keyboard: help(keyword), e.g., help(mean)  A shortcut is to type: ?keyword  If you are not sure of the command you can try the following: apropos("part.word"), e.g., apropos(wd); apropos(“mean")  To invoke a built-in help browser, you can type: help.start()
  • 31. Data Sets 31 #To see the list of available data sets in R data() #To load an available data sets in R data(name_of_dataset) #For example; data(airquality)
  • 33. Import Data Sets 34 #To import Text data file in R myTEXTdata = read.table("mydata.txt“, header = TRUE) Make sure to set your working directory
  • 34. Import Data Sets 35 #To import CSV data file in R myCSVdata <- read.table("c:/mydata.csv", header=TRUE, sep=",", row.names="id") # note the / instead of on Windows systems Or myCSVdata = read.csv("mydata.csv")
  • 35. Import Data Sets 36 #To import Excel data file in R # read in the first worksheet from the workbook myexcel.xlsx # first row contains variable names library(xlsx) mydata <- read.xlsx("c:/myexcel.xlsx", 1) # read in the worksheet named mysheet mydata <- read.xlsx("c:/myexcel.xlsx", sheetName = "mysheet")
  • 36. Import Data Sets 37 #To import Excel data file in R # read in the first worksheet from the workbook myexcel.xlsx # first row contains variable names library(readxl) mydata <- read_excel("c:/myexcel.xlsx", sheet =1) # read in the worksheet named mysheet mydata <- read_excel("c:/myexcel.xlsx", sheet = "mysheet")
  • 37. Import Data Sets 38 To import SPSS data file in R library(foreign); mySPSSdata <- read.spss("Housing Pricing Data.sav“) If SPSS dataset is in trasport format library(Hmisc); mySPSSdata <- spss.get("c:/mydata.por", use.value.labels=TRUE)
  • 38. Import Data Sets 39 #To import SAS data file in R install.packages("sas7bdat"); library(sas7bdat) mySASdata <- read.sas7bdat("d1.sas7bdat") If SAS dataset is in trasport format library(Hmisc); mySASdata <- sasxport.get("c:/mydata.xpt") # character variables are converted to R factors
  • 39. Import Data Sets 40 #To import STATA data file in R install.packages(“foreign") library(foreign) mySTATAdata <- read.dta("D://Learning//Learn R//R_programming data and codes//sales.dta")
  • 41. Export Data Sets 42 #To export R data file to a tab delimited text file write.table(mydata, "c:/mydata.txt", sep="t")
  • 42. Export Data Sets 43 #To export R data file CSV format write.csv(MyData, file = "MyData.csv") write.table(MyData, file = "MyData.csv",row.names=FALSE, na="",col.names=FALSE, sep=",")
  • 43. Export Data Sets 44 #To export R data file to an Excel spreadsheet library(xlsx) write.xlsx(mydata, "c:/mydata.xlsx")
  • 44. Export Data Sets 45 To export R data file to SPSS # write out text data file and an SPSS program to read it library(foreign) write.foreign(mydata, “D:/mydata.txt", D:/mydata.sps", package="SPSS")
  • 45. Export Data Sets 46 #To export R data file to SAS # write out text datafile and an SAS program to read it library(foreign) write.foreign(mydata, "c:/mydata.txt", "c:/mydata.sas", package="SAS")
  • 46. Export Data Sets 47 #To export R data file to STATA # export data frame to Stata binary format library(foreign) write.dta(mydata, "c:/mydata.dta")
  • 47. Helpful Tips 48 #To see the list of key board shortcuts alt + shift + k #To save a file ctr + s #To run selected piece of code ctr + r
  • 48. Short-cuts 49 Edit -> Folding: Collapse — Alt+L Expand — Shift+Alt+L Collapse All — Alt+O Expand All — Shift+Alt+O Code: Insert Section — Ctrl+Shift+R (Cmd+Shift+R on the Mac) Jump To — Shift+Alt+J
  • 49. Short-cuts https://support.rstudio.com/hc/en-us/articles/200711853-Keyboard- Shortcuts 50 Description Windows & Linux Mac Goto File/Function Ctrl+. Ctrl+. Move cursor to Source Editor Ctrl+1 Ctrl+1 New document (except on Chrome/Windows) Ctrl+Shift+N Command+Shift+N New document (Chrome only) Ctrl+Alt+Shift+N Command+Shift+Alt+N Open document Ctrl+O Command+O Save active document Ctrl+S Command+S Close active document (except on Chrome) Ctrl+W Command+W Goto File/Function Ctrl+. Ctrl+.
  • 50. 51 Get your hands dirty  R & R Studio  Install & Load Packages  Arithmetic in R  Numbers in R (NAN & NA)  Import data to R  Export data from R  Descriptive Statistics  Basic Plots
  • 51. References 52 • Crowley, M. J. (2007). The R Book. Chichester, New England: John Wiley & Sons, Ltd. • An Introduction to R by W. N. Venables, D. M. Smith and the R Core Team • R in a Nutshell by Joseph Adler: O’Reilly • Teetor, P. (2011). R cookbook. Sebastopol, CA: O’Reilly Media Inc.
  • 54. 55 Reach Out to Me http://stats.stackexchange.com/users/79100/learner https://www.researchgate.net/profile/Nisha_Arora2/contributions https://www.quora.com/profile/Nisha-Arora-9 nishaarora4@gmail.com