I get an error when I try to read a R object from a RDS file which is located on an Arvados platform. First, I use the following code to connect to Arvados and get a file listing:
library('ArvadosR')
# Read ARVADOS_API_TOKEN and ARVADOS_API_HOST
readRenviron("~/.config/arvados/arv.conf")
# Connect to Arvados
arv = Arvados$new()
# Get collection object
coll = Collection$new(arv, "<collection_uuid>")
# List collection content
coll$getFileListing()
When I read a tab delimited file xyz.txt
with
df.a = read.delim(coll$get("xyz.txt")$connection("r"))
it works perfectly fine. However, when I try to read an RDS file abc.RDS
with
df.b = readRDS(coll$get("abc.RDS")$connection("r"))
I get the following error :
Error in readRDS(coll$get("abc.RDS")$connection("r")) :
unknown input format
Reading abc.RDS
from a local drive works fine. According to the help page, readRDS
accepts "a connection or the name of the file where the R object is saved to or read from".
I could make it work with readRDS(gzcon(coll$get("abc.RDS")$connection("rb")))
.
In help(readRDS)
I noticed this paragraph:
"Compression is handled by the connection opened when file
is a file name, so is only possible when file
is a connection if handled by the connection. So eg url
connections will need to be wrapped in a call to gzcon
."
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.