vector1 <- c(1,2,3,4,5)
vector2 <- c(6,7,8,9,10)
vector3 <- c("hello", "goodbye", "hi", "bye", "hey")
combine.columns <- cbind(vector1, vector2, vector3)
new.data.frame <- as.data.frame(combine.columns)
new.data.frame$ones <- 1
vector4 <- c(26, 39, 12, 5, 14)
new.data.frame$vector4 <- vector4
colnames(new.data.frame) <- c("col1", "col2", "col3", "col4", "col5")
new.data.frame
#---------------------------------------------------------------
Now we would like to visualize our data
to do this, we can use "Base R" which are the functions
that come automatically with R, or we can use other packages
first we will use Base R to make a bar plot
barplot(new.data.frame$col5) # make a simple barplot of col5 values
what about col3 (x) and col5 (y), for this we use "~"
barplot(new.data.frame$col5 ~ new.data.frame$col3)
lets give it a title and change the x and y labels
barplot(new.data.frame$col5 ~ new.data.frame$col3,
main = "this is the plot title",
xlab = "this is the x-label",
ylab = "this is the y-label")
one of our bars seems to be extending over the y limitation
lets change the y limitation to 50 instead
barplot(new.data.frame$col5 ~ new.data.frame$col3,
main = "this is the plot title",
xlab = "this is the x-label",
ylab = "this is the y-label",
ylim = c(0,50))
#now lets use a simple plot function to see what it does
plot(new.data.frame$col5 ~ new.data.frame$col3,
main = "this is the plot title",
xlab = "this is the x-label",
ylab = "this is the y-label",
ylim = c(0,50))