SlideShare a Scribd company logo
R tutorial for CLIM undergraduate workshop
R tutorial for CLIM undergraduate
workshop
Huang Huang, SAMSI, Oct 23, 2017
About R
R is a free software environment for statistical computing and graphics.
A different implementation of S developed at Bell Lab
Provides a wide variety of statistical and graphical techniques, and is highly extensible
Open source
Powerful IDE: such as Rstudio
Open R
Data types
We can use variables without definition in advance
numbers
num=3.14;
print(num)
## [1] 3.14
print(num+1)
## [1] 4.14
print(typeof(num))
## [1] "double"
num.int=as.integer(num);
print(num.int)
## [1] 3
print(typeof(num.int))
R tutorial for CLIM undergraduate workshop
## [1] "integer"
We can use R as a calculater to calculate
x=2;
print(x*2);
## [1] 4
print(log(x));
## [1] 0.6931472
print(sqrt(x));
## [1] 1.414214
print(x**3);
## [1] 8
array
x=10:12;
print(x);
## [1] 10 11 12
y=c(1,3,5);
print(y);
## [1] 1 3 5
print(y[1])
## [1] 1
matrix=cbind(x,y);
print(matrix);
2 ∗ 2, log(2), ,2
–√ 23
R tutorial for CLIM undergraduate workshop
## x y
## [1,] 10 1
## [2,] 11 3
## [3,] 12 5
Extract a subset of the matrix
print(matrix[2,])
## x y
## 11 3
print(matrix[c(2,3),])
## x y
## [1,] 11 3
## [2,] 12 5
print(matrix[matrix[,1]<12,])
## x y
## [1,] 10 1
## [2,] 11 3
print(matrix[,2])
## [1] 1 3 5
data frame
df=data.frame(x=x,y=y);
print(df)
## x y
## 1 10 1
## 2 11 3
## 3 12 5
print(df$x);
## [1] 10 11 12
print(df$y);
R tutorial for CLIM undergraduate workshop
## [1] 1 3 5
Packages
How to install a package
install.packages('fields')
How to load functions from a package
library('fields')
Basic plots
Use of “plot” function
x=1:1000/10;
y=sin(x);
print(x[1:10]);
## [1] 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
print(y[1:10]);
## [1] 0.09983342 0.19866933 0.29552021 0.38941834 0.47942554 0.56464247
## [7] 0.64421769 0.71735609 0.78332691 0.84147098
plot(x,y)
R tutorial for CLIM undergraduate workshop
plot(x,y,type='l')
plot(x[1:20],y[1:20],type='b',col='red',lwd=5,ylim=c(0,2))
R tutorial for CLIM undergraduate workshop
Use of “hist” function
set.seed(2017)
data=rnorm(1000);
set.panel(1,2);
## plot window will lay out plots in a 1 by 2 matrix
plot(data,type='l');
hist(data)
“help” a function
help(hist)
Use the above command to see the description of function “hist”, and change some parameter(s) to
generate the figure below
R tutorial for CLIM undergraduate workshop
help(quantile)
Calculate the percent quantile, median, and percent quantile as follows.
## 5% 50% 95%
## -1.59585243 0.01210508 1.60853804
Use of “quilt.plot” function
quilt.plot is function in package “fields” to produce an image-like plot
library(fields)
data(ozone2)
plot(ozone2$lon.lat[,1],ozone2$lon.lat[,2],xlab='lon',ylab='lat')
US( add=TRUE, col="grey", lwd=2)
5% 95%
R tutorial for CLIM undergraduate workshop
quilt.plot( ozone2$lon.lat, ozone2$y[16,],xlab='lon',ylab='lat')
US( add=TRUE, col="grey", lwd=2)
R tutorial for CLIM undergraduate workshop
Exercise
Draw the histogram of ozone values at all the sites in the specific time period as before, and get the and
quantiles.
10%
90%

More Related Content

What's hot (20)

R
RR
R
exsuns
 
Data Visualization with R.ggplot2 and its extensions examples.
Data Visualization with R.ggplot2 and its extensions examples.Data Visualization with R.ggplot2 and its extensions examples.
Data Visualization with R.ggplot2 and its extensions examples.
Dr. Volkan OBAN
 
R meets Hadoop
R meets HadoopR meets Hadoop
R meets Hadoop
Hidekazu Tanaka
 
R-ggplot2 package Examples
R-ggplot2 package ExamplesR-ggplot2 package Examples
R-ggplot2 package Examples
Dr. Volkan OBAN
 
RHadoop の紹介
RHadoop の紹介RHadoop の紹介
RHadoop の紹介
Hidekazu Tanaka
 
Experement no 6
Experement no 6Experement no 6
Experement no 6
Smita Batti
 
