Hi, I am new to R. I have a bit of data looking like this: SemType, Length GeoLocation, Sentence GeneralInfo, Paragraphs GeneralInfo, Paragraphs GeneralInfo, Sentence GeneralInfo, Paragraphs NatLang, Phrase Advice, Article GeneralInfo Advice, Article Resource, Sentence ... (roughly 40,000 lines in total) I am interested in how many counts of each item in the second row I get for each item in the first. I read it in using qt <- read.table("~/results.table", header=TRUE, sep=",") And then I plot it: plot(qt, col=color) That works really fabulous, I am amazed. BUT: R orders the names on the x- and y-axes ("Sentences", "Paragraphs" etc. for y) alphabetically. That's a reasonable thing to do of course, especially because I didn't tell R in which order I'd like to have them. Nevertheless, I'd like to have them in a specific order ("Phrase", "Sentence", "Paragraph", "Article" for y), and I cannot seem to find a way to tell R about this. Can anyone help? Best Regards, Michael
Try ordering the factors: x <- read.table(textConnection("SemType, Length GeoLocation, Sentence GeneralInfo, Paragraphs GeneralInfo, Paragraphs GeneralInfo, Sentence GeneralInfo, Paragraphs NatLang, Phrase Advice, Article GeneralInfo, Article Advice, Article Resource, Sentence"), header=TRUE) # order the levels x$Length <- ordered(x$Length, levels=c("Phrase", "Paragraphs", "Sentence", "Article")) On 10/1/07, Michael Kaisser <mkaisser at powerset.com> wrote:> > > Hi, > > I am new to R. > > I have a bit of data looking like this: > > SemType, Length > GeoLocation, Sentence > GeneralInfo, Paragraphs > GeneralInfo, Paragraphs > GeneralInfo, Sentence > GeneralInfo, Paragraphs > NatLang, Phrase > Advice, Article > GeneralInfo > Advice, Article > Resource, Sentence > ... > (roughly 40,000 lines in total) > > I am interested in how many counts of each item in the second row I get for > each item in the first. > > I read it in using > qt <- read.table("~/results.table", header=TRUE, sep=",") > > And then I plot it: > plot(qt, col=color) > > That works really fabulous, I am amazed. > BUT: R orders the names on the x- and y-axes ("Sentences", "Paragraphs" etc. > for y) alphabetically. That's a reasonable thing to do of course, especially > because I didn't tell R in which order I'd like to have them. Nevertheless, > I'd like to have them in a specific order ("Phrase", "Sentence", > "Paragraph", "Article" for y), and I cannot seem to find a way to tell R > about this. > > Can anyone help? > > Best Regards, > Michael > > ______________________________________________ > R-help at 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. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve?
Hi Michael, This type of thing is pretty simple to do in R (take a look at ?plot and then ?par - very useful... necessary actually... for graphing). One way to do it is to use the "axis" function: my.labels <- c("a","b","c","d","e","f","g","h","i","j") plot(1:10,rnorm(10),axes=F,ylab="whatev",xlab="whatev") axis(1,at=1:10,labels=my.labels, font=1, cex.axis=.85, las=1) On 10/1/07, Michael Kaisser <mkaisser at powerset.com> wrote:> > > Hi, > > I am new to R. > > I have a bit of data looking like this: > > SemType, Length > GeoLocation, Sentence > GeneralInfo, Paragraphs > GeneralInfo, Paragraphs > GeneralInfo, Sentence > GeneralInfo, Paragraphs > NatLang, Phrase > Advice, Article > GeneralInfo > Advice, Article > Resource, Sentence > ... > (roughly 40,000 lines in total) > > I am interested in how many counts of each item in the second row I get for > each item in the first. > > I read it in using > qt <- read.table("~/results.table", header=TRUE, sep=",") > > And then I plot it: > plot(qt, col=color) > > That works really fabulous, I am amazed. > BUT: R orders the names on the x- and y-axes ("Sentences", "Paragraphs" etc. > for y) alphabetically. That's a reasonable thing to do of course, especially > because I didn't tell R in which order I'd like to have them. Nevertheless, > I'd like to have them in a specific order ("Phrase", "Sentence", > "Paragraph", "Article" for y), and I cannot seem to find a way to tell R > about this. > > Can anyone help? > > Best Regards, > Michael > > ______________________________________________ > R-help at 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. >-- Matthew C Keller Postdoctoral Fellow Virginia Institute for Psychiatric and Behavioral Genetics