I am new to R and am running into trouble with the function plot. When I enter in the simple code: x<-1:4 y<-5:8 plot(x,y) I get a scatter plot with 4 points as expected. However, with my own data, A and B are both vectors of length ~85, each entry a decimal in [0,1]. Using the same plot(A,B) with this data, the plot function no longer gives me a simple plot with 85 points. Instead there are many points, and what looks to be several box&whisker plots also included on the plot. This is a link to the actual output. http://www.nabble.com/file/p20364310/plotAB.bmp plotAB.bmp Why is the plot function doing this? How can I get it to simply give me a scatterplot? (From there I want to do a lsline, etc..) Any help is greatly appreciated... Thanks! -- View this message in context: http://www.nabble.com/New-to-R---Errors-in-plotting-tp20364310p20364310.html Sent from the R help mailing list archive at Nabble.com.
You need to provide more information. PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Show at least an 'str' of your data if you can not include it and the commands that you were using. On Thu, Nov 6, 2008 at 11:18 AM, BKMooney <bkmooney at gmail.com> wrote:> > I am new to R and am running into trouble with the function plot. > > When I enter in the simple code: > x<-1:4 > y<-5:8 > plot(x,y) > > I get a scatter plot with 4 points as expected. > > However, with my own data, A and B are both vectors of length ~85, each > entry a decimal in [0,1]. > > Using the same plot(A,B) with this data, the plot function no longer gives > me a simple plot with 85 points. Instead there are many points, and what > looks to be several box&whisker plots also included on the plot. > > This is a link to the actual output. > http://www.nabble.com/file/p20364310/plotAB.bmp plotAB.bmp > > Why is the plot function doing this? How can I get it to simply give me a > scatterplot? (From there I want to do a lsline, etc..) > > Any help is greatly appreciated... > > Thanks! > -- > View this message in context: http://www.nabble.com/New-to-R---Errors-in-plotting-tp20364310p20364310.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. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve?
Hello - In you example, what are the classes of x and y? x<-1:4 y<-5:8 plot(x,y) class(x) class(y) In your 'real' data, what are the classes of A and B class(A) class(B) One may be a factor? How are you reading your data into R, read.table? Make sure your data are numeric, then plot them, and it should do what you'd like. Since you're new to R, one of my tips would be to learn the class() and str() functions. Many functions, such as plot, operate differently depending on the class of data given to them, therefore it's very important to know the classes of your data objects. BKMooney wrote:> I am new to R and am running into trouble with the function plot. > > When I enter in the simple code: > x<-1:4 > y<-5:8 > plot(x,y) > > I get a scatter plot with 4 points as expected. > > However, with my own data, A and B are both vectors of length ~85, each > entry a decimal in [0,1]. > > Using the same plot(A,B) with this data, the plot function no longer gives > me a simple plot with 85 points. Instead there are many points, and what > looks to be several box&whisker plots also included on the plot. > > This is a link to the actual output. > http://www.nabble.com/file/p20364310/plotAB.bmp plotAB.bmp > > Why is the plot function doing this? How can I get it to simply give me a > scatterplot? (From there I want to do a lsline, etc..) > > Any help is greatly appreciated... > > Thanks!
On 06/11/2008 11:18 AM, BKMooney wrote:> I am new to R and am running into trouble with the function plot. > > When I enter in the simple code: > x<-1:4 > y<-5:8 > plot(x,y) > > I get a scatter plot with 4 points as expected. > > However, with my own data, A and B are both vectors of length ~85, each > entry a decimal in [0,1]. > > Using the same plot(A,B) with this data, the plot function no longer gives > me a simple plot with 85 points. Instead there are many points, and what > looks to be several box&whisker plots also included on the plot. > > This is a link to the actual output. > http://www.nabble.com/file/p20364310/plotAB.bmp plotAB.bmp > > Why is the plot function doing this? How can I get it to simply give me a > scatterplot? (From there I want to do a lsline, etc..) > > Any help is greatly appreciated...Most likely your A vector is not numeric: it's being read as strings like "0.4688", etc. Take a look at str(A) and str(B) to see their structure. (I can't tell from the plot, but I'd guess it's being read as a factor, because some of the values are not recognized as numeric.) Duncan Murdoch