R Programming
  • The wikipedia of R by me
  • Hello R
    • -What is R & RStudio
    • -Learning sources
    • -R online editor
    • -R environment
  • Data types
    • -Dealing with Number
    • -Dealing with String
    • -Dealing with Dates
    • -Dealing with NA's
    • -Dealing with Logicals
    • -Dealing with Factors
  • R data
    • -R object
    • -Data structures
      • --Basics
      • --Managing Vectors
      • --Managing Matrices
      • --Managing Data Frames
    • -Functions
    • -Importing/exporting data
    • -Shape&Transform data
    • -R management
  • Visualizations
  • Intro to R Bootcamp
    • -01-introduction
    • -02-data preparation
    • -03-data transformation
    • -04-visualization
  • R programming track
    • -a-Introduction to R
      • --1-Intro to basics
      • --2-Vectors
      • --3-Matrices
      • --4-Factors
      • --5-Data frames
      • --6-Lists
    • -b-Intermediate R
      • --1-Conditionals and Control Flow
      • --2-Loops
      • --3-Functions
      • --4-The apply family
      • --5-Utilities
    • -d-Writing Functions in R
      • --1-A quick refresher
      • --2-When and how you should write a function
      • --3-Functional programming
      • --4-Advanced inputs and outputs
      • --5-Robust functions
  • Data Wrangling with R
  • R-tutor
    • #R introduction
    • #Elementary Statistics with R
  • Hands-On Programming with R
  • R for Data Science
  • Advanced R
  • ggplot2
  • R packages
  • Statistik-1
  • Statistik-2
  • Statistik-3
  • Zeitreihen & Prognosen
  • Descriptive Analytics
  • Predictive Analytics
  • Prescriptive Analytics
  • R Graphics Cookbook
    • ggplot2 intro
    • ggplot2 custome
    • ggplot top-50
  • #Exploratory Data Analysis
    • -Data Summary
    • -Checklist Solution
  • #Data Mining
    • Untitled
    • Untitled
  • #Machine Learning
    • Intro to ML
    • Intro alghorithms
    • 1. Supervised Learning
  • Master R for Data Science
    • Learning R
    • Untitled
    • Untitled
  • Data Science Projects
    • Simple linear regression:
Powered by GitBook
On this page
  1. Intro to R Bootcamp

-01-introduction

PreviousIntro to R BootcampNext-02-data preparation

Last updated 6 years ago

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() 
Module01-Introduction