Home > Enterprise >  Converting H:M:S character variable to numeric/continuous scale (R)
Converting H:M:S character variable to numeric/continuous scale (R)

Time:05-31

I am interested in visualizing twitter sentiment over a given topic per hour, and my variables are stored as follows:

sapply(valence_hour,class)
      Time          day mean_valence            n 
 "character"    "numeric"    "numeric"    "integer" 

Here is a data example:

Time          day   mean_valence            n 
23:59:00     19     0.0909090909            3
23:58:00     19     0.0589743590            3
23:57:00     19     0.49743590             3

I then ran the following code for a graph:

ggplot(valence_hour, aes(x = Time, y = mean_valence))  
  geom_point()  
  geom_line() 
  scale_x_continuous(breaks=seq(1,30,1))  
  geom_smooth()

However, I keep receiving this error: "Error: Discrete value supplied to continuous scale"

To resolve this issue which I believe is caused by the "Time" variable stored as character, I tried to implement a solution similar to the one enter image description here

  • Related