[R] Beginner Question on Persp()

David Barron mothsailor at googlemail.com
Mon Feb 5 15:01:33 CET 2007


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. <tom.hatfield at ae.ctscorp.com> 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 at 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



More information about the R-help mailing list