objNameToList() on some particular list of objects in parent frame
1
0
Entering edit mode
urwaCFC • 0
@urwacfc-12905
Last seen 7.7 years ago
Pakistan/Lahore/UETLahore

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"))}
rm(i);rm(pathways);
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.

Thanks!

tkWidgets xml kegggraph • 1.1k views
ADD COMMENT
0
Entering edit mode
@james-w-macdonald-5106
Last seen 3 days ago
United States

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

arguments
    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.

ADD COMMENT

Login before adding your answer.

Traffic: 479 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