Monday 19 August 2013

Visualize the amount of two factors

Visualize the amount of two factors

In the following example I want to give a overview for all factors in all
levels during the time. To give a overview for one factor I could do this:
times<-tim.seq<-seq(as.POSIXlt("2013-07-01 00:00:00",origin =
"1960-01-01",tz="GMT"),
as.POSIXlt("2013-07-8 00:00:00",origin =
"1960-01-01",tz="GMT"),by="1 hour")
key<-factor(sample(LETTERS[1:2],2*length(times),T,prob=c(0.4,0.6)))
ref<-factor(sample(LETTERS[1:2],2*length(times),T,prob=c(0.2,0.8)))
df<-data.frame(times=c(times,times),key=key,ref=ref)
p <- ggplot(df, aes(x=times, y = ..count.., fill = key))
p<-p + geom_bar(binwidth=60*60*24)
p
But if I want to add factor "ref" I have no idea what kind of plot I
should use. That means I want also plot the amount of
df[,"key"]=="A" & df[,"ref"]=="A"
And in my opinion to use a factor like
factor(paste(df$ref,df$key))
is not a solution. What else could you propose?

No comments:

Post a Comment