DSD-INT 2018 Work with iMOD MODFLOW models in Python - Visser Bootsma
DSD-INT 2018 Work with iMOD MODFLOW models in Python - Visser BootsmaDSD-INT 2018 Work with iMOD MODFLOW models in Python - Visser Bootsma
DSD-INT 2018 Work with iMOD MODFLOW models in Python - Visser Bootsma
Deltares
 
Basic Calculus in R.
Basic Calculus in R. Basic Calculus in R.
Basic Calculus in R.
Dr. Volkan OBAN
 
Py lecture5 python plots
Py lecture5 python plotsPy lecture5 python plots
Py lecture5 python plots
Yoshiki Satotani
 
Advanced Data Visualization Examples with R-Part II
Advanced Data Visualization Examples with R-Part IIAdvanced Data Visualization Examples with R-Part II
Advanced Data Visualization Examples with R-Part II
Dr. Volkan OBAN
 
Advanced Data Visualization in R- Somes Examples.
Advanced Data Visualization in R- Somes Examples.Advanced Data Visualization in R- Somes Examples.
Advanced Data Visualization in R- Somes Examples.
Dr. Volkan OBAN
 
Matlab plotting
Matlab plottingMatlab plotting
Matlab plotting
Amr Rashed
 
Coding
CodingCoding
Coding
Prasanta Paul
 
XIX PUG-PE - Pygame game development
XIX PUG-PE - Pygame game developmentXIX PUG-PE - Pygame game development
XIX PUG-PE - Pygame game development
matheuscmpm
 
Prob-Dist-Toll-Forecast-Uncertainty
Prob-Dist-Toll-Forecast-UncertaintyProb-Dist-Toll-Forecast-Uncertainty
Prob-Dist-Toll-Forecast-Uncertainty
Ankoor Bhagat
 
Matlab plotting
Matlab plottingMatlab plotting
Matlab plotting
shahid sultan
 
Geo Spatial Plot using R
Geo Spatial Plot using R Geo Spatial Plot using R
Geo Spatial Plot using R
Rupak Roy
 
Data visualization using the grammar of graphics
Data visualization using the grammar of graphicsData visualization using the grammar of graphics
Data visualization using the grammar of graphics
Rupak Roy
 
Megadata With Python and Hadoop
Megadata With Python and HadoopMegadata With Python and Hadoop
Megadata With Python and Hadoop
ryancox
 
Bar plots.ipynb colaboratory
Bar plots.ipynb   colaboratoryBar plots.ipynb   colaboratory
Bar plots.ipynb colaboratory
Gokuldhev mony
 
Data Visualization with R.ggplot2 and its extensions examples.
Data Visualization with R.ggplot2 and its extensions examples.Data Visualization with R.ggplot2 and its extensions examples.
Data Visualization with R.ggplot2 and its extensions examples.
Dr. Volkan OBAN
 
R-ggplot2 package Examples
R-ggplot2 package ExamplesR-ggplot2 package Examples
R-ggplot2 package Examples
Dr. Volkan OBAN
 
DSD-INT 2018 Work with iMOD MODFLOW models in Python - Visser Bootsma
DSD-INT 2018 Work with iMOD MODFLOW models in Python - Visser BootsmaDSD-INT 2018 Work with iMOD MODFLOW models in Python - Visser Bootsma
DSD-INT 2018 Work with iMOD MODFLOW models in Python - Visser Bootsma
Deltares
 
Advanced Data Visualization Examples with R-Part II
Advanced Data Visualization Examples with R-Part IIAdvanced Data Visualization Examples with R-Part II
Advanced Data Visualization Examples with R-Part II
Dr. Volkan OBAN
 
Advanced Data Visualization in R- Somes Examples.
Advanced Data Visualization in R- Somes Examples.Advanced Data Visualization in R- Somes Examples.
Advanced Data Visualization in R- Somes Examples.
Dr. Volkan OBAN
 
Matlab plotting
Matlab plottingMatlab plotting
Matlab plotting
Amr Rashed
 
XIX PUG-PE - Pygame game development
XIX PUG-PE - Pygame game developmentXIX PUG-PE - Pygame game development
XIX PUG-PE - Pygame game development
matheuscmpm
 
Prob-Dist-Toll-Forecast-Uncertainty
Prob-Dist-Toll-Forecast-UncertaintyProb-Dist-Toll-Forecast-Uncertainty
Prob-Dist-Toll-Forecast-Uncertainty
Ankoor Bhagat
 
Geo Spatial Plot using R
Geo Spatial Plot using R Geo Spatial Plot using R
Geo Spatial Plot using R
Rupak Roy
 
Data visualization using the grammar of graphics
Data visualization using the grammar of graphicsData visualization using the grammar of graphics
Data visualization using the grammar of graphics
Rupak Roy
 
