Question

I need to feed an R code with a vector from an external source and be fast, so I want to avoid reading generic files, such as csv. I thought that writing outside R a RDS file could be a good idea.

Is there any library or wrapper in C, C++, Python, Perl able to write in RDS format?

P.S. If you know a better way, other than RDS, suggestions are welcome.

Était-ce utile?

La solution

Have you used ??

??rds  # brings up ...
?readRDS   # from the base package.

(You perhaps want to adapt the code from .Internal(serialize, ...)?)

Autres conseils

You could use rpy2 in Python. I use the following in python3:

import pandas as pd
import rpy2.robjects as robjects
saveRDS = robjects.r['saveRDS']
saveRDS(pd_dataframe, 'data.rds')
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top