Re: [R] Writing point pattern to a file

From: Barry Rowlingson <B.Rowlingson_at_lancaster.ac.uk>
Date: Wed 26 Oct 2005 - 18:17:21 EST

Ajit Chakrapani Warrier wrote:

> pp <- rpoispp(.01, win=owin(c(0,100),c(0,100)))

> 	But how can I export the generated point pattern to an external file so 
> that I could use it as input for some network simulation
> programs ? 

  You can get the coordinates of a point-pattern object with the $x and $y components. You can write to a file with R's 'write.table' function. So make the $x and $y components into a matrix, and use write.table. Here I'll use some write.table options to make a fairly clean file, coordinates separated by commas, with no row names, and nothing stuck in quote marks:

write.table(file="ppxy.csv",cbind(pp$x,pp$y),sep=",",row.names=FALSE,col.names=c('x','y'),quote=FALSE)

> Also, it seems that the generated graph is different on each
> invocation. Is there a way I could control this randomness, some seed
> perhaps.

See the help for 'set.seed' - type 'help(set.seed)'

Baz



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 Received on Wed Oct 26 18:22:23 2005

This archive was generated by hypermail 2.1.8 : Wed 26 Oct 2005 - 21:15:10 EST