Megadata With Python and Hadoop
Megadata With Python and HadoopMegadata With Python and Hadoop
Megadata With Python and Hadoop
ryancox
 
Bar plots.ipynb colaboratory
Bar plots.ipynb   colaboratoryBar plots.ipynb   colaboratory
Bar plots.ipynb colaboratory
Gokuldhev mony
 

Viewers also liked (20)

CLIM Undergraduate Workshop: Applications in Climate Context - Michael Wehner...
CLIM Undergraduate Workshop: Applications in Climate Context - Michael Wehner...CLIM Undergraduate Workshop: Applications in Climate Context - Michael Wehner...
CLIM Undergraduate Workshop: Applications in Climate Context - Michael Wehner...
The Statistical and Applied Mathematical Sciences Institute
 
CLIM Undergraduate Workshop: Statistical Development and challenges for Paleo...
CLIM Undergraduate Workshop: Statistical Development and challenges for Paleo...CLIM Undergraduate Workshop: Statistical Development and challenges for Paleo...
CLIM Undergraduate Workshop: Statistical Development and challenges for Paleo...
The Statistical and Applied Mathematical Sciences Institute
 
CLIM Undergraduate Workshop: Undergraduate Workshop Introduction - Elvan Ceyh...
CLIM Undergraduate Workshop: Undergraduate Workshop Introduction - Elvan Ceyh...CLIM Undergraduate Workshop: Undergraduate Workshop Introduction - Elvan Ceyh...
CLIM Undergraduate Workshop: Undergraduate Workshop Introduction - Elvan Ceyh...
The Statistical and Applied Mathematical Sciences Institute
 
CLIM Undergraduate Workshop: Introduction to Spatial Data Analysis with R - M...
CLIM Undergraduate Workshop: Introduction to Spatial Data Analysis with R - M...CLIM Undergraduate Workshop: Introduction to Spatial Data Analysis with R - M...
CLIM Undergraduate Workshop: Introduction to Spatial Data Analysis with R - M...
The Statistical and Applied Mathematical Sciences Institute
 
CLIM Undergraduate Workshop: How was this Made?: Making Dirty Data into Somet...
CLIM Undergraduate Workshop: How was this Made?: Making Dirty Data into Somet...CLIM Undergraduate Workshop: How was this Made?: Making Dirty Data into Somet...
CLIM Undergraduate Workshop: How was this Made?: Making Dirty Data into Somet...
The Statistical and Applied Mathematical Sciences Institute
 
CLIM Undergraduate Workshop: Extreme Value Analysis for Climate Research - Wh...
CLIM Undergraduate Workshop: Extreme Value Analysis for Climate Research - Wh...CLIM Undergraduate Workshop: Extreme Value Analysis for Climate Research - Wh...
CLIM Undergraduate Workshop: Extreme Value Analysis for Climate Research - Wh...
The Statistical and Applied Mathematical Sciences Institute
 
Summer Program on Transportation Statistics, Why Highway Crashes Have Recurri...
Summer Program on Transportation Statistics, Why Highway Crashes Have Recurri...Summer Program on Transportation Statistics, Why Highway Crashes Have Recurri...
Summer Program on Transportation Statistics, Why Highway Crashes Have Recurri...
The Statistical and Applied Mathematical Sciences Institute
 
Summer Program on Transportation Statistics, What about the Driver in Driver...
Summer Program on Transportation Statistics, What about the Driver in  Driver...Summer Program on Transportation Statistics, What about the Driver in  Driver...
Summer Program on Transportation Statistics, What about the Driver in Driver...
The Statistical and Applied Mathematical Sciences Institute
 
Summer Program on Transportation Statistics, Statistical Challenges for Advan...
Summer Program on Transportation Statistics, Statistical Challenges for Advan...Summer Program on Transportation Statistics, Statistical Challenges for Advan...
Summer Program on Transportation Statistics, Statistical Challenges for Advan...
The Statistical and Applied Mathematical Sciences Institute
 
Summer Program on Transportation Statistics, Assessing Crash Risk for Highly ...
Summer Program on Transportation Statistics, Assessing Crash Risk for Highly ...Summer Program on Transportation Statistics, Assessing Crash Risk for Highly ...
Summer Program on Transportation Statistics, Assessing Crash Risk for Highly ...
The Statistical and Applied Mathematical Sciences Institute
 
Summer Program on Transportation Statistics, Dynamic Modeling of Transportati...
Summer Program on Transportation Statistics, Dynamic Modeling of Transportati...Summer Program on Transportation Statistics, Dynamic Modeling of Transportati...
Summer Program on Transportation Statistics, Dynamic Modeling of Transportati...
The Statistical and Applied Mathematical Sciences Institute
 
Program on Mathematical and Statistical Methods for Climate and the Earth Sys...
Program on Mathematical and Statistical Methods for Climate and the Earth Sys...Program on Mathematical and Statistical Methods for Climate and the Earth Sys...
Program on Mathematical and Statistical Methods for Climate and the Earth Sys...
The Statistical and Applied Mathematical Sciences Institute
 
Program on Mathematical and Statistical Methods for Climate and the Earth Sys...
Program on Mathematical and Statistical Methods for Climate and the Earth Sys...Program on Mathematical and Statistical Methods for Climate and the Earth Sys...
Program on Mathematical and Statistical Methods for Climate and the Earth Sys...
The Statistical and Applied Mathematical Sciences Institute
 
CLIM Fall 2017 Course: Statistics for Climate Research, Analysis for Climate ...
CLIM Fall 2017 Course: Statistics for Climate Research, Analysis for Climate ...CLIM Fall 2017 Course: Statistics for Climate Research, Analysis for Climate ...
CLIM Fall 2017 Course: Statistics for Climate Research, Analysis for Climate ...
The Statistical and Applied Mathematical Sciences Institute
 
CLIM Fall 2017 Course: Statistics for Climate Research, Detection & Attributi...
CLIM Fall 2017 Course: Statistics for Climate Research, Detection & Attributi...CLIM Fall 2017 Course: Statistics for Climate Research, Detection & Attributi...
CLIM Fall 2017 Course: Statistics for Climate Research, Detection & Attributi...
The Statistical and Applied Mathematical Sciences Institute
 
CLIM Fall 2017 Course: Statistics for Climate Research, Estimating Curves and...
CLIM Fall 2017 Course: Statistics for Climate Research, Estimating Curves and...CLIM Fall 2017 Course: Statistics for Climate Research, Estimating Curves and...
CLIM Fall 2017 Course: Statistics for Climate Research, Estimating Curves and...
The Statistical and Applied Mathematical Sciences Institute
 
Program on Mathematical and Statistical Methods for Climate and the Earth Sys...
Program on Mathematical and Statistical Methods for Climate and the Earth Sys...Program on Mathematical and Statistical Methods for Climate and the Earth Sys...
Program on Mathematical and Statistical Methods for Climate and the Earth Sys...
The Statistical and Applied Mathematical Sciences Institute
 
Program on Mathematical and Statistical Methods for Climate and the Earth Sys...
Program on Mathematical and Statistical Methods for Climate and the Earth Sys...Program on Mathematical and Statistical Methods for Climate and the Earth Sys...
Program on Mathematical and Statistical Methods for Climate and the Earth Sys...
The Statistical and Applied Mathematical Sciences Institute
 
Program on Mathematical and Statistical Methods for Climate and the Earth Sys...
Program on Mathematical and Statistical Methods for Climate and the Earth Sys...Program on Mathematical and Statistical Methods for Climate and the Earth Sys...
Program on Mathematical and Statistical Methods for Climate and the Earth Sys...
The Statistical and Applied Mathematical Sciences Institute
 
CLIM Fall 2017 Course: Statistics for Climate Research, Climate Informatics -...
CLIM Fall 2017 Course: Statistics for Climate Research, Climate Informatics -...CLIM Fall 2017 Course: Statistics for Climate Research, Climate Informatics -...
CLIM Fall 2017 Course: Statistics for Climate Research, Climate Informatics -...
The Statistical and Applied Mathematical Sciences Institute
 

Similar to CLIM Undergraduate Workshop: Tutorial on R Software - Huang Huang, Oct 23, 2017 (20)

QMC: Undergraduate Workshop, Tutorial on 'R' Software - Yawen Guan, Feb 26, 2...
QMC: Undergraduate Workshop, Tutorial on 'R' Software - Yawen Guan, Feb 26, 2...QMC: Undergraduate Workshop, Tutorial on 'R' Software - Yawen Guan, Feb 26, 2...
QMC: Undergraduate Workshop, Tutorial on 'R' Software - Yawen Guan, Feb 26, 2...
The Statistical and Applied Mathematical Sciences Institute
 
Brief introduction to R Lecturenotes1_R .ppt
Brief introduction to R  Lecturenotes1_R .pptBrief introduction to R  Lecturenotes1_R .ppt
Brief introduction to R Lecturenotes1_R .ppt
geethar79
 
R_Language_study_forstudents_R_Material.ppt
R_Language_study_forstudents_R_Material.pptR_Language_study_forstudents_R_Material.ppt
R_Language_study_forstudents_R_Material.ppt
Suresh Babu
 
