[R] Beginner Question on Persp()

2007-02-05 Thread Tom H.

I recently downloaded R for Windows, running on Win XP.  I'm trying to create
a perspective plot but not having any luck after reading the R manual and
several examples found on the Internet.

I have a 100 x 100 matrix of Z data as a tab-delimited text file exported
from Minitab.  I read this in to R using read.delim; this seemed to go ok. 
I created  X and Y using seq() to get 100 divisions for the X and Y axes. 
Again, everything looked good, when I typed X or Y I got a string of 100
numbers.

However, when I try to do persp(x,y,z) I get an error something like: (list)
cannot be coerced to double.  I know the basic data (matrix of z values) is
ok (no hidden non-numeric values) because Minitab will graph it just fine. 
Any suggestions on how to proceed?  Thanks in advanced for your help.
-- 
View this message in context: 
http://www.nabble.com/Beginner-Question-on-Persp%28%29-tf3174399.html#a8806483
Sent from the R help mailing list archive at Nabble.com.

__
R-help@stat.math.ethz.ch 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] Beginner Question on Persp()

2007-02-05 Thread Peter Dalgaard
Tom H. wrote:
 I recently downloaded R for Windows, running on Win XP.  I'm trying to create
 a perspective plot but not having any luck after reading the R manual and
 several examples found on the Internet.

 I have a 100 x 100 matrix of Z data as a tab-delimited text file exported
 from Minitab.  I read this in to R using read.delim; this seemed to go ok. 
 I created  X and Y using seq() to get 100 divisions for the X and Y axes. 
 Again, everything looked good, when I typed X or Y I got a string of 100
 numbers.

 However, when I try to do persp(x,y,z) I get an error something like: (list)
 cannot be coerced to double.  I know the basic data (matrix of z values) is
 ok (no hidden non-numeric values) because Minitab will graph it just fine. 
 Any suggestions on how to proceed?  Thanks in advanced for your help.
   
Data frames are not matrices. Presumably, you want as.matrix(z).

-- 
   O__   Peter Dalgaard Ă˜ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-help@stat.math.ethz.ch 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] Beginner Question on Persp()

2007-02-05 Thread David Barron
read.delim creates a data frame (which is a type of list), whereas
persp requires that the z argument be a matrix.  These are different
classes of object in R -- you might want to read the Introduction to R
that ships with the programme.  Try

persp(x,y,as.matrix(z))

On 05/02/07, Tom H. [EMAIL PROTECTED] wrote:

 I recently downloaded R for Windows, running on Win XP.  I'm trying to create
 a perspective plot but not having any luck after reading the R manual and
 several examples found on the Internet.

 I have a 100 x 100 matrix of Z data as a tab-delimited text file exported
 from Minitab.  I read this in to R using read.delim; this seemed to go ok.
 I created  X and Y using seq() to get 100 divisions for the X and Y axes.
 Again, everything looked good, when I typed X or Y I got a string of 100
 numbers.

 However, when I try to do persp(x,y,z) I get an error something like: (list)
 cannot be coerced to double.  I know the basic data (matrix of z values) is
 ok (no hidden non-numeric values) because Minitab will graph it just fine.
 Any suggestions on how to proceed?  Thanks in advanced for your help.
 --
 View this message in context: 
 http://www.nabble.com/Beginner-Question-on-Persp%28%29-tf3174399.html#a8806483
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@stat.math.ethz.ch 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.



-- 
=
David Barron
Said Business School
University of Oxford
Park End Street
Oxford OX1 1HP

__
R-help@stat.math.ethz.ch 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] Beginner Question on Persp()

2007-02-05 Thread rolf

Your ``z'' which was read in by read.delim() is a *data frame*
not a matrix.

Do z - as.matrix(z), then persp(x,y,z) will work.

cheers,

Rolf Turner
[EMAIL PROTECTED]

===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===+===

