I have created a scatter plot that has come out okay but I am having trouble with the x axis. My data consists of 4 treatments but these treatments are days so R keeps reading them as numeric and making my x axis continuous. Here is what I have so far: plot(pair$MC~pair$Day, pch=c(19,24)[as.factor(Cookie)], main='Paired t Test', xlab='Days in Field', ylab='Moisture Content (Percent)') I have also done: as.factor(Day) to change it to 4 levels and when I do is.factor(Day) it returns with FALSE. I'm assuming this is the reason that I get the message that my x and y lengths differ when trying to convert my x axis using: axis(side=1, at=c(0,15,30,45) When I switch my numbers to words (i.e. zero, fifteen...) it only brings up a boxplot and I specifically want the points so I can assign different pch by group. Am I totally missing something here? -- View this message in context: http://r.789695.n4.nabble.com/scatterplot-x-axis-specifications-tp4630952.html Sent from the R help mailing list archive at Nabble.com.
On 22.05.2012 19:59, jhartsho wrote:> I have created a scatter plot that has come out okay but I am having trouble > with the x axis. My data consists of 4 treatments but these treatments are > days so R keeps reading them as numeric and making my x axis continuous. > Here is what I have so far: > > > plot(pair$MC~pair$Day, pch=c(19,24)[as.factor(Cookie)], > main='Paired t Test', > xlab='Days in Field', > ylab='Moisture Content (Percent)') > > I have also done: as.factor(Day) to change it to 4 levels and when I do > is.factor(Day) it returns with FALSE. > > I'm assuming this is the reason that I get the message that my x and y > lengths differ when trying to convert my x axis using: > > axis(side=1, at=c(0,15,30,45) > > When I switch my numbers to words (i.e. zero, fifteen...) it only brings up > a boxplot and I specifically want the points so I can assign different pch > by group. Am I totally missing something here?Yes, missing a reproducible example so that we could easily show how it works. Best, Uwe Ligges> -- > View this message in context: http://r.789695.n4.nabble.com/scatterplot-x-axis-specifications-tp4630952.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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.
On May 22, 2012, at 1:59 PM, jhartsho wrote:> I have created a scatter plot that has come out okay but I am having > trouble > with the x axis. My data consists of 4 treatments but these > treatments are > days so R keeps reading them as numeric and making my x axis > continuous. > Here is what I have so far: > > > plot(pair$MC~pair$Day, pch=c(19,24)[as.factor(Cookie)], > main='Paired t Test', > xlab='Days in Field', > ylab='Moisture Content (Percent)') > > I have also done: as.factor(Day) to change it to 4 levelsNo. This is more of a functional programming language, not an applicative one. There are functions with side-effects but very few that will change objects without assignment.> and when I do > is.factor(Day) it returns with FALSE.You probably did not make the assignment.. pair$Day <- factor(pair$Day)> > I'm assuming this is the reason that I get the message that my x and y > lengths differ when trying to convert my x axis using: > > axis(side=1, at=c(0,15,30,45) > > When I switch my numbers to words (i.e. zero, fifteen...) it only > brings up > a boxplot and I specifically want the points so I can assign > different pch > by group. Am I totally missing something here?You may have lost me on that one. axis(side=1, at= at=c(0,15,30,45), labels=c("one","fifteen", "thirty", "forty-five") One _does_ need to read the help page to learn the correct argument names. -- David Winsemius, MD West Hartford, CT