How to see data from .RData file?

后端 未结 8 1746
梦谈多话
梦谈多话 2020-11-29 02:23

I saw some similar qestions and I tried to work it out on my own, but I couldn\'t. This is my problem:

I have to load a isfar.RData file to use it in other computati

相关标签:
8条回答
  • 2020-11-29 02:40

    you can try

    isfar <- get(load('c:/users/isfar.Rdata'))

    this will assign the variable in isfar.Rdata to isfar . After this assignment, you can use str(isfar) or ls(isfar) or head(isfar) to get a rough look of the isfar.

    0 讨论(0)
  • 2020-11-29 02:42

    I think the problem is that you load isfar data.frame but you overwrite it by value returned by load.

    Try either:

    load("C:/Users/isfar.RData") 
    head(isfar)
    

    Or more general way

    load("C:/Users/isfar.RData", ex <- new.env())
    ls.str(ex) 
    
    0 讨论(0)
  • 2020-11-29 02:44

    You can also import the data via the "Import Dataset" tab in RStudio, under "global environment." Use the text data option in the drop down list and select your .RData file from the folder. Once the import is complete, it will display the data in the console. Hope this helps.

    0 讨论(0)
  • 2020-11-29 02:47
    isfar<-load("C:/Users/isfar.RData") 
    if(is.data.frame(isfar)){
       names(isfar)
    }
    

    If isfar is a dataframe, this will print out the names of its columns.

    0 讨论(0)
  • 2020-11-29 02:48

    If you have a lot of variables in your Rdata file and don't want them to clutter your global environment, create a new environment and load all of the data to this new environment.

    load(file.path("C:/Users/isfar.RData"), isfar_env <- new.env() )
    
    # Access individual variables in the RData file using '$' operator
    isfar_env$var_name 
    
    # List all of the variable names in RData:
    ls(isfar_env)
    
    0 讨论(0)
  • 2020-11-29 02:51

    This may fit better as a comment but I don't have enough reputation, so I put it here.
    It worth mentioning that the load() function will retain the object name that was originally saved no matter how you name the .Rdata file.

    Please check the name of the data.frame object used in the save() function. If you were using RStudio, you could check the upper right panel, Global Environment-Data, to find the name of the data you load.

    0 讨论(0)
提交回复
热议问题