r - Small multiples line plot -


i trying create small multiples line plot data frame looks this:

time      b   c   d 2013-01-01  69.23580    8.708641    nan 3.452663 2013-02-01  69.46016    8.353662    nan 4.601604 2013-03-01  69.62315    9.156498    nan 3.953704 2013-04-01  71.04144    7.817074    nan 3.762032 2013-05-01  74.29557    7.971487    nan 4.475369 

i ideally want 4 plots on single graph showing line plots each of variables in data frame. using following code (after melting data frame) gives me weird results.

q <- ggplot(data=temp) +    geom_line(aes(x=time, y=value, color=variable), size = 1) +    facet_grid(variable~value) +   xlab("time") 

any in regard appreciated.

i don't know if think using facet_wrap function.

and scales argument change scale since fixed default option.

should scales fixed ("fixed", default), free ("free"), or free in 1 dimension ("free_x", "free_y")

data_text <- " time      b   c   d 2013-01-01  69.23580    8.708641    nan 3.452663 2013-02-01  69.46016    8.353662    nan 4.601604 2013-03-01  69.62315    9.156498    nan 3.953704 2013-04-01  71.04144    7.817074    nan 3.762032 2013-05-01  74.29557    7.971487    nan 4.475369 " temp <- read.table(text=data_text, header=true, stringsasfactors=false) library(reshape2)  temp <- melt(temp, id.vars=c("time")) temp$time <- as.date(temp$time) library(ggplot2)  library(plyr) temp <- subset(temp, value > 0) q2 <- ggplot(data=temp) + geom_line(aes(x=time, y=value, color=variable), size = 1) + facet_wrap(~ variable, scales = "free_y")  q2  

enter image description here


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -