I am taking an online R class in Udemy, here is the code for a Linear regression visualization. I got the error message from the last command. The data from the website about bikesharing: https://www.kaggle.com/c/bike-sharing-demand/data
bike <- read.csv("train.csv")
library(ggplot2)
bike$datetime <- as.POSIXct(bike$datetime)
pl <- ggplot(bike, aes(datetime, count)) + geom_point(aes(color = temp),alpha = 0.5)
pl
print(pl)
pl + scale_color_continuous(low='#55D8CE',high='#FF6E2E') +theme_bw()
cor(bike[,c('temp','count')])
ggplot(bike,aes(factor(season),count)) + geom_boxplot(aes(color=factor(season))) +theme_bw()
bike$hour <- sapply(bike$datetime,function(x){format(x,"%H")})
library(dplyr)
pl <- ggplot(filter(bike,workingday==1),aes(hour,count))
pl <- pl + geom_point()
pl
pl <- pl + scale_color_gradientn(colours = c('dark blue','blue','light blue','light green','yellow','orange','red'))
the pl looks like:
I got the error message from the last command when I was trying to add colors:
Error in if (!alpha || all(lab_in[, 4] == 1)) { :
missing value where TRUE/FALSE needed
I have no idea how to solve the problem, anyone can help? thank you so much.