traversc / qs

Quick serialization of R objects
397 stars 19 forks source link

Unexpected behavior when loading .qs file #84

Closed svenb78 closed 1 year ago

svenb78 commented 1 year ago

Hi,

given the following minimal example:

tmp01 <- data.frame(
  x1 = rnorm(1000)
  , x2 = rnorm(1000)
)

qs::qsave(tmp01, file = "tmp01.qs")

If I use qs::qload(file = "tmp01.qs") for re-loading the data, I get each column, x1and x2, as a single object. If I use tmp02 <- qs::qload(file = "tmp01.qs"), I additionally get an environment tmp02. I never saw that before.

If I use qs::qsavem(tmp01, file = "tmp01.qs") instead, qs::qload(file = "tmp01.qs") re-loads the data frame tmp01as expected.

What is going on here?

svenb78 commented 1 year ago

Hmm ... perhaps I mixed up qloadand qread. Sorry for that. But what is the difference?

traversc commented 1 year ago

Hi, yes qload and qread are different. The base R comparables are load and readRDS.

qload will take a list in a file and put it into the global environment. qread will return an object in a file e.g. tmp02 <- qread("tmp01.qs")