You are on page 1of 2

# GETTING SESSION INFORMATION ========================

sessionInfo()

install.packages("ggplot2") # TO install packages # download packages from CRAN


and install in R
library("ggplot2") # make package available ; often used for loading in
scripts
require("ggplot2") # prefered for loading in functions; may be better

help("function") # developing your own functionalities # remember quoting!


help(names)

print("My First Program") # Prints data in console

paste("Hi I am", "ducat")


paste0("Hi I am", " ducat")

# Sequences
1:17
seq(0, 1, length.out = 5)
seq(1, 9, by = 2)
seq(1, 8, by = 2)
seq(9, 1, by = -2)
seq(17)

rep(1:4, 2)
rep(1:4, each = 3)
rep(1:4, c(2, 1, 2,3))
rep(1:4, each = 2, len = 15)

rep(1:4, each = 2, times = 3)

data()

# Viewing data set


mtcars # Total data set in console
View(mtcars) # Viewing dataset in spreadsheet
head(mtcars,10) # Viewing top-10 observations (default: top-6)
tail(mtcars) # Viewing bottom 10 observations
str(mtcars) # Viewing data dictionary
summary(mtcars)

names(mtcars) # Viewing column names

v1 = mtcars$disp
newvar <- mtcars$disp + mtcars$hp
v1 <- mtcars$mpg # Assigning single variable from mtcars data to v1
v2 <- mtcars$cyl
v3 <- mtcars$disp
v4 <- mtcars$hp

mtcars1<-rbind(v1,v2,v3,v4) # Combined as rows #Horizontal joins


mtcars2<-cbind(v1,v2,v3,v4) # Combined as columns # Vertical joins

#import dataset

stores <- read.csv("C:/Users/dell/Desktop/SASUniversityEdition/myfolders/DataSets


for R sessions/stores.csv")
summary(stores)

#export dataset

You might also like