The common R data types for research are numeric, factor, and character.
a <- c(-1, -3, 0, 5, 7, 8, 4, 6.3, 10)
"<-" is the assignment operator.
"c()" function combines values into a vector or list.
We can get help about functions by using the question mark followed by the name of the function, for example:
drink_vector <- (c('milk', 'water', 'juice')) drink_vector #  "milk" "water" "juice" drink_factor <- factor(drink_vector) drink_factor #  milk water juice # Levels: juice milk water
d<-c('Hellow world', 'R is fun!') d #  "Hellow world" "R is fun!"
Create a dataframe:
a <- c(1, 3, 5, 7) b <- c(2, 4, 6, 8) df<-data.frame(a, b) df
Add a column with the $ operator:
df$new_column <- c(1, 2, 3, 4) df
Add a column with the cbind function:
df <- cbind(df, new_new_column = c('a', 'b', 'c', 'd')) df
View the dataframe as a table in RStudio:
Get the names of the dataframe:
Display the structure of the dataframe:
If you enjoy the content, please consider subscribing to my YouTube channel for future updates.
To access video tutorials and receive a certificate, enroll in my Udemy course.
Did you find this article valuable?
Support Azad Rasul by becoming a sponsor. Any amount is appreciated!