[R] Inputting Co-ordinates
Sundar Dorai-Raj
sundar.dorai-raj at pdf.com
Wed May 8 20:51:17 CEST 2002
Louise,
See answer below:
>
> I am trying to input some co-ordinate sets into R of the form x,y by using
> lists. The command I am using is:
>
> p1 <- list(x=c(3445,563,646), y=c(234,567,456))
>
> However the actual co-ordinate sets that I am trying to input have 305
> points each and I think that the program will not accept a command that is
> as long as necessary. Is this so? If this is the case can you tell me how
> to read the points in as a table but so that I can call on them as being p1,
> later in the program?
Why not just place the points in a text file? E.g.
x, y
3445, 234
563, 567
646, 456
Save the last four lines into a text file called `coords.csv' (no
quotes).
In R, use the commands:
> p1 <- read.csv("coords.csv",header=T)
> p1
x y
1 3445 234
2 563 567
3 646 456
> p1$x
[1] 3445 563 646
> p1$y
[1] 234 567 456
> p1.list <- as.list(p1)
> p1.list
$x
[1] 3445 563 646
$y
[1] 234 567 456
>
See read.csv or read.table for more details.
Sundar
--
Sundar Dorai-Raj, Ph.D.
Statistical Methods Engineer
PDF Solutions, Inc.
Richardson TX
(972) 889-3085 x216
(214) 392-7619 cell
sundar.dorai-raj at pdf.com
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list