Re: [R] Using column length in plot gives error

2009-05-17 Thread Dieter Menne
MikSmith mike at hsm.org.uk writes:

 I'm trying to write a generic script for processing some data which finishes
 off with some plots. Given Im never sure how many columns will be in my
 dataframe I wanted to using the following 
 
 plot(spectra.wavelength, cormat, type = l, ylim=c(-1,1), xlab=Wavelength
 (nm), ylab=Correlation)
 
 however even if I specify as type=l it appears plot as points (right hand
 plot). If I specify a range such as 
 
 plot(650:700, cormat, type = l, ylim=c(-1,1), xlab=Wavelength (nm),
 ylab=Correlation)
 
 it looks good (left hand plot). If I try something like:
 

The example is not reproducible so we can only guess. I assume
spectra.wavelength is a matrix, so the matrix x/y values are plotted. 
In the second example the first parameter is definitively a vector.

Dieter

__
R-help@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.


Re: [R] Using column length in plot gives error

2009-05-17 Thread MikSmith

Hi Stephanie

Absolutely right! My CSV was imported as a factor. Reading the R FAQ:

http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-do-I-convert-factors-to-numeric_003f

I actually need to do:

as.numeric(as.character(spectra.wavelength))

to get back to my original data.

Many thanks for the pointer

mike



Stephanie Kovalchik wrote:
 
 Is spectra.wavelength a factor? If so, plot will treat it as  
 categorical and not draw a line. Try the following modification.
 
 plot(as.numeric(spectra.wavelength), cormat, type = l, ylim=c(-1,1),  
 xlab=Wavelength (nm), ylab=Correlation)
 
 Quoting MikSmith m...@hsm.org.uk:
 

 Hi

 I'm trying to write a generic script for processing some data which
 finishes
 off with some plots. Given Im never sure how many columns will be in my
 dataframe I wanted to using the following

 plot(spectra.wavelength, cormat, type = l, ylim=c(-1,1),
 xlab=Wavelength
 (nm), ylab=Correlation)

 however even if I specify as type=l it appears plot as points (right
 hand
 plot). If I specify a range such as

 plot(650:700, cormat, type = l, ylim=c(-1,1), xlab=Wavelength (nm),
 ylab=Correlation)

 it looks good (left hand plot). If I try something like:

 plot(spectra.wavelength[1]:spectra.wavelength[length(spectra.wavelength)],
 cormat, type = l, ylim=c(-1,1), xlab=Wavelength (nm),
 ylab=Correlation)

 it fails with variable lengths differ and when I look at
 spectra.wavelength[1] it gives me the value but then states there are 53
 levels.

 What does this mean and how can I get the result I want??!

 many thanks

 mike http://www.nabble.com/file/p23562717/1.pdf 1.pdf
 --
 View this message in context:   
 http://www.nabble.com/Using-column-length-in-plot-gives-error-tp23562717p23562717.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@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.

 
 __
 R-help@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.
 
 

-- 
View this message in context: 
http://www.nabble.com/Using-column-length-in-plot-gives-error-tp23562717p23582038.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


Re: [R] Using column length in plot gives error

2009-05-16 Thread Stephanie Kovalchik
Is spectra.wavelength a factor? If so, plot will treat it as  
categorical and not draw a line. Try the following modification.


plot(as.numeric(spectra.wavelength), cormat, type = l, ylim=c(-1,1),  
xlab=Wavelength (nm), ylab=Correlation)


Quoting MikSmith m...@hsm.org.uk:



Hi

I'm trying to write a generic script for processing some data which finishes
off with some plots. Given Im never sure how many columns will be in my
dataframe I wanted to using the following

plot(spectra.wavelength, cormat, type = l, ylim=c(-1,1), xlab=Wavelength
(nm), ylab=Correlation)

however even if I specify as type=l it appears plot as points (right hand
plot). If I specify a range such as

plot(650:700, cormat, type = l, ylim=c(-1,1), xlab=Wavelength (nm),
ylab=Correlation)

it looks good (left hand plot). If I try something like:

plot(spectra.wavelength[1]:spectra.wavelength[length(spectra.wavelength)],
cormat, type = l, ylim=c(-1,1), xlab=Wavelength (nm),
ylab=Correlation)

it fails with variable lengths differ and when I look at
spectra.wavelength[1] it gives me the value but then states there are 53
levels.

What does this mean and how can I get the result I want??!

many thanks

mike http://www.nabble.com/file/p23562717/1.pdf 1.pdf
--
View this message in context:   
http://www.nabble.com/Using-column-length-in-plot-gives-error-tp23562717p23562717.html

Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.



__
R-help@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.


[R] Using column length in plot gives error

2009-05-15 Thread MikSmith

Hi

I'm trying to write a generic script for processing some data which finishes
off with some plots. Given Im never sure how many columns will be in my
dataframe I wanted to using the following 

plot(spectra.wavelength, cormat, type = l, ylim=c(-1,1), xlab=Wavelength
(nm), ylab=Correlation)

however even if I specify as type=l it appears plot as points (right hand
plot). If I specify a range such as 

plot(650:700, cormat, type = l, ylim=c(-1,1), xlab=Wavelength (nm),
ylab=Correlation)

it looks good (left hand plot). If I try something like:

plot(spectra.wavelength[1]:spectra.wavelength[length(spectra.wavelength)],
cormat, type = l, ylim=c(-1,1), xlab=Wavelength (nm),
ylab=Correlation)

it fails with variable lengths differ and when I look at
spectra.wavelength[1] it gives me the value but then states there are 53
levels.

What does this mean and how can I get the result I want??!

many thanks

mike
-- 
View this message in context: 
http://www.nabble.com/Using-column-length-in-plot-gives-error-tp23562704p23562704.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


[R] Using column length in plot gives error

2009-05-15 Thread MikSmith

Hi

I'm trying to write a generic script for processing some data which finishes
off with some plots. Given Im never sure how many columns will be in my
dataframe I wanted to using the following 

plot(spectra.wavelength, cormat, type = l, ylim=c(-1,1), xlab=Wavelength
(nm), ylab=Correlation)

however even if I specify as type=l it appears plot as points (right hand
plot). If I specify a range such as 

plot(650:700, cormat, type = l, ylim=c(-1,1), xlab=Wavelength (nm),
ylab=Correlation)

it looks good (left hand plot). If I try something like:

plot(spectra.wavelength[1]:spectra.wavelength[length(spectra.wavelength)],
cormat, type = l, ylim=c(-1,1), xlab=Wavelength (nm),
ylab=Correlation)

it fails with variable lengths differ and when I look at
spectra.wavelength[1] it gives me the value but then states there are 53
levels.

What does this mean and how can I get the result I want??!

many thanks

mike http://www.nabble.com/file/p23562717/1.pdf 1.pdf 
-- 
View this message in context: 
http://www.nabble.com/Using-column-length-in-plot-gives-error-tp23562717p23562717.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.