Lecture1_R Programming Introduction1.ppt
Lecture1_R Programming Introduction1.pptLecture1_R Programming Introduction1.ppt
Lecture1_R Programming Introduction1.ppt
premak23
 
Lecture1_R.ppt
Lecture1_R.pptLecture1_R.ppt
Lecture1_R.ppt
ArchishaKhandareSS20
 
Lecture1 r
Lecture1 rLecture1 r
Lecture1 r
Sandeep242951
 
Lecture1_R.ppt
Lecture1_R.pptLecture1_R.ppt
Lecture1_R.ppt
vikassingh569137
 
Modeling in R Programming Language for Beginers.ppt
Modeling in R Programming Language for Beginers.pptModeling in R Programming Language for Beginers.ppt
Modeling in R Programming Language for Beginers.ppt
anshikagoel52
 
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...
The Statistical and Applied Mathematical Sciences Institute
 
Lecture1_R.pdf
Lecture1_R.pdfLecture1_R.pdf
Lecture1_R.pdf
BusyBird2
 
R-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdfR-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdf
KabilaArun
 
R-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdfR-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdf
attalurilalitha
 
R-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdfR-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdf
DrGSakthiGovindaraju
 
R programming lab 1 - jupyter notebook
R programming lab   1 - jupyter notebookR programming lab   1 - jupyter notebook
R programming lab 1 - jupyter notebook
Ashwini Mathur
 
Python program For O level Practical
Python program For O level Practical Python program For O level Practical
Python program For O level Practical
pavitrakumar18
 
R basics
R basicsR basics
R basics
Sagun Baijal
 
Best corporate-r-programming-training-in-mumbai
Best corporate-r-programming-training-in-mumbaiBest corporate-r-programming-training-in-mumbai
Best corporate-r-programming-training-in-mumbai
Unmesh Baile
 
美洲杯投注-美洲杯投注外围投注-美洲杯投注外围投注平台|【​网址​🎉ac10.net🎉​】
美洲杯投注-美洲杯投注外围投注-美洲杯投注外围投注平台|【​网址​🎉ac10.net🎉​】美洲杯投注-美洲杯投注外围投注-美洲杯投注外围投注平台|【​网址​🎉ac10.net🎉​】
美洲杯投注-美洲杯投注外围投注-美洲杯投注外围投注平台|【​网址​🎉ac10.net🎉​】
ravisconneraa55387
 
C arrays
C arraysC arrays
C arrays
CGC Technical campus,Mohali
 
R for Pythonistas (PyData NYC 2017)
R for Pythonistas (PyData NYC 2017)R for Pythonistas (PyData NYC 2017)
R for Pythonistas (PyData NYC 2017)
Christopher Roach
 
Brief introduction to R Lecturenotes1_R .ppt
Brief introduction to R  Lecturenotes1_R .pptBrief introduction to R  Lecturenotes1_R .ppt
Brief introduction to R Lecturenotes1_R .ppt
geethar79
 
R_Language_study_forstudents_R_Material.ppt
R_Language_study_forstudents_R_Material.pptR_Language_study_forstudents_R_Material.ppt
R_Language_study_forstudents_R_Material.ppt
Suresh Babu
 
Lecture1_R Programming Introduction1.ppt
Lecture1_R Programming Introduction1.pptLecture1_R Programming Introduction1.ppt
Lecture1_R Programming Introduction1.ppt
premak23
 
Modeling in R Programming Language for Beginers.ppt
Modeling in R Programming Language for Beginers.pptModeling in R Programming Language for Beginers.ppt
Modeling in R Programming Language for Beginers.ppt
anshikagoel52
 
Lecture1_R.pdf
Lecture1_R.pdfLecture1_R.pdf
Lecture1_R.pdf
BusyBird2
 
R-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdfR-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdf
KabilaArun
 
R-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdfR-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdf
attalurilalitha
 
R programming lab 1 - jupyter notebook
R programming lab   1 - jupyter notebookR programming lab   1 - jupyter notebook
R programming lab 1 - jupyter notebook
Ashwini Mathur
 
Python program For O level Practical
Python program For O level Practical Python program For O level Practical
Python program For O level Practical
pavitrakumar18
 
Best corporate-r-programming-training-in-mumbai
Best corporate-r-programming-training-in-mumbaiBest corporate-r-programming-training-in-mumbai
Best corporate-r-programming-training-in-mumbai
Unmesh Baile
 
美洲杯投注-美洲杯投注外围投注-美洲杯投注外围投注平台|【​网址​🎉ac10.net🎉​】
美洲杯投注-美洲杯投注外围投注-美洲杯投注外围投注平台|【​网址​🎉ac10.net🎉​】美洲杯投注-美洲杯投注外围投注-美洲杯投注外围投注平台|【​网址​🎉ac10.net🎉​】
美洲杯投注-美洲杯投注外围投注-美洲杯投注外围投注平台|【​网址​🎉ac10.net🎉​】
ravisconneraa55387
 
