I am MSc student studying honeybees and new to R. I have data of 2 temperature and humidity sensors from inside a beehive and would like to plot them on the same graph with two y scales, one for temperature and one for relative humidity.
Data:
time DHT22_t DHT11_t DHT22_h DHT11_h
1 10/5/2014 12:52 15.7 17 77.0 83
2 10/5/2014 13:52 16.7 18 71.6 81
3 10/5/2014 14:51 15.7 18 79.0 81
4 10/5/2014 15:51 15.8 18 77.0 81
5 10/5/2014 16:51 16.0 18 77.0 81
6 10/5/2014 17:50 14.3 17 80.2 81
I used melt to rearrange data w/ respect to time:
meltdf <- melt(Hive1_4days,id="time")
time variable value
1 10/5/2014 12:52 DHT22_t 15.7
2 10/5/2014 13:52 DHT22_t 16.7
3 10/5/2014 14:51 DHT22_t 15.7
4 10/5/2014 15:51 DHT22_t 15.8
5 10/5/2014 16:51 DHT22_t 16.0
6 10/5/2014 17:50 DHT22_t 14.3
using ggplot:
ggplot(meltdf,aes(x=time,y=value,colour=variable,group=variable)) + geom_line()
Instead of this, I would like to have a humidity scale on the right. Also, The x-axis is saturated with dates (the sensors logged data ~18 times per minute) and I would like to change the scale to every few hours or half day or something. Any ideas? Thanks!
EDIT:
pizza<- ggplot(meltdf,aes(x=time,y=value,colour=variable,group=variable)) + geom_line()
pizza+scale_x_date(breaks=date_breaks("1 days"))
produces this:
Which does not help. Is there a way to change the axis w/o affecting the plot?