[R] How to load a specific variable from an RData file?

Peng Yu pengyu.ut at gmail.com
Fri Nov 6 02:16:24 CET 2009


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?
>




More information about the R-help mailing list