R for Pythonistas (PyData NYC 2017)
R for Pythonistas (PyData NYC 2017)R for Pythonistas (PyData NYC 2017)
R for Pythonistas (PyData NYC 2017)
Christopher Roach
 

More from The Statistical and Applied Mathematical Sciences Institute (20)

Causal Inference Opening Workshop - Latent Variable Models, Causal Inference,...
Causal Inference Opening Workshop - Latent Variable Models, Causal Inference,...Causal Inference Opening Workshop - Latent Variable Models, Causal Inference,...
Causal Inference Opening Workshop - Latent Variable Models, Causal Inference,...
The Statistical and Applied Mathematical Sciences Institute
 
2019 Fall Series: Special Guest Lecture - 0-1 Phase Transitions in High Dimen...
2019 Fall Series: Special Guest Lecture - 0-1 Phase Transitions in High Dimen...2019 Fall Series: Special Guest Lecture - 0-1 Phase Transitions in High Dimen...
2019 Fall Series: Special Guest Lecture - 0-1 Phase Transitions in High Dimen...
The Statistical and Applied Mathematical Sciences Institute
 
Causal Inference Opening Workshop - Causal Discovery in Neuroimaging Data - F...
Causal Inference Opening Workshop - Causal Discovery in Neuroimaging Data - F...Causal Inference Opening Workshop - Causal Discovery in Neuroimaging Data - F...
Causal Inference Opening Workshop - Causal Discovery in Neuroimaging Data - F...
The Statistical and Applied Mathematical Sciences Institute
 
Causal Inference Opening Workshop - Smooth Extensions to BART for Heterogeneo...
Causal Inference Opening Workshop - Smooth Extensions to BART for Heterogeneo...Causal Inference Opening Workshop - Smooth Extensions to BART for Heterogeneo...
Causal Inference Opening Workshop - Smooth Extensions to BART for Heterogeneo...
The Statistical and Applied Mathematical Sciences Institute
 
Causal Inference Opening Workshop - A Bracketing Relationship between Differe...
Causal Inference Opening Workshop - A Bracketing Relationship between Differe...Causal Inference Opening Workshop - A Bracketing Relationship between Differe...
Causal Inference Opening Workshop - A Bracketing Relationship between Differe...
The Statistical and Applied Mathematical Sciences Institute
 
Causal Inference Opening Workshop - Testing Weak Nulls in Matched Observation...
Causal Inference Opening Workshop - Testing Weak Nulls in Matched Observation...Causal Inference Opening Workshop - Testing Weak Nulls in Matched Observation...
Causal Inference Opening Workshop - Testing Weak Nulls in Matched Observation...
The Statistical and Applied Mathematical Sciences Institute
 
Causal Inference Opening Workshop - Difference-in-differences: more than meet...
Causal Inference Opening Workshop - Difference-in-differences: more than meet...Causal Inference Opening Workshop - Difference-in-differences: more than meet...
Causal Inference Opening Workshop - Difference-in-differences: more than meet...
The Statistical and Applied Mathematical Sciences Institute
 
Causal Inference Opening Workshop - New Statistical Learning Methods for Esti...
Causal Inference Opening Workshop - New Statistical Learning Methods for Esti...Causal Inference Opening Workshop - New Statistical Learning Methods for Esti...
Causal Inference Opening Workshop - New Statistical Learning Methods for Esti...
The Statistical and Applied Mathematical Sciences Institute
 
Causal Inference Opening Workshop - Bipartite Causal Inference with Interfere...
Causal Inference Opening Workshop - Bipartite Causal Inference with Interfere...Causal Inference Opening Workshop - Bipartite Causal Inference with Interfere...
Causal Inference Opening Workshop - Bipartite Causal Inference with Interfere...
The Statistical and Applied Mathematical Sciences Institute
 
Causal Inference Opening Workshop - Bridging the Gap Between Causal Literatur...
Causal Inference Opening Workshop - Bridging the Gap Between Causal Literatur...Causal Inference Opening Workshop - Bridging the Gap Between Causal Literatur...
Causal Inference Opening Workshop - Bridging the Gap Between Causal Literatur...
The Statistical and Applied Mathematical Sciences Institute
 
Causal Inference Opening Workshop - Some Applications of Reinforcement Learni...
Causal Inference Opening Workshop - Some Applications of Reinforcement Learni...Causal Inference Opening Workshop - Some Applications of Reinforcement Learni...
Causal Inference Opening Workshop - Some Applications of Reinforcement Learni...
The Statistical and Applied Mathematical Sciences Institute
 
