-R environment

#R vs RStudio

Term:

-Graphical User Interface (GUI): User Interface or a simple term anything that you can see on your computer

-Integrated Development Environment (IDE): A software application to write a computer programm

Introduction to R: R is a language and environment for statistical computing and graphics

The R environment (R-IDE) has some of features, it includes:

  • Input and output , loops function, rekursive

  • Create an analytical graph

  • Operators in different data object such as matrices, data frame, etc

  • Storage facility

  • Data handling

  • Simple GUI

  • Saving graph as pdf

Introduction to R-Studio: R-Studio is open-source IDE for R and has better GUI to connect with R

#RStudio User Interface

RStudio has 4 layer of GUI

#RStudio support

RStudio built in "Help"

?mean()         # help about function mean()
help(mean)      # another help syntax about function mean()
help.start()    # go to manuals help (built in help system)
example(mean)   # show an example of function mean()
apropos("mean") # show all functions containing at least string "mean()"

#R directories

R directories is the current workspace working directory in our computer- or the address of our folder for save the R objects

getwd() #get the current working director
setwd(mydirectory) #setting the directory, use / in windows

Or use the RStudio GUI : Session pane->Set Working Directory->Choose Directory

#R packages

Packages are collections of R code. The directory where packages are stored is called the library

Available Packages:

Setting the library:

library()    # to know all packages 
installed search()     # to see packages currently loaded
.libPaths()  # get library path (location)

Installing additional Packages:

install.packages("nameofpackages") #install
library(nameofpackages) #or    #using the packages in RStudio
require(nameofpackages)        #same with library()

Creating Your Own Packages:

#R input/output

Input from the current working directory:

# input a file 
source("myfile")

Reusing output results:

The R output can easily be saved and used as input

x<-200 #save x which has value 
200y<-x+1000 #x as input for yxy

#R extra environment:

-Build interactive web apps straight from R: https://shiny.rstudio.com/​

-Build interactive document straight from R: https://rmarkdown.rstudio.com/index.html​

-The bookdown package is a free and open-source R package built on top of R Markdown to make it really easy to write books and long-form articles/reports.:

- R Markdown thesis template using the bookdown package: https://github.com/ismayc/thesisdown​

Last updated