Re: Plot this data using ggplot2

18 views
Skip to first unread message

Ben Bond-Lamberty

unread,
Oct 2, 2012, 12:31:31 PM10/2/12
to ggp...@googlegroups.com
What kind of plot are you trying to produce?
Ben

On Tue, Oct 2, 2012 at 12:25 PM, veepsirtt <veep...@gmail.com> wrote:
> How to plot this as it is?.
> data=
> V1 V2 V3 V4 V5 V6
> 1 145 0 0 0 0 1
> 2 142 0 0 0 0 1
> 3 139 0 0 1 0 1
> 4 137 0 0 1 -1 1
> 5 134 0 0 1 -1 1
> 6 131 0 0 1 -1 1
> 7 129 0 0 1 -1 0
> 8 126 1 0 1 0 0
> 9 124 1 -1 1 0 0
> 10 121 1 -1 1 0 0
> 11 119 1 -1 1 0 0
> 12 117 1 -1 0 0 0
> 13 114 1 0 0 0 0
> 14 112 1 0 0 0 0
> 15 110 0 0 0 0 0
> 16 A B C D E F
>
> Thanks
> veepsirtt
>
>
> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> Please provide a reproducible example:
> https://github.com/hadley/devtools/wiki/Reproducibility
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2

Velappan Periasamy

unread,
Oct 2, 2012, 12:40:03 PM10/2/12
to Ben Bond-Lamberty, ggp...@googlegroups.com
Hi
I would like to have barplot.

Ben Bond-Lamberty

unread,
Oct 2, 2012, 12:48:56 PM10/2/12
to Velappan Periasamy, ggp...@googlegroups.com
Well, here's something to hopefully get you started. If you have
something else in mind, please specify. -Ben

# working with data frame 'd'
d <- structure(list(A = structure(c(15L, 14L, 13L, 12L, 11L, 10L,
9L, 8L, 7L, 6L, 5L, 4L, 3L, 2L, 1L), .Label = c("110", "112",
"114", "117", "119", "121", "124", "126", "129", "131", "134",
"137", "139", "142", "145"), class = "factor"), B = c(0L, 0L,
0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L), C = c(0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, -1L, -1L, -1L, -1L, 0L, 0L, 0L),
D = c(0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L,
0L, 0L), E = c(0L, 0L, 0L, -1L, -1L, -1L, -1L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L), F = c(1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L)), .Names = c("A", "B", "C", "D",
"E", "F"), row.names = c(NA, -15L), class = "data.frame")

library(reshape)
d_melted <- melt( d, id.vars="A" )
qplot(A,value,fill=variable,geom="bar",data=d_melted)
Reply all
Reply to author
Forward
0 new messages