Home > Mobile >  How to turn an *.RDS file into a *.FEATHER file?
How to turn an *.RDS file into a *.FEATHER file?

Time:01-22

I am trying to covert an *.rds file in R into a *.feather file for use in Python.

library(feather)
data = readRDS("file.rds")
write_feather(data,"file.feather")

However, I receive the following error:

> write_feather(data,"file.feather")
Error: `x` must be a data frame

How can I turn the *.rds file/matrix into a *.feather file to read with Pandas (or any other Pandas-compatible file that can handle a 24000*24000 matrix)?

enter image description here

CodePudding user response:

Coerce matrix obeject to data.frame object:

library(feather)
data = readRDS("file.rds")
as.data.frame(as.matrix(data))
write_feather(data,"file.feather")

CodePudding user response:

It's very simple in fact, you can convert only dataframes and you have to name your file: Use:

data = data.frame(data)

Now use the function and it should work:

write_feather(data,"file.feather")
  •  Tags:  
  • Related