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 ...
随机推荐
- NSDate NSTimerZone 时区转换
timeZoneAbbreviation = @“America/New_York”: #pragma mark - 转换时区 - (NSDate *) convertDate:(NSDate *) ...
- 如何打包和生成你的Android应用程序
原文:http://android.eoe.cn/topic/android_sdk 在生成过程中,你的Android项目的编译和打包成一个apk文件,为您的应用程序二进制的容器.它包含了所有必要的信 ...
- 网络协议-网络分层、TCP/UDP、TCP三次握手和四次挥手
网络的五层划分是什么? 应用层,常见协议:HTTP.FTP 传输层,常见协议:TCP.UDP 网络层,常见协议:IP 链路层 物理层 TCP 和 UDP 的区别是什么 TCP/UDP 都属于传输层的协 ...
- remoting生命周期
https://www.cnblogs.com/luomingui/archive/2011/07/09/2101779.html
- [Windows Azure] How to Scale a SQL Database Solution
How to Scale a SQL Database Solution On Windows Azure, database scalability is synonymous with scale ...
- [Windows Azure] Windows Azure Execution Models
Windows Azure Execution Models Windows Azure provides different execution models for running applica ...
- Spring和Mybatis整合过程中遇到的一个找不到sqlSessionFactory或sqlSessionTemplate的异常
先看启动web项目时IDEA控制台抛出的异常(红色部分): D:\tomcat-kafka-\bin\catalina.bat run [-- ::,] Artifact Gradle : com.x ...
- export default与export的区别
1.export default 和export都可以用于导出常量,函数,文件,模块等: 2.可以在模块中通过import+(常量 | 函数 | 文件 | 模块)名的方式,将其导入,以便能够对其进行使 ...
- MATLAB 2016b 切换回英文版
原因: 中文下不能使用等间距字体.因为等间距字体都是英文字体,报错信息又是中文的,所以这时候报错就全是乱码.如果改成中文字体,又不是等间距的了,看着瞎眼. 方法: Preferences->Ge ...
- Python(八)之函数
Python函数 函数作用: (1)代码重用 (2)一种设计工具,分解复杂问题 (3)将相关功能打包并参数化 函数种类: 全局函数:定义在模块中 局部函数:嵌套在其他函数中 lambda函数:表达式 ...
