R data formats: RData, Rda, Rds etc

What are the main differences between .RData, .Rda and .Rds files? More specifically: Are there differences in compression etc? When should each type be used? How to convert one type to another? Rda is just a short name for RData. You can just save(), load(), attach(), etc. just like you do with RData. Rds stores a single R object. Yet, beyond that simple explanation, there are seve

R数据格式:RData,Rda,Rds等

.RData,.Rda和.Rds文件的主要区别是什么? 进一步来说: 在压缩等方面有差异吗? 什么时候应该使用每种类型? 如何将一种类型转换为另一种? Rda只是RData的简称。 您可以像保存RData一样保存(),加载(),附加()等。 Rds存储一个R对象。 然而,除了这个简单的解释之外,与“标准”存储有几处不同之处。 readRDS()函数的这个R-manual链接可能充分阐明了这种区别。 所以,回答你的问题: 区别不在于压缩

Opening all files in a folder, and applying a function

I am doing a relatively simple piece of analysis which I have put into a function, on all the files in a particular folder. I was wondering whether anyone had any tips to help me automate the process on a number of different folders. Firstly, I was wondering whether there was a way of reading all the files in a particular folder straight into R. I believe the following command will list all th

打开文件夹中的所有文件并应用功能

我正在做一个相对简单的分析,我把它放到一个函数中,放在特定文件夹中的所有文件中。 我想知道是否有人有任何提示可以帮助我在多个不同文件夹上自动执行该过程。 首先,我想知道是否有一种方法可以将特定文件夹中的所有文件直接读入R.我相信以下命令将列出所有文件: files <- (Sys.glob("*.csv")) ...我从使用R找到具有指定扩展名的所有文件 然后下面的代码将所有这些文件读入R. listOfFiles <- lapp

How do you save images in an R shiny function

Generally the format looks like this output$downloadPlot <- downloadHandler filename = function() { paste0(basename(file_path_sans_ext(input$filename)), "_plot", ".jpeg", sep='') }, PLOTFUNCTION()<- function(){ plot() }, content = function(file) { if (input$clickButton != 0) { jpeg(file) PLOTFUNCTION() dev.off() } else { return() } }) so then I get this mess

如何将图像保存在R闪光灯功能中

通常这种格式看起来像这样 output$downloadPlot <- downloadHandler filename = function() { paste0(basename(file_path_sans_ext(input$filename)), "_plot", ".jpeg", sep='') }, PLOTFUNCTION()<- function(){ plot() }, content = function(file) { if (input$clickButton != 0) { jpeg(file) PLOTFUNCTION() dev.off() } else { return() } }) 然后我收到这条消息 错误:无法将

How to load .Rdata from an R package?

I am developing an R package. In the package, I stored some .Rdata file from the simulation results. Now I would like to load/use those .Rdata in the rmarkdown so that I can write vignettes. I can load those data from my computer. But my question is how do I load data from my own package directory? Because in the future some users of the package may need to follow the same code from the vign

如何从R包加载.Rdata?

