Hellen Gakuruh
2017-03-06
base R
and RStudio
In this session we get to know a bit about R and Rstudio, like what they are, how they differ and where we can get them.
S
language and started in 1983Ross Ihaka
and Robert Gentleman
and partly to bear similarity with S
base R
.[1]: IDE's
are software's which ease coding process, they include RStudio, and Revolution R.
Integrated Development Environment(IDE)'s
. Some of it's key advantages over base R are:
In this sub-session we discuss and demonstrate how to install and download R and Rstudio.
(live demonstration)
In this sub-session we quickly look at R's tool bar and windows.
Command Line Interface
# simple arithmetric
1 + 1
[1] 2
# Exponential
exp(1)
[1] 2.718282
# Some geometry
2 * pi * (90/360)
[1] 1.570796
# Some trigonometry
cos(90 - 32)
[1] 0.1191801
atan(28/63)
[1] 0.4182243
file > Scripts
edit
then run all/selection, alternatively ctrl_R
Live demonstration on scripting in base R
ls()
)Live demonstration
run
button.Live demo (.R file)
()
mean
(to compute mean), median
(to locate median), and read.table
(to import data)mean
has arguments (x, trim = 0, na.rm = FALSE, …)trim
and na.rm
have default values 0 and FALSE. These can be changed as need be but if okay, don't include in call.x
has no default value hence it must be given.mean(x = data)
it's a named argument call. If it's mean(data)
, then it's unnamed argument call(Live demo)
loaded
with function library
to make them available[2]: R Core Team (2016). R: A language and environment for statistical computation. R Foundation for Statistical Computing, Vienna, Austria. URL https://www.R-project.org/.
getwd()
setwd(dir)
dir
is a path (location) name), it can either be relative or absoluteset("~/Data Mania Inc/Data_Mgt_Analysis_and_Graphics_R")
?function
or help(function)
e.g. ?read.table
or help("read.table")
. Note, later case has to be quoted (“”).help.start()
(no arguments)Search Engine & Keywords
can be handy in locating certain write-upMiscellaneous Materials
, “Frequently Asked Questions is a must read”