-01-introduction
Link to the module:
mtcars
?sum
hist(mtcars$mpg)
avg_mpg <- mean(mtcars$mpg)
avg_mpg
random_numbers <-runif(25)
random_numbers
history()
# provides details for specific function
help(sqrt)
# provides same information as
help(functionname)
?sqrt
# provides examples for said function
example(sqrt)
example(sum)
# get your current working directory
getwd()
# set your working directory
#setwd("C:/Users/cevi herdian/Documents/MEGA/Data-Sciences/R Programming
#/uc-github.io/Intro to R Bootcamp/Module 01")
# Uses PEMDAS convention for order of operations
4 + 3 / 10 ^ 2
4 + (3 / 10 ^ 2)
(4 + 3) / 10 ^ 2
1 / 17 ^ 7
1 / 0
Inf - Inf
#THE ASSIGNMENT (<-) OPERATOR
x <- 3 # GOOD
x = 3 # BAD
# we can increment (build onto) existing objects
rm(list=ls())
x <- x + 1
x
D <- 1000
K <- 5
h <- .25
Q <- sqrt((2 * D * K) / h)
Q
# list all objects ls()
ls()
# remove defined object from the environment
rm(D)
# removes everything in the working environment --
# use with caution!
rm(list = ls())
#PACKAGES
#CRAN: 10,000+
#Bioconductor: 1,000+
#GitHub: Many more plus beta versions for updated
#packages not yet published
#So how do we install these packages?
# install packages from CRAN
#install.packages("packagename")
# install packages from Bioconductor
# only required the first time biocLite()
#source("http://bioconductor.org/biocLite.R")
# only required the first time
#biocLite("packagename")
# install packages from GitHub
#install.packages("devtools") # only required the first time
#devtools::install_github("username/packagename")
#YOUR TURN!
#Download these packages from CRAN: tidyverse nycflights13
install.packages("tidyverse")
install.packages("nycflights13")
# alternative install.packages(c(“tidyverse”, “nycflights13”))
#PACKAGES:
#Loading packages:
# load the package to use in the current R session
library(tidyverse)
# use a particular function within a package without loading the package
stringr::str_replace()
#Getting help on packages:
# provides details regarding contents of a package
help(package = "tidyr")
# list vignettes available for a specific package
vignette(package = "tidyr")
# view specific
#vignette is an R jargon for documentation
#vignette(tidy-data)--->XXXXX??
#######FUNCTIONS TO REMEMBER
#help(), ?, example()
Last updated