objNameToList() on some particular list of objects in parent frame
Entering edit mode
urwaCFC • 0
Last seen 6.6 years ago

This is what I am doing:

  • Extract 112 xml files names from my working directory into a list.
  • Convert xml files into graphs.
  • Create a list of all those xml files
  • Merge all those graphNEL objects into one big graphNEL object

Here is my code:

rm(list = ls())
pathways = list.files(pattern="*.xml")
for (i in 1:length(pathways)){ 
  assign(pathways[i], parseKGML2Graph(pathways[i],expandGenes=TRUE, genesOnly = "TRUE"))}
pathways<-objNameToList(objects(), parent.frame())
mergedPathways_u <- ugraph(mergeKEGGgraphs(pathways, edgemode = "directed"))

The problem is when I use objNameToList I have to ensure there are no other objects in my R environment other than xml files which I do by using rm(list = ls()). Is there a way around this? Is it possible to list only those 112 graphNEL objects. The rest of the data is used later and I have to load it again and that would require writing it in files which I don't want to do.


tkWidgets xml kegggraph • 811 views
Entering edit mode
Last seen 3 hours ago
United States

Yes, there is a way around this. Note that you could have answered this yourself by simply reading the help page:

    objNames  character vector giving the names of objects.

You are using the function objects to list the names of everything in your global environment, in which case you obviously need to remove everything that is in your global environment that you don't want to use. You could alternatively just generate a character vector of the things you do want to use, which seems to be a more directed way of doing things.


Login before adding your answer.

Traffic: 380 users visited in the last hour
Help About
Access RSS

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

Powered by the version 2.3.6