I have a dataset which is a function of time and frequency. When I melt it I want to retain actual time (date) and frequency values as I want a 2d plot with y axis as frequency and x axis as time.
I tried to retain a column of desired axis values but melting makes it factor and stat_contour throws error. My data is some thing like the following
a = data.frame(date=time,power=power)
names(a) = c('date',period)
where period is
[1] 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
[23] 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
[45] 8 8 8 8 8 8 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16
[67] 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16
[89] 16 16 16 16 16 16 16 16 16 16 16 16 32 32 32 32 32 32 32 32 32 32
[111] 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
[133] 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 64 64 64 64
[155] 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64
[177] 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64
[199] 64 64 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128
[221] 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128
[243] 128 128 128 128 128 128 128 128 256
power = melt(a,id.vars = 'date')
date period power
1 850-01-01 8 0.05106766
2 851-01-01 8 0.05926821
3 852-01-01 8 0.06783015
4 853-01-01 8 0.07681627
5 854-01-01 8 0.08636516
6 855-01-01 8 0.09667054
ggplot(power, aes(x = date, y = period, z = power)) +
stat_contour()
this gives an error as period column is a factor; if I make it numeric I loose the exact Y axis labels. Is there any workaround? thanks