English 中文(简体)
Save a file in R eachhour
原标题:Save a file in R every hour
  • 时间:2012-01-12 20:11:51
  •  标签:
  • r
  • save

我有一个收集数据的连续过程,我想写每小时收集的数据。 简而言之,我如何能够有条件地每小时将数据保存到数据档案中。

就此而言,我收集一份清单中的数据,希望将清单的标语保存到每小时存档、删除清单并重建。

我对以下法典进行了尝试,但并未奏效:

 if (identical(format(Sys.time(), "%M:%S"), "00:00")) {
      save(twt, file=fname_r)
 }

任何帮助都将受到高度赞赏。

最佳回答

你可能会以错误的方式来做到这一点。 并非所有工作都是R(因为R真正是单一阅读的),时间安排一直是主要的操作系统任务。 使用<代码>cron,或者如果你从西北地区重新担任这一市场领导职务,则看其时间安排选择。 然后编造了三维书。

连续的收集工作是否在现场收集结果,或者在现场或双手进行。 然后每小时收集一次垃圾堆。 一旦你们看到了时间安排,就能够在R这样做。

至于决定某一小时是否已经过去这一更狭隘的问题,使用像过去这样的东西。

then <- Sys.time()
# ... stuff happens ...
now <- Sys.time()
if (as.numeric(difftime(now, then, unit="mins") > 60) {
   # .. do stuff
}
问题回答

为在<代码>R上安排会议,请在<编码>tcltk2包装上使用功能。 你告诉我们,在执行任务、(表达/职能)任务和完成这项任务之间,会如何等待,然后在这种背景下,它会定期执行任务。 很谨慎的是,你没有两个相互干预的过程。 如果你拯救该物体的任务与更新同一物体的任务同时进行,那么只有一部分物体可以获救,或所节省的物品是解放的。 因此,如果数据标的在保存之前已经完整,你需要某种方法加以检查。





相关问题
How to plot fitted model over observed time series

This is a really really simple question to which I seem to be entirely unable to get a solution. I would like to do a scatter plot of an observed time series in R, and over this I want to plot the ...

REvolution for R

since the latest Ubuntu release (karmic koala), I noticed that the internal R package advertises on start-up the REvolution package. It seems to be a library collection for high-performance matrix ...

R - capturing elements of R output into text files

I am trying to run an analysis by invoking R through the command line as follows: R --no-save < SampleProgram.R > SampleProgram.opt For example, consider the simple R program below: mydata =...

R statistical package: wrapping GOFrame objects

I m trying to generate GOFrame objects to generate a gene ontology mapping in R for unsupported organisms (see http://www.bioconductor.org/packages/release/bioc/vignettes/GOstats/inst/doc/...

Changing the order of dodged bars in ggplot2 barplot

I have a dataframe df.all and I m plotting it in a bar plot with ggplot2 using the code below. I d like to make it so that the order of the dodged bars is flipped. That is, so that the bars labeled "...

Strange error when using sparse matrices and glmnet

I m getting a weird error when training a glmnet regression. invalid class "dgCMatrix" object: length(Dimnames[[2]]) must match Dim[2] It only happens occasionally, and perhaps only under larger ...

Generating non-duplicate combination pairs in R

Sorry for the non-descriptive title but I don t know whether there s a word for what I m trying to achieve. Let s assume that I have a list of names of different classes like c( 1 , 2 , 3 , 4 ) ...

Per panel smoothing in ggplot2

I m plotting a group of curves, using facet in ggplot2. I d like to have a smoother applied to plots where there are enough points to smooth, but not on plots with very few points. In particular I d ...

热门标签