Reputation: 63
I would like to make a boxplot of the counts on y axis and the position on the axis.But the counts have different amount of counts, how can I plot it? Thanks! I'd also like to take the absolute value of the counts. Thanks!
> mat.count[1:50,]
position count
1 136873135 0
2 136873136 0
3 136873137 0
4 136873138 0
5 136873139 0
6 136873140 -15
7 136873141 0
8 136873142 0
9 136873143 0
10 136873144 0
11 136873145 0
12 136873146 0
13 136873147 0
14 136873148 0
15 136873149 0
16 136873150 0
17 136873151 0
18 136873152 0
19 136873153 0
20 136873154 0
21 136873155 0
22 136873156 0
23 136873157 0
24 136873158 0
25 136873159 0
26 136873160 0
27 136873161 0
28 136873162 0
29 136873163 0
30 136873164 0
31 136873165 0
32 136873166 0
33 136873167 0
34 136873168 -1
35 136873169 0
36 136873170 0
37 136873171 0
38 136873172 0
39 136873173 -70
40 136873174 -66
41 136873175 -73,-1,-1,-1,-73,-1
42 136873176 -52
43 136873177 0
44 136873178 0
45 136873179 -66,-1
46 136873180 -1
47 136873181 0
48 136873182 -68,-75
49 136873183 -67,-67
50 136873184 -60,-56,-56
Upvotes: 2
Views: 268
Reputation: 21621
Try:
library(splitstackshape)
mc <- cSplit(mat.count, "count", sep =",", "long")
boxplot(abs(count) ~ position, data = mc, varwidth = TRUE)
Or using ggplot2
:
ggplot(mc, aes(x=as.factor(position), y=abs(count))) +
geom_boxplot(varwidth=TRUE) +
theme(text = element_text(size=6),
axis.text.x = element_text(angle=90, vjust=1))
Upvotes: 1