S

@Serah_J

6. Objects, Data and Basic Operators /# 6.2 Object Types in R

R
4 years ago
#1) Variable - object with single value -> x=3, y=b+c where b=2.5 and c= 2.3 #2) Vector - is a collection of elements of the same data type. #- Allows operations to be performed on every element. #Example : {1,2,3}, {"Jecy","Bethany", "Alison"}, {10.4,7.8,1.1} #- You can have vector of many data types #3) Sequene - is a vector made of numbers #- Has a fixed pattern

6. Objects, Data and Basic Operators /# 6.1 Data Types in R

R
4 years ago
# Double- no.s with decimal - 1.3, -8.5, 3.0 # Complex - square root of a negative no. - -2-i, 3.4+23.li #Logical- Has two values 0 or 1, produced as a result of logical test #Date and Time - can take multiple formats #Character -"This is a car", "42" #Check data type of an object # typeof()

5. Installing Packages

R
4 years ago
# Library() is used to load a package to the current R session #use library({package})at command line #Example- library("MASS") library() #Listing loaded packages #search() can be used to list all the loaded packages search ()

Miscellaneous

R
5 years ago
x=25 Y <- 2*4 A <-3 d <- 3+4 Z =4 c <- 2>3 |3 >2 # used to list objects in the current working environment objects()

Logical Operators

R
5 years ago
# ==Equals x <- 2==3 x # != Not equals to y <- 2!=3 y # < Less than z <- 5<7

Arithmetic Operations

R
5 years ago
#Addition a <- 3+4 a #Subtraction b <- 2-9 b #Multiplication c <- 5*12

Basic Commands

R
5 years ago
#Assignment rules x <-5 x y=6 y 7-> z z