I'm wondering if there is any option available in load() such that I can specify which variable I want to load from an RData file. I don't see such option in the help.
How to load a specific variable from an RData file?
6 messages · Peng Yu, jim holtman, Charlie Sharpsteen
Create an environment, load the RData file into the environment, copy over the items of interest, delete the environment.
e1 <- new.env()
load("gold.RData", e1)
ls()
[1] "e1"
ls(e1)
[1] "a.mark" "aisleRange" "allSlots" "balanced" [5] "baseSlots" "box.offset" "case2cube" "case2desc" [9] "caseupc2upc" "ClassifyCommodity" "colToUse" "comm.gold" [13] "comm_map" "comm2desc" "commOrder" "createBay" [17] "D_slots.save" "DoubleCutoff" "f.assignDouble" "f.assignSingle" [21] "f.bayCheck" "f.checkForGrowthSlot" "f.getBay" "f.removeSlot" [25] "f.slotNum" "f.sortSlots" "firstSlot" "gold.comm" [29] "growthInc" "i" "KLN2comm" "KLN2cpq" [33] "KLN2cube" "KLN2desc" "KLN2slot" "KLN2upc" [37] "missingQuads" "nfree" "nSlots" "r.size" [41] "rankComm" "realign" "report" "reslotAisles" [45] "s.lower" "s.mat" "S_slots.save" "sa.m" [49] "save.opt" "save.slots" "setupSlots" "slotAssignments" [53] "slots" "slotSize" "slotsUsed" "slotWork" [57] "topSlots" "total" "total.split" "upc2comm" [61] "upc2crush" "upc2cube" "upc2desc" "upc2KLN" [65] "upc2slot" "upc2weight" "upcDesc" "vol.report" [69] "wh.reslot" "x.aisle" "x.m"
nfree <- get('nfree', e1)
ls() # now it is in the global workspace.
[1] "e1" "nfree"
On Thu, Nov 5, 2009 at 6:43 PM, Peng Yu <pengyu.ut at gmail.com> wrote:
I'm wondering if there is any option available in load() such that I can specify which variable I want to load from an RData file. I don't see such option in the help.
______________________________________________ R-help at 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.
Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve?
Thank you. When the RData file is huge, it will take a long time to load it even though I may only need a small variable. Could somebody add an option to 'load()' to load only a few given variables?
On Thu, Nov 5, 2009 at 5:58 PM, jim holtman <jholtman at gmail.com> wrote:
Create an environment, load the RData file into the environment, copy over the items of interest, delete the environment.
e1 <- new.env()
load("gold.RData", e1)
ls()
[1] "e1"
ls(e1)
?[1] "a.mark" ? ? ? ? ? ? ? "aisleRange" ? ? ? ? ? "allSlots" ? "balanced" ?[5] "baseSlots" ? ? ? ? ? ?"box.offset" ? ? ? ? ? "case2cube" ? "case2desc" ?[9] "caseupc2upc" ? ? ? ? ?"ClassifyCommodity" ? ?"colToUse" ? "comm.gold" [13] "comm_map" ? ? ? ? ? ? "comm2desc" ? ? ? ? ? ?"commOrder" ? "createBay" [17] "D_slots.save" ? ? ? ? "DoubleCutoff" ? ? ? ? "f.assignDouble" ? "f.assignSingle" [21] "f.bayCheck" ? ? ? ? ? "f.checkForGrowthSlot" "f.getBay" ? "f.removeSlot" [25] "f.slotNum" ? ? ? ? ? ?"f.sortSlots" ? ? ? ? ?"firstSlot" ? "gold.comm" [29] "growthInc" ? ? ? ? ? ?"i" ? ? ? ? ? ? ? ? ? ?"KLN2comm" ? "KLN2cpq" [33] "KLN2cube" ? ? ? ? ? ? "KLN2desc" ? ? ? ? ? ? "KLN2slot" ? "KLN2upc" [37] "missingQuads" ? ? ? ? "nfree" ? ? ? ? ? ? ? ?"nSlots" ? "r.size" [41] "rankComm" ? ? ? ? ? ? "realign" ? ? ? ? ? ? ?"report" ? "reslotAisles" [45] "s.lower" ? ? ? ? ? ? ?"s.mat" ? ? ? ? ? ? ? ?"S_slots.save" ? "sa.m" [49] "save.opt" ? ? ? ? ? ? "save.slots" ? ? ? ? ? "setupSlots" ? "slotAssignments" [53] "slots" ? ? ? ? ? ? ? ?"slotSize" ? ? ? ? ? ? "slotsUsed" ? "slotWork" [57] "topSlots" ? ? ? ? ? ? "total" ? ? ? ? ? ? ? ?"total.split" ? "upc2comm" [61] "upc2crush" ? ? ? ? ? ?"upc2cube" ? ? ? ? ? ? "upc2desc" ? "upc2KLN" [65] "upc2slot" ? ? ? ? ? ? "upc2weight" ? ? ? ? ? "upcDesc" ? "vol.report" [69] "wh.reslot" ? ? ? ? ? ?"x.aisle" ? ? ? ? ? ? ?"x.m"
nfree <- get('nfree', e1)
ls() ?# now it is in the global workspace.
[1] "e1" ? ?"nfree" On Thu, Nov 5, 2009 at 6:43 PM, Peng Yu <pengyu.ut at gmail.com> wrote:
I'm wondering if there is any option available in load() such that I can specify which variable I want to load from an RData file. I don't see such option in the help.
______________________________________________ R-help at 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.
-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve?
Peng Yu wrote:
Thank you. When the RData file is huge, it will take a long time to load it even though I may only need a small variable. Could somebody add an option to 'load()' to load only a few given variables?
Check out the "filehash" package. It has an option that allows you to store variables in single-file databases just like RData files. However, with filehash data files, you can pick and choose which variables to load. Hope this helps! -Charlie ----- Charlie Sharpsteen Undergraduate Environmental Resources Engineering Humboldt State University
View this message in context: http://old.nabble.com/How-to-load-a-specific-variable-from-an-RData-file--tp26224416p26225433.html Sent from the R help mailing list archive at Nabble.com.
On Thu, Nov 5, 2009 at 5:58 PM, jim holtman <jholtman at gmail.com> wrote:
Create an environment, load the RData file into the environment, copy over the items of interest, delete the environment.
e1 <- new.env()
load("gold.RData", e1)
ls()
[1] "e1"
ls(e1)
?[1] "a.mark" ? ? ? ? ? ? ? "aisleRange" ? ? ? ? ? "allSlots" ? "balanced" ?[5] "baseSlots" ? ? ? ? ? ?"box.offset" ? ? ? ? ? "case2cube" ? "case2desc" ?[9] "caseupc2upc" ? ? ? ? ?"ClassifyCommodity" ? ?"colToUse" ? "comm.gold" [13] "comm_map" ? ? ? ? ? ? "comm2desc" ? ? ? ? ? ?"commOrder" ? "createBay" [17] "D_slots.save" ? ? ? ? "DoubleCutoff" ? ? ? ? "f.assignDouble" ? "f.assignSingle" [21] "f.bayCheck" ? ? ? ? ? "f.checkForGrowthSlot" "f.getBay" ? "f.removeSlot" [25] "f.slotNum" ? ? ? ? ? ?"f.sortSlots" ? ? ? ? ?"firstSlot" ? "gold.comm" [29] "growthInc" ? ? ? ? ? ?"i" ? ? ? ? ? ? ? ? ? ?"KLN2comm" ? "KLN2cpq" [33] "KLN2cube" ? ? ? ? ? ? "KLN2desc" ? ? ? ? ? ? "KLN2slot" ? "KLN2upc" [37] "missingQuads" ? ? ? ? "nfree" ? ? ? ? ? ? ? ?"nSlots" ? "r.size" [41] "rankComm" ? ? ? ? ? ? "realign" ? ? ? ? ? ? ?"report" ? "reslotAisles" [45] "s.lower" ? ? ? ? ? ? ?"s.mat" ? ? ? ? ? ? ? ?"S_slots.save" ? "sa.m" [49] "save.opt" ? ? ? ? ? ? "save.slots" ? ? ? ? ? "setupSlots" ? "slotAssignments" [53] "slots" ? ? ? ? ? ? ? ?"slotSize" ? ? ? ? ? ? "slotsUsed" ? "slotWork" [57] "topSlots" ? ? ? ? ? ? "total" ? ? ? ? ? ? ? ?"total.split" ? "upc2comm" [61] "upc2crush" ? ? ? ? ? ?"upc2cube" ? ? ? ? ? ? "upc2desc" ? "upc2KLN" [65] "upc2slot" ? ? ? ? ? ? "upc2weight" ? ? ? ? ? "upcDesc" ? "vol.report" [69] "wh.reslot" ? ? ? ? ? ?"x.aisle" ? ? ? ? ? ? ?"x.m"
nfree <- get('nfree', e1)
ls() ?# now it is in the global workspace.
[1] "e1" ? ?"nfree"
How to remove the environment 'e1' after I get 'nfree'?
On Thu, Nov 5, 2009 at 6:43 PM, Peng Yu <pengyu.ut at gmail.com> wrote:
I'm wondering if there is any option available in load() such that I can specify which variable I want to load from an RData file. I don't see such option in the help.
______________________________________________ R-help at 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.
-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve?
Peng Yu wrote:
How to remove the environment 'e1' after I get 'nfree'?
Did you try rm( e1 ) ? ----- Charlie Sharpsteen Undergraduate Environmental Resources Engineering Humboldt State University
View this message in context: http://old.nabble.com/How-to-load-a-specific-variable-from-an-RData-file--tp26224416p26226191.html Sent from the R help mailing list archive at Nabble.com.