Getting started with R and R Commander -...
Transcript of Getting started with R and R Commander -...
Getting started with R and R Commander
Getting started with R and R Commander
Contents
I Starting R
I Changing language to English in RI Loading R Commander (and other packages)
I Loading data in R CommanderI From a fileI From R librariesI Creating data in R/ R CommanderI Creating data in R Commander
I Installing R
I Installing packages in R
Starting RI Go to the Start menu (bottom left corner)I Then to Programs, look for RI Click on the thick blue R 2...I R uses the language from the windows version of your
computer.I It is possible to change language (apart from English) to
German, French, Italian... Right click the shortcut icon in thedesktop. Type, e.g., Language=it after the texts in Targetfield. Apply and restart R.
Changing language to English in RI Go to Edit menu, then GUI preferences...
Changing language to English in RI Type english in the top right field and hit OK
Loading R Commander - first methodI From the top menu, choose Packages and Load package...
Loading R Commander - first method cont.I From the drop-down menu, choose Rcmdr
Loading R Commander - second method
I Type in the R Console window library(Rcmdr) and hit OK
Main window of R Commander
Main window of R Commander
R CommanderI If you accidently close the Rcmdr window, type Commander()
in the R Console and hit OK
Loading data in R Commander - from a fileI We want to load Nations.txt located in ...I C:/Program Files/R/R-2.13.1/library/Rcmdr/etc/ ...I And call it mydata
Loading data in R Commander - from a file cont.
Loading data in R Commander - from a file cont.I Starting from C:, follow the path till you get to the file
Loading data in R Commander - from a file cont.I mydata automatically becomes your active Data set and you
can view its contents by clicking on the View data set
Loading data in R Commander - from R librariesI You can load data from any package of R:
Loading data in R Commander - from R libraries cont.I Remember to double-click!
Loading data in R Commander - from R libraries cont.
I In Active data set, you can Select/Refresh, etc and Getvariable names
I In Manage variables in active data set, Recode, etc
Creating data in R/ R Commander
I We want to create three vectors X: 11,12,13,16,16,17,18,21,Y: 14,15,15,15,16,16,16,17, Z: 11,11,11,12,19,20,20,20
I And then merge them together as one data set, one vector percolumn
I Type in the Script Window, highlight everything, press Submit
x = c(11,12,13,16,16,17,18,21)
y = c(14,15,15,15,16,16,16,17)
z = c(11,11,11,12,19,20,20,20)
data.xyz = data.frame(x,y,z)
data.xyz
Creating data in R Commander (not recommended)I Often crashes the programme
Creating data: Alternatives
Type in the Script Window, highlight everything, press Submit:
I Data <- edit(as.data.frame(NULL))
I Alternatively: x = scan()
Introduce values. When finishing, press Intro twice.
Installing RI Go to CRAN website http://cran.r-project.org/
Installing RI Choose the platform, eg, Windows
Installing RI Choose the base
Installing RI Click on Download... and ...I save the .exe file on your machine/external hard-driveI You can get to the .exe file faster by simply typing
http://cran.es.r-project.org/bin/windows/base/R-2.13.1-win32.exe in your browser
Installing R
I Double click on the saved file and ...I Follow the installation steps
I You can install R on an external hard-drive (you need around150MB of space), thus not necessarily on your laptop/desktop
I Set the language to Spanish/English
Installing packages in RI From the top menu, choose Packages and Install package(s)...
Installing packages in RI Select CRAN mirror (place from which you will download
packages), eg, from Lyon in France
Installing packages in RI From the drop-down list, select the packages (press CTRL and
hold it, whilst clicking with the mouse button on severalpackages)
I Useful packages: agricolae, Rcmdr, Rcmdr.TeachingDemos,lattice, Deducer
References and additional reading material aboutRCommander
I ”The R Commander: A Basic-Statistics Graphical UserInterface to R”. John Fox Journal of Statistical Software2005, Volume 14, Issue 9.
I cran.r-project.org/doc/contrib/Karp-Rcommander-intro.pdf