David 1. The last line of the code should have been ...
Output = as.data.frame(do.call(rbind,nn)) # Output Node Connect.up Connect.down 1 1 NULL 2, 3 2 2 1 4, 5 3 3 NULL 2, 3 4 4 1 4, 5 Apologies for any confusion 2. I am not familiar with the diagram package or the examples you describe. Why the desire to create a data frame? Why not just use a list? HTH Pete dkStevens wrote > > Thanks for the reply. Two things - I must have something missing because > copying and pasting your example gave me an error > > ... your definitions of nn > > Output = do.call(as.data.frame(rbind),nn) > > Error in as.data.frame.default(rbind) : > cannot coerce class '"function"' into a data.frame > > The second is the need, and why I'm not sure this is the best way. This > is to customize the flow charting library code from the library > 'diagram' to use a node-and-link characterization of a network - think > PERT charts or perhaps linking river segments in a water quality model. > Each Node will be a, say, circle and has attributes of being connected > up to one or more upstream nodes and down to one or more downstream > nodes. So the Connect.up column is a vector up upstream connections, > usually one but sometimes > one, and likewise Connect.down. There is an > accompanying table of links with attributes of which nodes are at each > end of a link and other metadata that describe the link (e.g. the length > of time required to traverse the link, its name etc. That said, my > thought was that the situation was too simple to fire up a full-blown > object system beyond what R provides natively. I guess it's like making > a data frame that has some 3-d elements. > > > > On 2/3/2012 9:32 PM, Pete Brecknock wrote: >> nn=list() >> >> nn[[1]] = list(Node = "1", Connect.up = c(NULL), Connect.down = c(2,3)) >> nn[[2]] = list(Node = "2", Connect.up = c(1), Connect.down = c(4,5)) >> nn[[3]] = list(Node = "3", Connect.up = c(NULL), Connect.down = c(2,3)) >> nn[[4]] = list(Node = "4", Connect.up = c(1), Connect.down = c(4,5)) >> >> Output = do.call(as.data.frame(rbind),nn) > > -- > David K Stevens, P.E., Ph.D., Professor > Civil and Environmental Engineering > Utah Water Research Laboratory > 8200 Old Main Hill > Logan, UT 84322-8200 > 435 797 3229 - voice > 435 797 1363 - fax > david.stevens@ > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@ 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. > -- View this message in context: http://r.789695.n4.nabble.com/combining-data-structures-tp4356288p4358435.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org 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.