Dear all, Thanks for your help. Option of Sarah and Dan is just what I want:
ff1<-mydata[mydata$cat%in%c(“wish1”, “wish2”, “wish3”),] Then I used ff1 in ggplot2 without problems. Option of Dennis (reshape2) does produced an output “no coherent”: content in he object contained data of categorical variable but not data of “ind”. Option of Dennis (ggplot2) does functioned well, but when I put more than one clasification in categ the following output is obtained: > ggplot(subset(mydata, categ=='folic tot', 'porc fol marc'), > aes(age,ind))+geom_point() Error in `[.data.frame`(x, r, vars, drop = drop) : undefined columns selected I tryed the same but added ddply: qq<-ddply(mydata, .(ind), subset, categ=("porc fol tot", "porc fol marc")) Error: unexpected ',' in "qq<-ddply(mydata, .(ind), subset, categ=("porc fol tot"," Any idea about the last? Andrés AM 2011/10/25, Dennis Murphy <djmu...@gmail.com>: > Are you trying to separate the substrings in cat? If so, one way is to > use the colsplit() function in the reshape2 package, something like > (untested since you did not provide a suitable data format with which > to work): > > library('reshape2') > splitcat <- colsplit(mydata$cat, ' ', names = c('fat', 'bat', 'rat')) > moredat <- cbind(mydata, splitcat) > > Other options that might pertain to your request include: > > (i) subset(mydata, cat == 'por fol pec') > which you can use as a data argument inside ggplot2 - e.g., > > ggplot(subset(mydata, cat == 'por fol pec'), aes(x = age, y = ind)) + > geom_point() > > (ii) use faceting to get individual plots by factor level of cat - e.g., > ggplot(mydata, aes(x = age, y = ind)) + > geom_point() + > facet_grid( ~ cat) > > Hope that one of these is close to the bullseye... > Dennis > > > 2011/10/25 Andrés Aragón <armand...@gmail.com>: >> Dear all, >> >> I'm trying to analyze data with the following structure: >> >> ind cat tx age >> 40.2 por fol peq vh 35 >> 41.9 por fol med vh 35 >> 68.9 por fol preov vh 35 >> 71.5 por fol peq ser 37 >> 67.5 por fol med ser 37 >> 76.9 por fol preov ser 37 >> 78.7 por fol peq otr 37 >> 78.3 por fol med otr 37 >> 82.1 por fol preov otr 37 >> 83.9 por fol peq vh 37 >> 80.6 por fol med vh 37 >> 76.1 por fol preov vh 37 >> 86.9 por fol peq ser 35 >> 97.7 por fol med ser 35 >> 62.3 por fol preov ser 35 >> >> >> >> I want to separate exclusively some of factor levels (“por fol peq” >> in the “cat” colum). I am using ggplot2 and I only can plot all of >> factors, not separately. I did try ddply without success. >> Any help is welcome. >> >> Andrés >> >> ______________________________________________ >> 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. >> > ______________________________________________ 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.