Hi Luigi

 

not sure of your code and dataset

If you have rescaled your data so that they all go from 0-50, I rescaled
your original dataset so that max was 50

and this works. All you need is to add a group and col argument

 

stripplot(value~factor(time)|factor(dat$clas, levels =
c("low","medium","high")),dat, hor=F, layout = c(3,1) , groups =
factor(time), col = c("black","red") )

 

HTH

 

Duncan

 

 

From: Luigi Marongiu [mailto:marongiu.lu...@gmail.com] 
Sent: Saturday, 21 December 2013 03:32
To: Duncan Mackay
Subject: Re: [R] plot different groups as factors

 

Dear Duncan,

thank you for your reply. I have applied it and i obtained the figure
attached. I changed BWplot with stripplot and it looks OK. Only thing: would
it be possible to have different colours for the time plot at 12 and 18?

Best regards,

Luigi

 

 

On Thu, Dec 19, 2013 at 12:32 PM, Duncan Mackay <dulca...@bigpond.com>
wrote:

Hi Luigi

A quick guess with lattice

library(lattice)

structure(list(time = c(18, 18, 18, 18, 18, 18, 18, 18, 18, 18,

18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,

12, 12, 12, 12, 12, 12, 12, 12), clas = c("medium", "medium",
"medium", "medium", "medium", "medium", "medium", "medium", "medium",
"medium", "medium", "medium", "medium", "medium", "high", "high",
"high", "high", "high", "high", "high", "low", "low", "low",
"low", "low", "low", "low", "medium", "medium", "medium", "medium",
"medium", "medium", "medium", "medium", "medium", "medium", "medium",
"medium", "medium", "medium", "medium", "medium", "medium", "medium",
"high", "high", "high", "high", "high", "high", "high", "high",
"high", "high", "low", "low", "low", "low", "low", "low", "low",
"low", "low", "low"), value = c(2.92, 0.01, 0.36, 3.16, 0.99,

0.38, 0.01, 5.1, 0.04, 0.01, 1.33, 4.13, 0.15, 0.15, 14.18, 4290.14,
26.8, 5.33, 17.58, 14.29, 248.5, 0.01, 0, 0, 0, 0, 0, 0, 0.151395382,
5.327863403, 5.10096383, 1.32567787, 4.352404124, 0.458606982,
2.915908912, 0.011996374, 0.364710382, 0.033016026, 3.161701212,
0.381564497, 0.010971385, 0.035646472, 0.014781805, 4.129708296,
0.153094117, 0.018497847, 15.09178491, 17.58393041, 14.17643928,
4290.143561, 26.79730719, 294.6367065, 14.2888441, 248.495231,
209.3131795, 2014.506722, 0.010751273, 0.002325138, 0.000637473,

0.003984336, 0.006018154, 0.003620907, 7.45936e-05, 0.000142311,
0.002460417, 0.001280189)), .Names = c("time", "clas", "value"
), row.names = c(NA, -66L), class = "data.frame")

bwplot(value~factor(time)|factor(dat$clas, levels =
c("low","medium","high")),dat, hor=F, layout = c(3,1),scales = list(relation
= "free") )

Regards

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mac...@northnet.com.au






-----Original Message-----
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Luigi Marongiu
Sent: Thursday, 19 December 2013 10:19
To: r-help@r-project.org
Subject: [R] plot different groups as factors

dear all,
i would like to plot the value of different response groups. when i simply
use  plot(y ~ x) i obtain a series of boxplots. i would rather use dots. i
also tried with stripchart(y ~ x), which gives better results but does not
place properly the labels since place them alphabetically.
in addition i actually have 6 response groups: 3 classes (low, medium,
high) and 2 sampling time (12 and 18 months).
how can i generate these individual groups and plot them in the correct
order (low, medium, high and 12, 18)? i believe is something to do with the
factors but i don't know how to implement them.
what i am looking for is to generate a figure such as the one i sketched in
the attached file. i also attached a dataframe version of my data. the
vectors containing the same data are:
time <-c(  18,    18,    18,    18,    18,    18,    18,    18,    18,
18,    18,    18,    18,    18,    18,    18,    18,    18,    18,
18,    18,    18,    18,    18,    18,    18,    18,    18,    12,
12,    12,    12,    12,    12,    12,    12,    12,    12,    12,
12,    12,    12,    12,    12,    12,    12,    12,    12,    12,
12,    12,    12,    12,    12,    12,    12,    12,    12,    12,
12,    12,    12,    12,    12,    12,    12)
class <-c(    medium,    medium,    medium,    medium,    medium,
medium,    medium,    medium,    medium,    medium,    medium,
medium,    medium,    medium,    high,    high,    high,    high,
high,    high,    high,    low,    low,    low,    low,    low,    low,
low,    medium,    medium,    medium,    medium,    medium,    medium,
medium,    medium,    medium,    medium,    medium,    medium,
medium,    medium,    medium,    medium,    medium,    medium,    high,
high,    high,    high,    high,    high,    high,    high,    high,
high,    low,    low,    low,    low,    low,    low,    low,    low,
low,    low)
value <-c(    2.92,    0.01,    0.36,    3.16,    0.99,    0.38,
0.01,    5.1,    0.04,    0.01,    1.33,    4.13,    0.15,    0.15,
14.18,    4290.14,    26.8,    5.33,    17.58,    14.29,    248.5,
0.01,    0,    0,    0,    0,    0,    0,    0.151395382,
5.327863403,    5.10096383,    1.32567787,    4.352404124,
0.458606982,    2.915908912,    0.011996374,    0.364710382,
0.033016026,    3.161701212,    0.381564497,    0.010971385,
0.035646472,    0.014781805,    4.129708296,    0.153094117,
0.018497847,    15.09178491,    17.58393041,    14.17643928,
4290.143561,    26.79730719,    294.6367065,    14.2888441,
248.495231,    209.3131795,    2014.506722,    0.010751273,
0.002325138,    0.000637473,    0.003984336,    0.006018154,
0.003620907,    0.0000745936,    0.000142311,    0.002460417,
0.001280189)

Thank you very much for any help you could provide!
regards
Luigi

 


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to