Reading and writing RData files
前面添加个lapply()或者dplyr::llply()就能读取,储存多个文件了。 http://bluemountaincapital.github.io/FSharpRProvider/reading-rdata.html |
Reading and writing RData files
When using R, you can save and load data sets as *.rdata
files. These can be easily exported and consumed using the R provider too, so if you want to perform part of your data acquisition, analysis and visualization using F# and another part using R, you can easily pass the data between F# and R as *.rdata
files.
Passing data from R to F#
Let's say that you have some data in R and want to pass them to F#. To do that, you can use the save
function in R. The following R snippet creates a simple *.rdata
file containing a couple of symbols from the sample volcano
data set:
1: |
|
To import the data on the F# side, you can use the RData
type provider that is available in the RProvider
namespace. It takes a static parameter specifying the path of the file (absolute or relative) and generates a type that exposes all the saved values as static members:
1: |
|
When accessed, the type provider automatically converts the data from the R format to F# format. In the above example,volcanoList
is imported as float[]
and the volcanoMean
value is a singleton array. (The provider does not detect that this is a singleton, so you can get the value using sample.volcanoMean.[0]
). For the sample.volcano
value, the R provider does not have a default conversion and so it is exposed as SymbolicExpression
.
When you have a number of *.rdata
files containing data in the same format, you can pick one of them as a sample (which will be used to determine the fields of the type) and then pass the file name to the constructor of the generated type to load it. For example, if we had files data/sample_1.rdata
to data/sample_10.rdata
, we could read them as:
1: |
|
Note that the default conversions available depend on the plugins that are currently available. For example, when you install the enrie FsLab package with the Deedle library, the RData
provider will automatically expose data frames as DeedleFrame<string, string>
values.
Passing data from F# to R
If you perform data acquisition in F# and then want to pass the data to R, you can use the standard R functions for saving the*.rdata
files. The easiest option is to call the R.assign
function to define named values in the R environment and then useR.save
to save the environment to a file:
1: |
|
It is recommended to use the list
parameter of the save
function to specify the names of the symbols that should be saved, rather than saving all symbols. The R provider uses additional temporary symbols and so the saved file would otherwise contain unnecessary fileds.
Once you save the file using the above command, you can re-load it again using the RData
type provider, such as: new RData<"C:/temp/volcano.rdata">()
.
Reading and writing RData files的更多相关文章
- Reading and Writing CSV Files in C#
Introduction A common requirement is to have applications share data with other programs. Although t ...
- Writing Text Files On The Client in Oracle Forms 10g
Below is the example to write file on client in Oracle Forms 10g with webutil library package.Note: ...
- PostgreSQL Reading Ad Writing Files、Execution System Instructions Vul
catalog . postgresql简介 . 文件读取/写入 . 命令执行 . 影响范围 . 恶意代码分析 . 缓解方案 1. postgresql简介 PostgreSQL 是一个自由的对象-关 ...
- Reading or Writing to Another Processes Memory in C# z
http://www.jarloo.com/reading-and-writing-to-memory/ Declarations [Flags] public enum ProcessAccessF ...
- Apache POI – Reading and Writing Excel file in Java
来源于:https://www.mkyong.com/java/apache-poi-reading-and-writing-excel-file-in-java/ In this article, ...
- Reading and writing
A text file is a sequence of characters stored on a permanent medium like a hard drive, flash memory ...
- Analysis about different methods for reading and writing file in Java language
referee:Java Programming Tutorial Advanced Input & Output (I/O) JDK 1.4+ introduced the so-calle ...
- DotNet 资源大全中文版(Awesome最新版)
Awesome系列的.Net资源整理.awesome-dotnet是由quozd发起和维护.内容包括:编译器.压缩.应用框架.应用模板.加密.数据库.反编译.IDE.日志.风格指南等. 算法与数据结构 ...
- Thinking in Java——笔记(18)
I/O The original byte-oriented library was supplemented with char-oriented, Unicode-based I/O classe ...
随机推荐
- 设计模式-装饰模式(Decorator Pattern)
装饰模式(Decorator Pattern):动态地给一个对象添加一些额外的职责,就增加功能来说,装饰模式比生成子类更为灵活
- iOS-一个弹出菜单动画视图开源项目分享
相似于Tumblr公布button的弹出视图 使用非常easy: 初始化: @property (nonatomic, strong) XWMenuPopView *myMenuPopView; - ...
- Java Web(六) EL表达式
这也是属于JSP范围内的知识,使用EL表达式,能更好的使用JSP中的各种内置对象和作用域,说点闲话,马上要出去实习了,有点恐慌,可能这是马上要出去工作的学生的通病,继续努力把,兵来将挡水来土掩, -- ...
- 【Unity】4.0 第4章 创建基本的游戏场景
分类:Unity.C#.VS2015 创建日期:2016-04-05 一.简介 上一章我们学习了如何利用长方体(Cube)制作基本的3D模型,以及如何导入各种资源,本章将在此基础上,分别制作路面.跳板 ...
- java集群优化——ORM框架查询优化原理
众所周知,当下的流行的企业级架构中,ORM一直是最基础的部分,在架构设计的底层.对逻辑层提供面向对象的操作支持,而事实总是和我们预想的有所偏差,ORM在提供了较好的操作体验时,也流失了一部分原生SQL ...
- distinct aggregation
https://docs.google.com/document/d/1zj6OA-K2hi7ah8Fo-xTQB-mVmYfm6LsN2_NHgTCVmJI/edit# https://issues ...
- jsack
https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/tooldescr016.html#BABGHEJB
- 【设计模式】适配器模式与Reader、InputStream之间的适配
简述 适配器模式,目的是将A对象通过适配.转换的方式转换成B对象来使用,为什么转换为B对象?因为用户通过依赖B对象来使用. 适配器的实现有两种方式. 继承实现 组合实现 基于Java单继承的机制,组合 ...
- 关于 android receiver
可以在代码文件中声明一个receiver,也可以在manifest中声明一个,前者中的receiver只有在该activity launch起来以后才会监听其所感兴趣的事件,而如果在androidMa ...
- 使用BC库解密出现no such provider错误
使用BC库解密出现no such provider错误 错误提示如下: Exception in thread "main" java.security.NoSuchProvide ...