Ole Tange
Ole Tange

Reputation: 33685

R: boxplot of 2 columned table

My input is:

4 a
2 a
3 a
5 b
4 b
1 c
5 c
8 c

I would like a boxplot of a, b, and c.

How do I convert the above into something I can boxplot?

Upvotes: 0

Views: 90

Answers (3)

rnso
rnso

Reputation: 24535

You can also use ggplot package, where further refinements may be easier:

library(ggplot2)
ggplot(ddf)+geom_boxplot(aes(let, val))

enter image description here

Upvotes: 0

niandra82
niandra82

Reputation: 255

If your data are in the dataset data1, for example, you can use the following:

boxplot(data1[,1] ~data[,2])

Upvotes: 1

Henry
Henry

Reputation: 6784

Try ?boxplot to find how to use the boxplot function.

For example

exampledf <- data.frame( val=c(4, 2, 3, 5, 4, 1, 5, 8), 
                         let=c("a", "a", "a", "b", "b", "c", "c", "c") )
boxplot(val ~ let, data=exampledf)

gives

enter image description here

though you really need more observations for each letter for this to be informative

Upvotes: 1

Related Questions