Example of converting graphNEL object to ajacency matrix?
2
0
Entering edit mode
@zembower-kevin-2767
Last seen 10.2 years ago
I'm interested in converting the graphNEL objects in the package SNAData into adjacency matrices, so that I can convert them into 'network' objects and use the R package 'sna' to analyze them. I'm working through the examples in Wasserman and Faust, Social Network Analysis, and these datasets will save me considerable typing. I think that this is possible because of references to the 'coerce' method on the graphNEL-class and graphAM-class help pages, but I haven't been successful. I've tried commands like: coerce(friendship, fs-mat) coerce(friendship, fsmat) as.matrix(friendship) as.graphAM(friendship) coerce(from="friendship", to="fsmat") Can anyone give me an example of converting a graphNEL object to a regular matrix, such as an adjacency matrix? I think with just one example, I could work things out. Thanks for your advice and suggestions. -Kevin Kevin Zembower Internet Services Group manager Center for Communication Programs Bloomberg School of Public Health Johns Hopkins University 111 Market Place, Suite 310 Baltimore, Maryland 21202 410-659-6139
Network convert Network convert • 1.5k views
ADD COMMENT
0
Entering edit mode
rgentleman ★ 5.5k
@rgentleman-7725
Last seen 9.6 years ago
United States
Hi, Zembower, Kevin wrote: > I'm interested in converting the graphNEL objects in the package SNAData > into adjacency matrices, so that I can convert them into 'network' > objects and use the R package 'sna' to analyze them. I'm working through > the examples in Wasserman and Faust, Social Network Analysis, and these > datasets will save me considerable typing. Why not just analyze them with the tools in RBGL (which are a bit more extensive than those in sna)? > > I think that this is possible because of references to the 'coerce' > method on the graphNEL-class and graphAM-class help pages, but I haven't > been successful. I've tried commands like: > coerce(friendship, fs-mat) > coerce(friendship, fsmat) > as.matrix(friendship) > as.graphAM(friendship) > coerce(from="friendship", to="fsmat") I am a bit confused about how you got to any of these incantations. The man page for coerce (as) is pretty explicit about needing to specify the input, and the name of the desired class, so my first guess would have been: as(friendship, "matrix") which does indeed seem to work. Robert > > Can anyone give me an example of converting a graphNEL object to a > regular matrix, such as an adjacency matrix? I think with just one > example, I could work things out. > > Thanks for your advice and suggestions. > > -Kevin > > Kevin Zembower > Internet Services Group manager > Center for Communication Programs > Bloomberg School of Public Health > Johns Hopkins University > 111 Market Place, Suite 310 > Baltimore, Maryland 21202 > 410-659-6139 > > _______________________________________________ > Bioconductor mailing list > Bioconductor at stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor > -- Robert Gentleman, PhD Program in Computational Biology Division of Public Health Sciences Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N, M2-B876 PO Box 19024 Seattle, Washington 98109-1024 206-667-7700 rgentlem at fhcrc.org
ADD COMMENT
0
Entering edit mode
Robert and Gabor, thanks so much for writing and helping me. Both suggestions will be very helpful. Robert, with regard to RBGL, I didn't consider this because I'm not very knowledgeable about projects in the Bioconductor system. In fact, my only interest was caused by Googling 'krackhardt' and discovering his data in the SNAData package. I've never heard of RBGL, but Googling it just now returns a page with "Description: demo of interface with full copy of all hpp defining boost." From this description, I don't think that I would have known that this has anything to do with Social Network Analysis. I've printed the manual for RBGL and will investigate it for my use. Thanks for suggesting this. I also didn't know that 'as' was an alias for 'coerce.' Thank you so much for pointing this out, and for your example. All of this is really helpful. -Kevin -----Original Message----- From: Robert Gentleman [mailto:rgentlem@fhcrc.org] Sent: Thursday, April 24, 2008 9:29 AM To: Zembower, Kevin Cc: bioconductor at stat.math.ethz.ch Subject: Re: [BioC] Example of converting graphNEL object to ajacency matrix? Hi, Zembower, Kevin wrote: > I'm interested in converting the graphNEL objects in the package SNAData > into adjacency matrices, so that I can convert them into 'network' > objects and use the R package 'sna' to analyze them. I'm working through > the examples in Wasserman and Faust, Social Network Analysis, and these > datasets will save me considerable typing. Why not just analyze them with the tools in RBGL (which are a bit more extensive than those in sna)? > > I think that this is possible because of references to the 'coerce' > method on the graphNEL-class and graphAM-class help pages, but I haven't > been successful. I've tried commands like: > coerce(friendship, fs-mat) > coerce(friendship, fsmat) > as.matrix(friendship) > as.graphAM(friendship) > coerce(from="friendship", to="fsmat") I am a bit confused about how you got to any of these incantations. The man page for coerce (as) is pretty explicit about needing to specify the input, and the name of the desired class, so my first guess would have been: as(friendship, "matrix") which does indeed seem to work. Robert > > Can anyone give me an example of converting a graphNEL object to a > regular matrix, such as an adjacency matrix? I think with just one > example, I could work things out. > > Thanks for your advice and suggestions. > > -Kevin > > Kevin Zembower > Internet Services Group manager > Center for Communication Programs > Bloomberg School of Public Health > Johns Hopkins University > 111 Market Place, Suite 310 > Baltimore, Maryland 21202 > 410-659-6139 > > _______________________________________________ > Bioconductor mailing list > Bioconductor at stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor > -- Robert Gentleman, PhD Program in Computational Biology Division of Public Health Sciences Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N, M2-B876 PO Box 19024 Seattle, Washington 98109-1024 206-667-7700 rgentlem at fhcrc.org
ADD REPLY
0
Entering edit mode
Zembower, Kevin wrote: > Robert and Gabor, thanks so much for writing and helping me. Both > suggestions will be very helpful. > > Robert, with regard to RBGL, I didn't consider this because I'm not very > knowledgeable about projects in the Bioconductor system. In fact, my > only interest was caused by Googling 'krackhardt' and discovering his > data in the SNAData package. I've never heard of RBGL, but Googling it > just now returns a page with "Description: demo of interface with full > copy of all hpp defining boost." From this description, I don't think > that I would have known that this has anything to do with Social Network > Analysis. I've printed the manual for RBGL and will investigate it for > my use. Thanks for suggesting this. Very good point, I had not noticed that the DESCRIPTION file had not changed since we began - hopefully it is now somewhat more descriptive. You should be able to virtually everything in Wasserman and Faust from RBGL - I would be happy to hear about things that do not work, or where the implementation is not obvious. best wishes Robert > > I also didn't know that 'as' was an alias for 'coerce.' Thank you so > much for pointing this out, and for your example. All of this is really > helpful. > > -Kevin > > -----Original Message----- > From: Robert Gentleman [mailto:rgentlem at fhcrc.org] > Sent: Thursday, April 24, 2008 9:29 AM > To: Zembower, Kevin > Cc: bioconductor at stat.math.ethz.ch > Subject: Re: [BioC] Example of converting graphNEL object to ajacency > matrix? > > Hi, > > Zembower, Kevin wrote: >> I'm interested in converting the graphNEL objects in the package > SNAData >> into adjacency matrices, so that I can convert them into 'network' >> objects and use the R package 'sna' to analyze them. I'm working > through >> the examples in Wasserman and Faust, Social Network Analysis, and > these >> datasets will save me considerable typing. > > Why not just analyze them with the tools in RBGL (which are a bit > more extensive than those in sna)? > >> I think that this is possible because of references to the 'coerce' >> method on the graphNEL-class and graphAM-class help pages, but I > haven't >> been successful. I've tried commands like: >> coerce(friendship, fs-mat) >> coerce(friendship, fsmat) >> as.matrix(friendship) >> as.graphAM(friendship) >> coerce(from="friendship", to="fsmat") > > I am a bit confused about how you got to any of these incantations. > The man page for coerce (as) is pretty explicit about needing to specify > > the input, and the name of the desired class, so my first guess would > have been: > > as(friendship, "matrix") > > which does indeed seem to work. > > Robert > >> Can anyone give me an example of converting a graphNEL object to a >> regular matrix, such as an adjacency matrix? I think with just one >> example, I could work things out. >> >> Thanks for your advice and suggestions. >> >> -Kevin >> >> Kevin Zembower >> Internet Services Group manager >> Center for Communication Programs >> Bloomberg School of Public Health >> Johns Hopkins University >> 111 Market Place, Suite 310 >> Baltimore, Maryland 21202 >> 410-659-6139 >> >> _______________________________________________ >> Bioconductor mailing list >> Bioconductor at stat.math.ethz.ch >> https://stat.ethz.ch/mailman/listinfo/bioconductor >> Search the archives: > http://news.gmane.org/gmane.science.biology.informatics.conductor > -- Robert Gentleman, PhD Program in Computational Biology Division of Public Health Sciences Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N, M2-B876 PO Box 19024 Seattle, Washington 98109-1024 206-667-7700 rgentlem at fhcrc.org
ADD REPLY
0
Entering edit mode
@gabor-csardi-2729
Last seen 20 months ago
Spain
An embedded and charset-unspecified text was scrubbed... Name: not available Url: https://stat.ethz.ch/pipermail/bioconductor/attachments/20080424/ 2000d8a8/attachment.pl
ADD COMMENT

Login before adding your answer.

Traffic: 774 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6