ECON 6306 Lecture Notes - Lecture 2: Scatter Plot, Rstudio
![](https://new-preview-html.oneclass.com/06gDVlA8qeMwNreGd6X2j3W524oxrnBz/bg1.png)
Installing and Working with R
There are two versions of R that can be installed. Originally, R was distributed under CRAN but recently Microsoft also
releases R under the MRAN repository. Downloading from MRAN has the advantage of somewhat faster processing in
functions where matrix algebra is involved through multi core processing. It is suggested to download it from MRAN,
install it and then install R-Studio for a nice graphical interface.
When you open R-Studio, press ctrl-shift- ad you’ll get the folloig sree. 1 is here you’ll rite all your ode ad
scripts. You can save this file anywhere and anytime. 2 is where the output and error/warning messages will be shown. 3
is your environment where all of your datasets or values are shown. You can use any of the data appearing here in your
ode. 4 has a fe helpful tas. files gies you aess to all files o your oputer. plots ta shos ay harts or
graphis you ake. Help ta gies iforatio aout ay futio or pakage he you press f1. Pakages shos
the libraries that are available to install and/or load.
Basic functions
These snippets are meant to be written in the script file. Any line starting with # is not interpreted as code. It is called
commenting out the code
install.packages("AER") #will install a package named AER
library(AER) #will load the package into your current session so you can use any functions in the library
my.pi <- 3.14 # will save a variable my.pi equals to 3.14 in your workspace. <- is the assignment operator in R. You can
also use = for assignment but most people use <-. If you type my.pi in a new line and press ctrl+enter, it will give you the
value of my.pi in the output. Ctrl+ enter is the shortcut for running one line of code or a selection of code. If you want to
run your entire code, you can press ctrl+ shift+enter
ls() # will give all datasets or values currently in your workspace
rm(my.pi) # will remove my.pi
find more resources at oneclass.com
find more resources at oneclass.com
Document Summary
There are two versions of r that can be installed. Originally, r was distributed under cran but recently microsoft also releases r under the mran repository. Downloading from mran has the advantage of somewhat faster processing in functions where matrix algebra is involved through multi core processing. It is suggested to download it from mran, install it and then install r-studio for a nice graphical interface. When you open r-studio, press ctrl-shift-(cid:374) a(cid:374)d you"ll get the follo(cid:449)i(cid:374)g s(cid:272)ree(cid:374). 1 is (cid:449)here you"ll (cid:449)rite all your (cid:272)ode a(cid:374)d scripts. You can save this file anywhere and anytime. 2 is where the output and error/warning messages will be shown. 3 is your environment where all of your datasets or values are shown. You can use any of the data appearing here in your (cid:272)ode. These snippets are meant to be written in the script file. Any line starting with # is not interpreted as code.