[R] Using column length in plot gives error
skoval at ucla.edu
Sun May 17 03:59:03 CEST 2009
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 <mike at hsm.org.uk>:
> 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)",
> it looks good (left hand plot). If I try something like:
> cormat, type = "l", ylim=c(-1,1), xlab="Wavelength (nm)",
> it fails with "variable lengths differ" and when I look at
> spectra.wavelength it gives me the value but then states there are 53
> 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:
> Sent from the R help mailing list archive at Nabble.com.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help