[R] Inputs for plots

arun smartpink111 at yahoo.com
Mon Jun 17 15:49:30 CEST 2013



HI,
Try this:

X<- c("0","659-1000","641-659","634-641","630-634","630-630","626-628","618-626","604-618","574-604","0-574")
 Y<- c(0,2.166477,6.347396,12.23869,20.18244,26.07374,36.64006,48.15659,61.61155,77.95515,100.152)
 dat1<- data.frame(X,Y)
dat2<-dat1[order(dat1$Y,dat1$X),]
dat2$X<-factor(dat2$X,levels=dat2$X)
plot(as.numeric(dat2$X),dat2$Y,xaxt="n",xlab="X",ylab="Y",type="b")
 axis(1,at=as.numeric(dat2$X),labels=levels(dat2$X))
A.K.



________________________________
From: Sudha Krishnan <Sudha.Krishnan at marlabs.com>
To: "arun (smartpink111 at yahoo.com)" <smartpink111 at yahoo.com> 
Sent: Monday, June 17, 2013 9:09 AM
Subject: Inputs for plots




Arun, 

I am somehow getting struck while I try to Input values to a plot. I am really not sure how to go about better understanding how to input data for an column category names in X axis. Is there a way where I can get some understanding of this rather than trial and error? 


In this case, I have two columns X and Y (which I read from a csv). Column X has values like 659-1000,641-659,634-641,630-634,630-630,626-628,618-626,604-618,574-604,0-574( I have arrived at these values by calculating min and max values for a set of standard scores) 

Column Y has cumulative values (0,2.166477,6.347396,12.23869,20.18244,26.07374,36.64006,48.15659,61.61155,77.95515,100.152) 


I want to plot these in X and Y axis respectively, with those list of column  X that must appear as column category names. 

plot(mydata$X,mydata$Y,type="l",col="red",xlim=c(0,10),ylim=c(0,100),xaxp=c(0,10,10),xaxs="i",yaxs="i")
abline(0,10)


But I don’t see a proper curve when I do this. 

Is there anything that you can suggest for me to go about this? I technically want 659-1000,641-659,634-641,630-634,630-630,626-628,618-626,604-618,574-604,0-574 range listed in my column category instead of 0,1,2…..

Thanks
Sudha Krishnan           



More information about the R-help mailing list