Elcio Silveira
Elcio Silveira

Reputation: 25

How to do a boxplot with just some data of a big table?

I have a table like

levels,fbest
l1;12.6047459516359
l1;17.7790155785604
l2;12.9751482431558
l2;11.6308580312229
l3;13.1983516785261
l3;14.8089962471286
l4;12.2291110811856
l4;14.9696263794269

in a "csv" format. I read this table with

data <- read.csv(file = "data.csv", sep = ";", dec = ".", header = T)

after that I need make a boxplot with just the levels l1, l2 and l3. Someone knows how can I do it?

I know how to do a boxplot with all data, but not with only some levels. With all data, I do

boxplot(fbest~levels,data=data, pch = 16, cex = 2)

Thanks.

Upvotes: 0

Views: 117

Answers (1)

Daniel Anderson
Daniel Anderson

Reputation: 2424

A simple solution would be to just first subset the data so it only contains those levels, and then produce the box plot. Something like.

ss <- subset(data, levels == l1 | levels == l2 | levels == l3)
ss$levels <- as.factor(as.character(ss$levels))

boxplot(fbest ~ levels, data = ss, pch = 16, cex = 2)

Upvotes: 1

Related Questions