Reputation: 11
I am trying to plot the data using the ggplot2 package, but I am crossing with an error: the data are set of columns which represents every day values (the values change in altitude)
V1 V2.... V500
2E-15.....3E-14
3e-14.....3E-21
1.3E-15....NA
I want to plot all the data in two axis with a fill of the values.
Code;
a<-data.frame("/../vertical_value.csv",sep=",",header=F)
am<-melt(t(a))
dataset<-expand.grid(X = 1:500, H = seq(1,25,by=1))
dataset$axp<-am$value
g<-ggplot(dataset, aes(x = X, y = H, fill = axp)) + geom_tile()
error:
Error: Casting formula contains variables not found in molten data: XHaxp
Upvotes: 1
Views: 514
Reputation: 44688
Looking at this again, I think that you should be able to bypass this just by dropping NA rows after you melt.
a<-data.frame("/../vertical_value.csv",sep=",",header=F)
am<-melt(t(a))
am <- na.omit(am) ## ADD THIS LINE
dataset<-expand.grid(X = 1:500, H = seq(1,25,by=1))
dataset$axp<-am$value
g<-ggplot(dataset, aes(x = X, y = H, fill = axp)) + geom_tile()
Upvotes: 1