Beruflich Dokumente
Kultur Dokumente
getwd()
setwd("folder path")
list.files()
print (v)
print(class(v))
#shortcuts
#Data Types
vlogical=TRUE
Vlogical<- TRUE
Vnumeric<- 32.5
# A.2 vectors with more than 1 element : Use c() or create function.
vcharacttermulti2=c("2+4i","2+8i")
vcomplexmulti=c(2+4i,2+8i)
#B LISTS
print(list1)
#or
v2=35L
v3=35
v4="TRUE"
v5=FALSE
# C MATRICES
# D ARRAY
# E FACTORS
> sex <- c("male", "female", "female", "male", "male", "female", "female")
> sex [1] "male" "female" "female" "male" "male" "female" "female"
You can declare these variables to be factor variables for regression analyses:
> sex.factor [1] male female female male male female female
## LOGICAL OPERATOR
vec1= c(1:10)
vec1>3
vec1[vec1>3]
## Variable assignment
##To know all the variables currently available in the workspace we use the ls() function.
##Also the ls() function can use patterns to match the variable names.
print(ls())
print(ls(pattern = "var"))
##The variables starting with dot(.) are hidden, they can be listed using "all.names = TRUE"
print(ls(all.name = TRUE))
##Variables can be deleted by using the rm() function. Below we delete the variable var.3.
##On printing the value of the variable error is thrown.
rm(var.3)
print(var.3)
##When we execute the above code, it produces the following result ???
# [1] "var.3"
#All the variables can be deleted by using the rm() and ls() function together.
rm(list = ls())
print(ls())
## Arithmetic operations
2+2
a=2
b=2
c=a+b
##FUNCTIONS
#1. duplicated() returns dulicates in a array, matrix, vector; return logical answers
vec1=c(1,2,3,4,3,2,3,4)
duplicated(vec1)
MY R2