Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent behavior with RData files #295

Closed
hliebert opened this issue Aug 16, 2022 · 1 comment
Closed

Inconsistent behavior with RData files #295

hliebert opened this issue Aug 16, 2022 · 1 comment

Comments

@hliebert
Copy link

hliebert commented Aug 16, 2022

I've stumbled upon some strange behavior today when comparing rio with the builtin load/save. I presume the first part where the object is not imported in the global environment is intentional. Is the second part related?

rio::export(iris, "test.RData")
save(iris, file = "test2.RData")

rio::import("test.RData") # doesn't actually import iris
load("test2.RData")       # imports iris

rm(iris)

load("test.RData")  # is named x
load("test2.RData") # is named iris
@chainsawriot
Copy link
Collaborator

chainsawriot commented Aug 28, 2023

@hliebert Thank you for reporting this. This behavior is intentional because rio::import() should (always) return a data frame. Rather than the side-effect of putting sometime to the current global environment.

The intended way to use rio::import() for .RData is like this (not very different from .RDS):

tempRdata <- tempfile(fileext = ".RData")
rio::export(iris, tempRdata)
newdata <- rio::import(tempRdata)
newdata

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants