var = dataframe
str(var)
get data structure of dataframe
head(var, n=x)
get the first x data (x default 6)
tail(var, n=x)
get the last x data (x default 6)
table(tblx$colName)
get the freq of dataframe from categorical column
min(tblx$colName)
get the min value of the column
max(tblx$colName)
get the max value of the column
mean(tblx$colName)
get the mean value of the column
range(tblx$colName)
get the min-max value of the column
if
if(tblx$ColumnName[1]>4) {
print("do something")
}
if-else
if(tblx$ColumnName[1] > someVal) {
print("do something")
} else {
print("do something else")
}
for loop
vec <- c(1:5)
do something to each in vec
for (i in vec) {
print(i + 5)
}
while loop
i=1 #define i
while(i<10) { # break when i < 10
print(i+5)
i=i+1
}
basically user can have function to do certain task, using function()
adding5 <- function(x) {
return(x + 5)
}
something <- adding5(30)