Hello list,
I'm new to R and I have a problem :-) Below is what my data file that looks
like. I tried to import and contour this data by doing this:
cv_data <-
read.table("cv_data.csv",sep=",",header=TRUE)
attach(cv_data)
contour(x,y,z)
I get the error "Error in contour.default(x,y,z) : increasing 'x',
and 'y'
values expected" I can see that y is not increasing, but I don't know
how
to get this to work.
Thanks in advance for any help.
Bob
========================================================x, y, z
10, 0.1, 3
10, 0.2, 7
[snip]
10,1.0,5
20,0.1,12
20,0.2,4
[[alternative HTML version deleted]]
Please **READ** ?contour. x and y are the location of grid lines, z must be
a matrix. Your data are **not** of that form.
Bert Gunter
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On
Behalf Of Bob and Deb
Sent: Thursday, June 26, 2008 11:01 AM
To: r-help at r-project.org
Subject: [R] using contour() with x,y,z data?
Hello list,
I'm new to R and I have a problem :-) Below is what my data file that looks
like. I tried to import and contour this data by doing this:
cv_data <-
read.table("cv_data.csv",sep=",",header=TRUE)
attach(cv_data)
contour(x,y,z)
I get the error "Error in contour.default(x,y,z) : increasing 'x',
and 'y'
values expected" I can see that y is not increasing, but I don't know
how
to get this to work.
Thanks in advance for any help.
Bob
========================================================x, y, z
10, 0.1, 3
10, 0.2, 7
[snip]
10,1.0,5
20,0.1,12
20,0.2,4
[[alternative HTML version deleted]]
______________________________________________
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.
"Bob and Deb" <bobdebm at gmail.com> writes:> I'm new to R and I have a problem :-) Below is what my data file that looks > like. I tried to import and contour this data by doing this: > > cv_data <- read.table("cv_data.csv",sep=",",header=TRUE) > attach(cv_data) > contour(x,y,z) > > I get the error "Error in contour.default(x,y,z) : increasing 'x', and 'y' > values expected" I can see that y is not increasing, but I don't know how > to get this to work.All of your arguments to contour are wrong. x and y are the locations of the gridlines for the figure (and are not required), and z is a matrix of values, not a single vector. See ?contour for the details and examples. I'm sure there is a better way to do this, but when I have data in the format you do: x y z 10, 0.1, 3 10, 0.2, 7 [snip] 10, 1.0, 5 20, 0.1, 12 20, 0.2, 4 I use the following function to convert it to the proper format: image.maker <- function(coords, value){ N <- length(unique(coords[,1])) image.out <- matrix(NA, nrow = N, ncol = N) coords[,1] <- as.numeric(factor(coords[,1])) coords[,2] <- as.numeric(factor(coords[,2])) for (i in 1:nrow(coords)) image.out[coords[i,1], coords[i,2]] <- value[i] return(image.out) } my.image <- image.maker(cv_data[,c("x", "y")], cv_data$z) contour(my.image) HTH, Tyler -- Power corrupts. PowerPoint corrupts absolutely. --Edward Tufte http://www.wired.com/wired/archive/11.09/ppt2.html
Hi you probably want to look to interp from arima package Petr Pikal petr.pikal at precheza.cz 724008364, 581252140, 581252257 r-help-bounces at r-project.org napsal dne 26.06.2008 20:00:48:> Hello list, > > I'm new to R and I have a problem :-) Below is what my data file thatlooks> like. I tried to import and contour this data by doing this: > > cv_data <- read.table("cv_data.csv",sep=",",header=TRUE) > attach(cv_data) > contour(x,y,z) > > I get the error "Error in contour.default(x,y,z) : increasing 'x', and'y'> values expected" I can see that y is not increasing, but I don't knowhow> to get this to work. > > Thanks in advance for any help. > > Bob > ========================================================> x, y, z > 10, 0.1, 3 > 10, 0.2, 7 > [snip] > 10,1.0,5 > 20,0.1,12 > 20,0.2,4 > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.