An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20110805/ac7ea234/attachment.pl>
Grouping "linked" points
3 messages · mattc0, Thomas Pengo, Ben Madin
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20110805/3ad265b6/attachment.pl>
Matthew, You might want to look at the graphing packages for this - network, sna, igraph will all help you. What you are describing is probably best thought of as an edgelist, so if using a function such as as.network() you may need to specify that it is 'edgelist'. example code might look like : (note I'm using a data frame for your data, and the id (row name) will become the vertex.names attribute)
library(network)
Classes for Relational Data
Version 1.7 created on July 7, 2011.
copyright (c) 2005, Carter T. Butts, University of California-Irvine
Mark S. Handcock, University of Washington
David R. Hunter, Penn State University
Martina Morris, University of Washington
For citation information, type citation("network").
Type help("network-package") to get started.
links <- data.frame(rbind(c(5,3),c(10,16),c(20,1),c(19,8),c(19,1),c(7,11),c(11,13),c(4,13),c(15,20),c(16,2),c(13,7),c(14,16),c(11,8),c(16,12),NULL,NULL,c(12,14),NULL,c(4,5),NULL)) g <- network(links) list.vertex.attributes(g)
[1] "na" "vertex.names"
get.vertex.attribute(g,"vertex.names")
[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
plot(g) ?network
cheers Ben
On 05/08/2011, at 1:51 PM, mattc0 wrote:
Hi, I have a list of the links shared by n points. Each element of the list represents the ID of a point and the entries for each element indicate the ID's of the points that it is linked with. I would like to group points via their ID's based on these links. There are an unknown number of groups and some points do not share any links. I would be grateful for any assistance in pointing me towards a solution. An example list of 20 points with two links for each point is given below. links <- list(c(5,3),c(10,16),c(20,1),c(19,8),c(19,1),c(7,11),c(11,13),c(4,13),c(15,20),c(16,2),c(13,7),c(14,16),c(11,8),c(16,12),NULL,NULL,c(12,14),NULL,c(4,5),NULL) Thanks in advance, Matthew Cracknell PhD. Candidate ARC Centre of Excellence in Ore Deposits University of Tasmania Private Bag 79 Hobart, 7001 Australia Mob: 0409438924 [[alternative HTML version deleted]]
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo