[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] Need for advice

From: Gábor Csárdi
Subject: Re: [igraph] Need for advice
Date: Thu, 8 May 2014 11:24:57 -0400

Hi Tom,

I would create an Rdata file that contains all the data, and a function that you can use to retrieve the graph you want. The graphs can be in some nested named list, grouped by the groups, type of question, etc., in an organization that is most logical for you. The retrieving function could be created with something like this:

get_graph <- (function() {
  env <- new.env()
  load("my-data-file-with-all-graphs.Rdata", envir=env)
  function(group, at, question) { env[["allgraphs"]][[group]][[at]][[question]] }

and then you can get your desired graph via get_graph(group="foo", at=1, question="advice"). 

The advantage of not using the list directly is that if you change the data format, file name, etc. you don't need to update the code. You can also make the retrieving function more flexible, e.g. to retrieve all time points for a question and group, etc.

The advantage of the closure trick (i.e. to return a function that will return the data, and then call it immediately) will make sure that you only load the file once from the disk, and that the object itself is hidden.


On Thu, May 8, 2014 at 5:44 AM, Tom Backer Johnsen <address@hidden> wrote:

I need some advice on handling a relatively large number of graphs in R.  What I have is 128 graphs representing eight groups (each with 8 to 11 members) at four times (repeats) where each subject was asked four types of questions.  In addition there are 20 groups which based on the same sample, each with from 3 to 6 members, tested at four points in time with the same set of questions.  So, there are 448 different graphs.

It was a fairly complex matter of entering the data from the original forms (the data are old, collected in 1967), so I have written a program in Lazarus (a Pascal GUI interface) which takes care of checking and anonymization, where the end product is (at present) a long text file containing the graphs in iGraph matrix format.  Other formats are possible, that is a minor matter.  Each graph has a short descriptive name.

I would prefer to use parts of iGraph (possibly other SNA packages as well) to analyse the structures using the R / RStudio interface.  I am quite used to handle R, but have very limited experience with iGraph.

So:  Having to operate with 448 different files seems to be cumbersome, but of course possible.  I would however prefer to have all the graphs in one database/file.  I seem to remember having seen a reference to SQLite in this list, but are there better/simpler alternatives?  How does one extract single graphs from the database?  It would also be an advantage if the data base could be generated by the program written in Lazarus / Free Pascal and then accessed by R, but that transfer could be handled in several ways.

Any suggestions?

I am using a Mac OS X computer, where something like Wine may be installed to be able to run Windows programs.

Tom Backer Johnsen
Email: backer(at)psych.uib.no

igraph-help mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]