Dear R users, - Is it possible to produce a figure with 2 plots that they share one of the axis, e.g., the y-axis? I did not succeed by setting mai[4] <- 0. Is there a simple way? - How could I convert 2 factor variables in a single factor variable which is the combination of the other 2. Example: lith: a factor 2 levels "ca", "ma" sp: a factor with 2 levels, "ph", "qi" and I'd like to obtain: splith: a factor with 4 levels: phma, phca, qima, qica on way is by using ifelse: splith <- as.factor(ifelse(sp=="ph", ifelse(lith=="ma", "phma", "phca"), ifelse(lith=="ma", "qima", "qica"))) which works fine, but I've got the feeling that it can be done in a more efficient way, especially for other cases where factors have more than 2 levels. Thanks in advance for any suggestion Juli -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hi On 30 Sep 2002 at 17:22, juli g. pausas wrote:> Dear R users, > > - Is it possible to produce a figure with 2 plots that they share one > of the axis, e.g., the y-axis? I did not succeed by setting mai[4] <- > 0. Is there a simple way? > > - How could I convert 2 factor variables in a single factor variable > which is the combination of the other 2. Example: > lith: a factor 2 levels "ca", "ma" > sp: a factor with 2 levels, "ph", "qi"interaction(f1,f2) works if f1 and f2 are factors with the same length if one factor is shorter than the other the shorter one is recycled> and I'd like to obtain: > splith: a factor with 4 levels: phma, phca, qima, qica > > on way is by using ifelse: > > splith <- as.factor(ifelse(sp=="ph", ifelse(lith=="ma", "phma", > "phca"), ifelse(lith=="ma", "qima", "qica"))) > > which works fine, but I've got the feeling that it can be done in a > more efficient way, especially for other cases where factors have more > than 2 levels. > > > Thanks in advance for any suggestion > > Juli > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. > -.-.-.-.- r-help mailing list -- Read > http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", > or "[un]subscribe" (in the "body", not the subject !) To: > r-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._. > _._._._._Petr Pikal petr.pikal at precheza.cz p.pik at volny.cz -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Dear Juli, At 05:22 PM 9/30/2002 +0200, juli g. pausas wrote:>- How could I convert 2 factor variables in a single factor variable >which is the combination of the other 2. >Example: > lith: a factor 2 levels "ca", "ma" > sp: a factor with 2 levels, "ph", "qi" >and I'd like to obtain: > splith: a factor with 4 levels: phma, phca, qima, qica > >on way is by using ifelse: > >splith <- as.factor(ifelse(sp=="ph", ifelse(lith=="ma", "phma", "phca"), >ifelse(lith=="ma", "qima", "qica"))) > >which works fine, but I've got the feeling that it can be done in a more >efficient way, especially for other cases where factors have more than 2 >levels.How about this? splith <- factor(paste(as.character(lith),as.character(sp), sep=".")) If you prefer that the levels be pasted without the periods, then you could use sep="". John ----------------------------------------------------- John Fox Department of Sociology McMaster University Hamilton, Ontario, Canada L8S 4M4 email: jfox at mcmaster.ca phone: 905-525-9140x23604 web: www.socsci.mcmaster.ca/jfox ----------------------------------------------------- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Mon, 30 Sep 2002, juli g. pausas wrote:> - How could I convert 2 factor variables in a single factor variable > which is the combination of the other 2. > Example: > lith: a factor 2 levels "ca", "ma" > sp: a factor with 2 levels, "ph", "qi" > and I'd like to obtain: > splith: a factor with 4 levels: phma, phca, qima, qica >strata(lith,sp) or interaction(lith,sp) -thomas -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Bill.Venables@cmis.csiro.au
2002-Oct-02 00:44 UTC
[R] 2 plots sharing axis / combining factors
Two short replies to Thomas's answer: "strata" is from the survival package. "interaction" and "strata" do slightly different things. The order in which the levels are cycled is different and In both cases the new level set is the cartesian product of all the component level sets, but with strata any vacant levels are pruned, with interaction they are not. Bill Venables. -----Original Message----- From: Thomas Lumley [mailto:tlumley at u.washington.edu] Sent: Tuesday, October 01, 2002 11:55 PM To: juli g. pausas Cc: r-help Subject: Re: [R] 2 plots sharing axis / combining factors On Mon, 30 Sep 2002, juli g. pausas wrote:> - How could I convert 2 factor variables in a single factor variable > which is the combination of the other 2. > Example: > lith: a factor 2 levels "ca", "ma" > sp: a factor with 2 levels, "ph", "qi" > and I'd like to obtain: > splith: a factor with 4 levels: phma, phca, qima, qica >strata(lith,sp) or interaction(lith,sp) -thomas -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. -.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._. _._ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._