I have grades data. I read them from a csv in letter-grade format. I
then converted them to levels
levels(grades$grade)=c('A+','A','A-','B+','B','B-','C+','C','C-','D+','D','D-')
And then to numbers
grades$gp=grades$grade
levels(grades$gp)=c(4.3,4.0,3.7, 3.3,3.0,2.7, 2.3,2.0,1.7, 1.3,1.0,0.7)
grades$gp=as.numeric(as.character(grades$gp))
And I'm plotting them in a barplot
barplot(gp[order(gp)],width=n[order(gp)],ylab="Class Median
Grade",xlab="Class, scaled to number of students in the
class",main="Class Median Grades for Cornell University weighted by
class size")
I would like to change the scale on the bar graph such that it reads
c('A+','A','A-','B+','B','B-','C+','C','C-','D+','D','D-')
in the locations
c(4.3,4.0,3.7, 3.3,3.0,2.7, 2.3,2.0,1.7, 1.3,1.0,0.7)
Any ideas?
Tom
Thomas,
You could perhaps do a tad better by simply adding a right-hand-side
axis using axis():
axis(4, at=c(4.3,4.0,3.7, 3.3,3.0,2.7, 2.3,2.0,1.7, 1.3,1.0,0.7),
labels=c('A+','A','A-','B+','B','B-','C+','C','C-','D+','D','D-'),
las=1)
That way you have both numeric and grade scales.
if you want a left-hand grade scale only, first suppress the axes in the
barplot using axes=FALSE, and then add the axes using axis(1) and
axis(2,..) with the ... as above.
Incidentally, I'm not sure I'd have converted your numbers that way, but
if it's worked it's worked.
Steve E>>> Thomas Levine <thomas.levine at gmail.com> 02/28/10 12:44 AM
>>>
I have grades data. I read them from a csv in letter-grade format. I
then converted them to levels
levels(grades$grade)=c('A+','A','A-','B+','B','B-','C+','C','C-','D+','D','D-')
And then to numbers
grades$gp=grades$grade
levels(grades$gp)=c(4.3,4.0,3.7, 3.3,3.0,2.7, 2.3,2.0,1.7, 1.3,1.0,0.7)
grades$gp=as.numeric(as.character(grades$gp))
And I'm plotting them in a barplot
barplot(gp[order(gp)],width=n[order(gp)],ylab="Class Median
Grade",xlab="Class, scaled to number of students in the
class",main="Class Median Grades for Cornell University weighted by
class size")
I would like to change the scale on the bar graph such that it reads
c('A+','A','A-','B+','B','B-','C+','C','C-','D+','D','D-')
in the locations
c(4.3,4.0,3.7, 3.3,3.0,2.7, 2.3,2.0,1.7, 1.3,1.0,0.7)
Any ideas?
Tom
______________________________________________
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.
*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}
Yay! That's perfect. Thanks, Steve! Tom 2010/2/27 S Ellison <S.Ellison at lgc.co.uk>:> Thomas, > > You could perhaps do a tad better by simply adding a right-hand-side > axis using axis(): > > axis(4, at=c(4.3,4.0,3.7, 3.3,3.0,2.7, 2.3,2.0,1.7, 1.3,1.0,0.7), > labels=c('A+','A','A-','B+','B','B-','C+','C','C-','D+','D','D-'), > las=1) > > That way you have both numeric and grade scales. > > if you want a left-hand grade scale only, first suppress the axes in the > barplot using axes=FALSE, and then add the axes using axis(1) and > axis(2,..) with the ... as above. > > Incidentally, I'm not sure I'd have converted your numbers that way, but > if it's worked it's worked. > > Steve E >>>> Thomas Levine <thomas.levine at gmail.com> 02/28/10 12:44 AM >>> > I have grades data. I read them from a csv in letter-grade format. I > then converted them to levels > > levels(grades$grade)=c('A+','A','A-','B+','B','B-','C+','C','C-','D+','D','D-') > > And then to numbers > > grades$gp=grades$grade > levels(grades$gp)=c(4.3,4.0,3.7, 3.3,3.0,2.7, 2.3,2.0,1.7, 1.3,1.0,0.7) > grades$gp=as.numeric(as.character(grades$gp)) > > And I'm plotting them in a barplot > > barplot(gp[order(gp)],width=n[order(gp)],ylab="Class Median > Grade",xlab="Class, scaled to number of students in the > class",main="Class Median Grades for Cornell University weighted by > class size") > > I would like to change the scale on the bar graph such that it reads > > c('A+','A','A-','B+','B','B-','C+','C','C-','D+','D','D-') > > in the locations > > c(4.3,4.0,3.7, 3.3,3.0,2.7, 2.3,2.0,1.7, 1.3,1.0,0.7) > > Any ideas? > > Tom > > ______________________________________________ > 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. > > > ******************************************************************* > This email and any attachments are confidential. Any u...{{dropped:9}}
On 02/28/2010 11:44 AM, Thomas Levine wrote:> I have grades data. I read them from a csv in letter-grade format. I > then converted them to levels > > levels(grades$grade)=c('A+','A','A-','B+','B','B-','C+','C','C-','D+','D','D-') > > And then to numbers > > grades$gp=grades$grade > levels(grades$gp)=c(4.3,4.0,3.7, 3.3,3.0,2.7, 2.3,2.0,1.7, 1.3,1.0,0.7) > grades$gp=as.numeric(as.character(grades$gp)) > > And I'm plotting them in a barplot > > barplot(gp[order(gp)],width=n[order(gp)],ylab="Class Median > Grade",xlab="Class, scaled to number of students in the > class",main="Class Median Grades for Cornell University weighted by > class size") > > I would like to change the scale on the bar graph such that it reads > > c('A+','A','A-','B+','B','B-','C+','C','C-','D+','D','D-') > > in the locations > > c(4.3,4.0,3.7, 3.3,3.0,2.7, 2.3,2.0,1.7, 1.3,1.0,0.7) >Hi Tom, You can do this directly using the height.at and height.lab arguments in the barp function in the plotrix package. Jim
Reasonably Related Threads
- Understanding lm-based analysis of fractional factorial experiments
- lattice multipanel strip placement - with two factors
- Regular expressions: offsets of groups
- Repost: Estimation when interaction is present: How do I get get the parameters from nlme?
- spot the error (I can''t, I''m new)