1

I am trying to load a data frame that is in .RData format. I am using load() as is presented here. When I get the object in my environment, it is loaded as a large function displaying the following output:

>  load("bsas_short.RData")
>  data
  function (..., list = character(), package = NULL, lib.loc = NULL, 
     verbose = getOption("verbose"), envir = .GlobalEnv)

I wonder why it is loading as a large function object instead of a data.frame.

Edu
  • 903
  • 6
  • 17
  • 4
    ``data`` is a function in the utils package. If no other object with the same name is in the environment this function will be displayed. You could check all objects in the local environment with ``ls()``. Maybe your data is there, but has another name. – Phann Jul 03 '18 at 06:27
  • Thanks, Phann. I did that but the only object I have is data. There should be "bias_short" but does not seem to load properly. – Edu Jul 03 '18 at 06:31
  • 1
    Can save a `.RDS` of your data object?. If so, then you can import it with any desired name. – patL Jul 03 '18 at 06:36
  • 2
    That is strange. You could try ``getAnywhere("data")`` to see all objects named ``data``. You can check the class of data with ``class(data)`` (which will probably return ``function`` as that is would you obviously see in the current environment). Maybe the ``.RData`` is broken, but I cannot reproduce that. – Phann Jul 03 '18 at 06:38
  • This was my first guess but the data it is not. I have loaded in another machine (PC) and works. – Edu Jul 03 '18 at 06:46

1 Answers1

0

To import the RData file and perform operations on it (such as View or other queries) do:

df <- get(load("bsas_short.RData"))
LN_P
  • 1,448
  • 4
  • 21
  • 37
  • While this code snippet may be the solution, [including an explanation](https://meta.stackexchange.com/questions/114762/explaining-entirely-%E2%80%8C%E2%80%8Bcode-based-answers) really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion. – Narendra Jadhav Jul 04 '18 at 04:52