我正在开发一个R包。 在包中,我从模拟结果中存储了一些.Rdata文件。 现在我想在rmarkdown中加载/使用这些.Rdata,以便我可以编写小插曲。 我可以从我的电脑加载这些数据。 但我的问题是如何从我自己的软件包目录加载数据? 因为将来该软件包的某些用户可能需要遵循小插图中的相同代码并重现结果或绘图。 假设你使用了devtools::use_data() ,你可以使用library(YOUR_PACKAGE); data("dataset") library(YOUR_

How to subset RData file that is too large for memory?

I have an RData file that has become too large to load on my computer using the load() command. It contains a data frame with ~3 million observations and ~100 variables. I want to load the file, maybe using some bigdata or ff package (but I have no idea how these work) get rid of some variables to reduce file size save it as as an Rdata file with a regular data frame (not some weird &quo

如何对RData文件进行子集分配过大?

我有一个RData文件变得太大,无法使用load()命令加载到我的电脑上。 它包含一个包含约300万个观察值和约100个变量的数据框。 我要 加载文件,也许使用一些bigdata或ff包(但我不知道这些如何工作) 摆脱一些变量来减小文件大小 将其保存为具有常规数据框的Rdata文件(不是一些奇怪的“bigdata”类型对象) 使用load()加载压缩文件并恢复常规R操作 我应该怎么做呢? 上周,Jared Lander(这本书“R for Everyone”一书

Saving jags.model in RData file

Is there any way to save a jags.model() object into a RData or txt file ? To perform MCMC on a better computer, I have to save my model on one and using it in a new workspace. But I've some difficulty to use "save()" and "load()" function on R. Thanks for your advices. Added: I tried: jags <- jags.model('regression.bug', data = my.data, n.chains = 4, n.

在RData文件中保存jags.model

有没有办法将jags.model()对象保存到RData或txt文件中? 要在更好的计算机上执行MCMC,我必须将模型保存在一个模型上并在新的工作空间中使用它。 但是我在R上使用“save()”和“load()”函数时遇到了一些困难。感谢您的建议。 添加: 我试过了: jags < - jags.model('regression.bug',data = my.data,n.chains = 4,n.adapt = 1000) 然后我想保存“jags” 保存(jags,file =“jags.RData”) 它

How to remove a namespace reference in a saved .rda object in R?

I've got a package with a data object (.rda) that was originally created by another package and seems to have a reference to its original namespace. The man page for load() explains: Objects can be saved with references to namespaces, usually as part of the environment of a function or formula. As from R 3.1.0 such objects can be loaded even if the namespace is not available: it is repla

如何删除R中已保存的.rda对象中的名称空间引用?

我有一个包含一个数据对象(.rda)的包,它最初是由另一个包创建的,似乎有一个对其原始名称空间的引用。 load()的手册页说明: 对象可以通过引用命名空间来保存,通常作为函数或公式的环境的一部分。 从R 3.1.0开始,即使命名空间不可用,也可以加载这些对象:它被替换为带有警告的全局环境的引用。 该警告用这样的参考识别第一个对象(但可能有多个)。 我需要删除这个引用,因为它会在包检查期间引发警告。 我试过加

Creating and serializing / saving global variable from within a NAMESPACE in R

I would like to create a function within a package with a NAMESPACE that will save some variables. The problem is that when load is called on the .Rdata file it tries to load the namespace of the package that contained the function that created the .Rdata file, but this package need not be loaded. This example function is in a package in a namespace : create.global.function <- function(x,

在R中的NAMESPACE中创建和序列化/保存全局变量

我想在一个包含NAMESPACE的包中创建一个函数,它将save一些变量。 问题是,当load被呼吁.Rdata文件,它会尝试加载包含创建该.Rdata文件中的函数包的命名空间,但是这个包不需要加载。 这个示例函数位于命名空间的一个包中: create.global.function <- function(x, FUN, ...) { environment(FUN) <- .GlobalEnv assign(".GLOBAL.FUN", function(x) { FUN(x, ...) }, env=.GlobalEnv) environment(.GLOBAL.FUN) <-

Use of gsub function to clean a column in a data frame in R

I have a column showing total assets of some people in Rs 3,94,24,827 ~ 3 Crore+ this format. I want this column to show only numeric data ie 39400000 for the above value and same for every row. How to do this in R. What if you try something like text=“Rs 3,94,24,827 ~ 3 Crore+” gsub(“\D”,””,gsub(“,[2].+”,”00000”,text)) [1] “39400000” To obtain the number alone; gsub(“(~.*)|\D”,””,text) [1

使用gsub函数清理R中数据框中的列

我有一列显示一些人的总资产为3,94,24,827〜3 Crore +这种格式。 我希望此列仅显示数字数据,即上面的值为39400000,每行都显示相同的值。 如何在R中执行此操作 如果你尝试类似的话会怎么样 text=“Rs 3,94,24,827 ~ 3 Crore+” gsub(“\D”,””,gsub(“,[2].+”,”00000”,text)) [1] “39400000” 单独获取号码; gsub(“(~.*)|\D”,””,text) [1]”39424827”

Separate Mixed Dates and Times

I'm exporting data from a medical record platform. The data looks like this... Date.time TEMP HR RR SBP DBP 1 Jun-08-2015 2 1323 36.8 O – – – – 3 931 36.8 O 76 MC 22 SP 104 MC 52 MC 4 930 – – – – – 5 929 – – – –

单独混合日期和时间

我正在从医疗记录平台导出数据。 数据看起来像这样... Date.time TEMP HR RR SBP DBP 1 Jun-08-2015 2 1323 36.8 O – – – – 3 931 36.8 O 76 MC 22 SP 104 MC 52 MC 4 930 – – – – – 5 929 – – – – – 6 813 36.8 O 7