Causal Inference Opening Workshop - Bracketing Bounds for Differences-in-Diff...
Causal Inference Opening Workshop - Bracketing Bounds for Differences-in-Diff...Causal Inference Opening Workshop - Bracketing Bounds for Differences-in-Diff...
Causal Inference Opening Workshop - Bracketing Bounds for Differences-in-Diff...
The Statistical and Applied Mathematical Sciences Institute
 
Causal Inference Opening Workshop - Assisting the Impact of State Polcies: Br...
Causal Inference Opening Workshop - Assisting the Impact of State Polcies: Br...Causal Inference Opening Workshop - Assisting the Impact of State Polcies: Br...
Causal Inference Opening Workshop - Assisting the Impact of State Polcies: Br...
The Statistical and Applied Mathematical Sciences Institute
 
Causal Inference Opening Workshop - Experimenting in Equilibrium - Stefan Wag...
Causal Inference Opening Workshop - Experimenting in Equilibrium - Stefan Wag...Causal Inference Opening Workshop - Experimenting in Equilibrium - Stefan Wag...
Causal Inference Opening Workshop - Experimenting in Equilibrium - Stefan Wag...
The Statistical and Applied Mathematical Sciences Institute
 
Causal Inference Opening Workshop - Targeted Learning for Causal Inference Ba...
Causal Inference Opening Workshop - Targeted Learning for Causal Inference Ba...Causal Inference Opening Workshop - Targeted Learning for Causal Inference Ba...
Causal Inference Opening Workshop - Targeted Learning for Causal Inference Ba...
The Statistical and Applied Mathematical Sciences Institute
 
Causal Inference Opening Workshop - Bayesian Nonparametric Models for Treatme...
Causal Inference Opening Workshop - Bayesian Nonparametric Models for Treatme...Causal Inference Opening Workshop - Bayesian Nonparametric Models for Treatme...
Causal Inference Opening Workshop - Bayesian Nonparametric Models for Treatme...
The Statistical and Applied Mathematical Sciences Institute
 
2019 Fall Series: Special Guest Lecture - Adversarial Risk Analysis of the Ge...
2019 Fall Series: Special Guest Lecture - Adversarial Risk Analysis of the Ge...2019 Fall Series: Special Guest Lecture - Adversarial Risk Analysis of the Ge...
2019 Fall Series: Special Guest Lecture - Adversarial Risk Analysis of the Ge...
The Statistical and Applied Mathematical Sciences Institute
 
2019 Fall Series: Professional Development, Writing Academic Papers…What Work...
2019 Fall Series: Professional Development, Writing Academic Papers…What Work...2019 Fall Series: Professional Development, Writing Academic Papers…What Work...
2019 Fall Series: Professional Development, Writing Academic Papers…What Work...
The Statistical and Applied Mathematical Sciences Institute
 
2019 GDRR: Blockchain Data Analytics - Machine Learning in/for Blockchain: Fu...
2019 GDRR: Blockchain Data Analytics - Machine Learning in/for Blockchain: Fu...2019 GDRR: Blockchain Data Analytics - Machine Learning in/for Blockchain: Fu...
2019 GDRR: Blockchain Data Analytics - Machine Learning in/for Blockchain: Fu...
The Statistical and Applied Mathematical Sciences Institute
 
2019 GDRR: Blockchain Data Analytics - QuTrack: Model Life Cycle Management f...
2019 GDRR: Blockchain Data Analytics - QuTrack: Model Life Cycle Management f...2019 GDRR: Blockchain Data Analytics - QuTrack: Model Life Cycle Management f...
2019 GDRR: Blockchain Data Analytics - QuTrack: Model Life Cycle Management f...
The Statistical and Applied Mathematical Sciences Institute
 

Recently uploaded (20)

Download Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With LatestDownload Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With Latest
tahirabibi60507
 
The Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdfThe Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdf
drewplanas10
 
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
AxisTechnolabs
 
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
University of Hawai‘i at Mānoa
 
Not So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java WebinarNot So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java Webinar
Tier1 app
 
How can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptxHow can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptx
laravinson24
 
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage DashboardsAdobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
BradBedford3
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Ranjan Baisak
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
F-Secure Freedome VPN 2025 Crack Plus Activation  New VersionF-Secure Freedome VPN 2025 Crack Plus Activation  New Version
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
saimabibi60507
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Dele Amefo
 
Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)
Allon Mureinik
 
Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025
mu394968
 
Download YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full ActivatedDownload YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full Activated
saniamalik72555
 
Douwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License codeDouwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License code
aneelaramzan63
 
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New VersionPixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
saimabibi60507
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
Top 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docxTop 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docx
Portli
 
Download Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With LatestDownload Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With Latest
tahirabibi60507
 
The Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdfThe Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdf
drewplanas10
 
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
AxisTechnolabs
 
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
University of Hawai‘i at Mānoa
 
Not So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java WebinarNot So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java Webinar
Tier1 app
 
How can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptxHow can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptx
laravinson24
 
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage DashboardsAdobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
BradBedford3
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Ranjan Baisak
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
F-Secure Freedome VPN 2025 Crack Plus Activation  New VersionF-Secure Freedome VPN 2025 Crack Plus Activation  New Version
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
saimabibi60507
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Dele Amefo
 
Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)
Allon Mureinik
 
Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025
mu394968
 
Download YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full ActivatedDownload YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full Activated
saniamalik72555
 
Douwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License codeDouwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License code
aneelaramzan63
 
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New VersionPixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
saimabibi60507
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
Top 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docxTop 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docx
Portli
 

CLIM Undergraduate Workshop: Tutorial on R Software - Huang Huang, Oct 23, 2017

  • 1. R tutorial for CLIM undergraduate workshop R tutorial for CLIM undergraduate workshop Huang Huang, SAMSI, Oct 23, 2017 About R R is a free software environment for statistical computing and graphics. A different implementation of S developed at Bell Lab Provides a wide variety of statistical and graphical techniques, and is highly extensible Open source Powerful IDE: such as Rstudio Open R Data types We can use variables without definition in advance numbers num=3.14; print(num) ## [1] 3.14 print(num+1) ## [1] 4.14 print(typeof(num)) ## [1] "double" num.int=as.integer(num); print(num.int) ## [1] 3 print(typeof(num.int))
  • 2. R tutorial for CLIM undergraduate workshop ## [1] "integer" We can use R as a calculater to calculate x=2; print(x*2); ## [1] 4 print(log(x)); ## [1] 0.6931472 print(sqrt(x)); ## [1] 1.414214 print(x**3); ## [1] 8 array x=10:12; print(x); ## [1] 10 11 12 y=c(1,3,5); print(y); ## [1] 1 3 5 print(y[1]) ## [1] 1 matrix=cbind(x,y); print(matrix); 2 ∗ 2, log(2), ,2 –√ 23
  • 3. R tutorial for CLIM undergraduate workshop ## x y ## [1,] 10 1 ## [2,] 11 3 ## [3,] 12 5 Extract a subset of the matrix print(matrix[2,]) ## x y ## 11 3 print(matrix[c(2,3),]) ## x y ## [1,] 11 3 ## [2,] 12 5 print(matrix[matrix[,1]<12,]) ## x y ## [1,] 10 1 ## [2,] 11 3 print(matrix[,2]) ## [1] 1 3 5 data frame df=data.frame(x=x,y=y); print(df) ## x y ## 1 10 1 ## 2 11 3 ## 3 12 5 print(df$x); ## [1] 10 11 12 print(df$y);
  • 4. R tutorial for CLIM undergraduate workshop ## [1] 1 3 5 Packages How to install a package install.packages('fields') How to load functions from a package library('fields') Basic plots Use of “plot” function x=1:1000/10; y=sin(x); print(x[1:10]); ## [1] 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 print(y[1:10]); ## [1] 0.09983342 0.19866933 0.29552021 0.38941834 0.47942554 0.56464247 ## [7] 0.64421769 0.71735609 0.78332691 0.84147098 plot(x,y)
  • 5. R tutorial for CLIM undergraduate workshop plot(x,y,type='l') plot(x[1:20],y[1:20],type='b',col='red',lwd=5,ylim=c(0,2))
  • 6. R tutorial for CLIM undergraduate workshop Use of “hist” function set.seed(2017) data=rnorm(1000); set.panel(1,2); ## plot window will lay out plots in a 1 by 2 matrix plot(data,type='l'); hist(data) “help” a function help(hist) Use the above command to see the description of function “hist”, and change some parameter(s) to generate the figure below
  • 7. R tutorial for CLIM undergraduate workshop help(quantile) Calculate the percent quantile, median, and percent quantile as follows. ## 5% 50% 95% ## -1.59585243 0.01210508 1.60853804 Use of “quilt.plot” function quilt.plot is function in package “fields” to produce an image-like plot library(fields) data(ozone2) plot(ozone2$lon.lat[,1],ozone2$lon.lat[,2],xlab='lon',ylab='lat') US( add=TRUE, col="grey", lwd=2) 5% 95%
  • 8. R tutorial for CLIM undergraduate workshop quilt.plot( ozone2$lon.lat, ozone2$y[16,],xlab='lon',ylab='lat') US( add=TRUE, col="grey", lwd=2)
  • 9. R tutorial for CLIM undergraduate workshop Exercise Draw the histogram of ozone values at all the sites in the specific time period as before, and get the and quantiles. 10% 90%