Original message:

 I recently downloaded R for Windows, running on Win XP.  I'm trying to create
 a perspective plot but not having any luck after reading the R manual and
 several examples found on the Internet.
 
 I have a 100 x 100 matrix of Z data as a tab-delimited text file exported
 from Minitab.  I read this in to R using read.delim; this seemed to go ok. 
 I created  X and Y using seq() to get 100 divisions for the X and Y axes. 
 Again, everything looked good, when I typed X or Y I got a string of 100
 numbers.
 
 However, when I try to do persp(x,y,z) I get an error something like: (list)
 cannot be coerced to double.  I know the basic data (matrix of z values) is
 ok (no hidden non-numeric values) because Minitab will graph it just fine. 
 Any suggestions on how to proceed?  Thanks in advanced for your help.

__
R-help@stat.math.ethz.ch 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] Beginner Question on Persp()

2007-02-05 Thread Petr Pikal
Hi

 x-1:100
 y-1:100
 z-rnorm(100*100)
 dim(z)-c(100,100)
 persp(x,y,z)

works ok
so problem is with your data. Z being OK in Minitab does not mean 
it is read OK to R.


On 5 Feb 2007 at 5:50, Tom H. wrote:

Date sent:  Mon, 5 Feb 2007 05:50:34 -0800 (PST)
From:   Tom H. [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Subject:[R] Beginner Question on Persp()

 
 I recently downloaded R for Windows, running on Win XP.  I'm trying to
 create a perspective plot but not having any luck after reading the R
 manual and several examples found on the Internet.
 
 I have a 100 x 100 matrix of Z data as a tab-delimited text file
 exported from Minitab.  I read this in to R using read.delim; this
 seemed to go ok. I created  X and Y using seq() to get 100 divisions

what does str(Z) says about your data?
z-list(z)
 persp(x,y,z)
Error in persp.default(x, y, z) : (list) object cannot be coerced to 
'double'

so although z looks like matrix it is actually list

 z1-z[[1]]
 persp(x,y,z1)

works again OK.

Based on structure of your data you need to extract a matrix for 
using it as z. See ?persp

HTH
Petr

BTW try to transfer it to R just by selection of data list in 
Minitab, pressing Ctrl-C, and using

z -  read.delim(clipboard)

in R. It works for me.

 for the X and Y axes. Again, everything looked good, when I typed X or
 Y I got a string of 100 numbers.
 
 However, when I try to do persp(x,y,z) I get an error something like:
 (list) cannot be coerced to double.  I know the basic data (matrix of
 z values) is ok (no hidden non-numeric values) because Minitab will
 graph it just fine. Any suggestions on how to proceed?  Thanks in
 advanced for your help. -- View this message in context:
 http://www.nabble.com/Beginner-Question-on-Persp%28%29-tf3174399.html#
 a8806483 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@stat.math.ethz.ch 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.

Petr Pikal
[EMAIL PROTECTED]

__
R-help@stat.math.ethz.ch 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] Beginner Question on Persp()

2007-02-05 Thread Tom H.

Thank you all for taking the time to point out that a data frame is not the
same as a matrix!  I'll give it another shot when I get home tonight.


-- 
View this message in context: 
http://www.nabble.com/Beginner-Question-on-Persp%28%29-tf3174399.html#a8807536
Sent from the R help mailing list archive at Nabble.com.

__
R-help@stat.math.ethz.ch 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] Beginner Question on Persp()

2007-02-05 Thread Tom H.



Tom H. wrote:
 
 I recently downloaded R for Windows, running on Win XP.  I'm trying to
 create a perspective plot but not having any luck after reading the R
 manual and several examples found on the Internet.
 
 I have a 100 x 100 matrix of Z data as a tab-delimited text file exported
 from Minitab.  I read this in to R using read.delim; this seemed to go ok. 
 I created  X and Y using seq() to get 100 divisions for the X and Y axes. 
 Again, everything looked good, when I typed X or Y I got a string of 100
 numbers.
 
 However, when I try to do persp(x,y,z) I get an error something like:
 (list) cannot be coerced to double.  I know the basic data (matrix of z
 values) is ok (no hidden non-numeric values) because Minitab will graph it
 just fine.  Any suggestions on how to proceed?  Thanks in advanced for
 your help.
 

-- 
View this message in context: 
http://www.nabble.com/Beginner-Question-on-Persp%28%29-tf3174399.html#a8807458
Sent from the R help mailing list archive at Nabble.com.

__
R-help@stat.math.ethz.ch 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.