R Installation
The latest version of R can be downloaded from
http://cran.r-project.org/bin/windows/base/
You
will be asked whether you want to save or run a file “R-3.2.0-win.exe”. Choose
“Save” and save the file on the Desktop. Then double-click on the icon for the
file to run it and install R.
RStudio
RStudio is the Integrated Development Environment
for R. It comes in two varieties namely:
a) RStudio Desktop: RStudio Desktop is a standalone
desktop application. It can be downloaded from the following link: http://www.rstudio.com/products/rstudio/download/.
b) RStudio Server: It is a Linux server application
that provides a web browser based interface to the version of R running on the
server. It is necessary for:
- Computations that require larger CPU utilization
- Efficient utilization of resources
- Usage of standardized R package versions
Installing R packages
Choose Install Packages from the
Packages menu in Rstudio.
Select a CRAN mirror.
Choose the package.
Use library (package) function to
load it for use.
Getting Help
R has built in help system. The
following commands can be used to access it:
help.start() # for general help
help(mean) # help about the function mean
?mean
apropos("str") # lists all functions
containing the string “str”
example(mean) # shows an example of mean
()
vignette(“mean”) #Show vignette for mean
Key Objects
R mainly supports two types of
objects:
Basic Objects
Important basic objects are:
- Atomic Vector: All the elements of an atomic vector should be of the same type. Based on the type of values it contains atomic vector can be differentiated into three types namely numeric vector, logical vector and character vector.
- List: Lists can have atomic vectors or other lists as components.
Derived Objects
Following are the derived objects
in R:
- Matrix: All elements of the matrix should be of the same type.
- Data frame: It can have different data types in different columns.
- Factors: Factors contain categorical data.
Data Import and Export
R can read different types of
files e.g. plain text files, databases, Excel files, XML, HTML files, SPSS, SAS
and Stata formatted data. The data in R can be exported in all these formats.
Developing Web applications in R
Shiny is a powerful framework
used for building interactive web applications using R. A Shiny application is
defined by two files namely ui.R and server.R. The file ui.R contains the
definition of the application interface and server.R contains the code for the
computation.