zoo

R: Interpolation of NAs by group

孤街醉人 提交于 2019-11-29 08:20:35
I would like to perform a linear interpolation in a variable of a data frame which takes into account the: 1) time difference between the two points, 2) the moment when the data was taken and 3) the individual taken for measure the variable. For example in the next dataframe: df <- data.frame(time=c(1,2,3,4,5,6,7,1,2,3), Individuals=c(1,1,1,1,1,1,1,2,2,2), Value=c(1, 2, 3, NA, 5, NA, 7, 5, NA, 7)) df I would like to obtain: result <- data.frame(time=c(1,2,3,4,5,6,7,1,2,3), Individuals=c(1,1,1,1,1,1,1,2,2,2), Value=c(1, 2, 3, 4, 5, 6, 7, 5, 5.5, 6)) result I cannot use exclusively the function

redis之基础命令

隐身守侯 提交于 2019-11-29 08:17:59
redis之基础命令 一、redis介绍 1、redis特性 Redis 是一个开源(BSD许可)的,内存中的数据结构存储系统,它可以用作数据库、缓存和消息中间件 redis是c语言编写的,支持数据持久化,是key-value类型数据库。 应用在缓存,队列系统中 redis支持数据备份,也就是master-slave模式 2、redis优势 性能高,读取速度10万次每秒 写入速度8万次每秒 所有操作支持原子性 用作缓存数据库,数据放在内存中 替代某些场景下的mysql,如社交类app 大型系统中,可以存储session信息,购物车订单 二、安装resis 1、yum安装 #前提得配置好阿里云yum源,epel源 #查看是否有redis包 yum list redis #安装redis yum install redis -y #安装好,启动redis systemctl start redis 检测redis是否工作 redis-cli #redis 客户端工具 #进入交互式环境后,执行ping,返回pong表示安装成功 127.0.0.1:6379> ping PONG 2、源码安装redis,编译安装 为什么要学习源码安装? 有人说编译安装性能好?错 编译安装的优势是: 编译安装时可以指定扩展的module(模块),php、apache、nginx都是一样有很多第三方扩展模块

Modifying Plot in ggplot2 using as.yearmon from zoo

十年热恋 提交于 2019-11-29 07:35:43
I have created a graph in ggplot2 using zoo to create month bins. However, I want to be able to modify the graph so it looks like a standard ggplot graph. This means that the bins that aren't used are dropped and the bins that are populate the entire bin space. Here is my code: library(data.table) library(ggplot2) library(scales) library(zoo) testset <- data.table(Date=as.Date(c("2013-07-02","2013-08-03","2013-09-04","2013-10-05","2013-11-06","2013-07-03","2013-08-04","2013-09-05","2013-10-06","2013-11-07")), Action = c("A","B","C","D","E","B","A","B","C","A","B","E","E","C","A"), rating =

ZooKeeper伪分布式集群安装及使用

拈花ヽ惹草 提交于 2019-11-29 06:21:29
ZooKeeper伪分布式集群安装及使用 让Hadoop跑在云端系列文章 ,介绍了如何整合虚拟化和Hadoop,让Hadoop集群跑在VPS虚拟主机上,通过云向用户提供存储和计算的服务。 现在硬件越来越便宜,一台非品牌服务器,2颗24核CPU,配48G内存,2T的硬盘,已经降到2万块人民币以下了。这种配置如果简单地放几个web应用,显然是奢侈的浪费。就算是用来实现单节点的hadoop,对计算资源浪费也是非常高的。对于这么高性能的计算机,如何有效利用计算资源,就成为成本控制的一项重要议题了。 通过虚拟化技术,我们可以将一台服务器,拆分成12台VPS,每台2核CPU,4G内存,40G硬盘,并且支持资源重新分配。多么伟大的技术啊!现在我们有了12个节点的hadoop集群, 让Hadoop跑在云端,让世界加速。 关于作者: 张丹(Conan), 程序员Java,R,PHP,Javascript weibo:@Conan_Z blog: http://blog.fens.me email: bsspirit @gmail.com 转载请注明出处: http://blog.fens.me/hadoop-zookeeper-intro/ 前言 ZooKeeper是Hadoop家族的一款高性能的分布式协作的产品。在单机中,系统协作大都是进程级的操作。分布式系统中,服务协作都是跨服务器才能完成的

Why is there no apply.hourly in R with xts/zoo?

落爺英雄遲暮 提交于 2019-11-29 05:06:23
问题 I want to aggregate data by hourly mean. Daily is very easy: apply.daily(X2,mean) Why is there no function for hourly? I tried hr.means <- aggregate(X2, format(X2["timestamp"],"%Y-%m-%d %H")) and got always error with trim argument. Is there an easier function similar to apply.daily? What if I want to aggregate the mean of 5 minutes. Data are values per minute: "timestamp", value "2012-04-09 05:03:00",2 "2012-04-09 05:04:00",4 "2012-04-09 05:05:00",5 "2012-04-09 05:06:00",0 "2012-04-09 05:07

R: adding 1 month to a date

独自空忆成欢 提交于 2019-11-29 04:01:26
I want to get the date sequence between a startDate and endDate by adding 1 month to the startDate . ie, if startDate is 2013-01-31 and endDate is 2013-07-31, I would prefer to see dates like this: "2013-01-31" "2013-02-28" "2013-03-31" "2013-04-30" "2013-05-31" "2013-06-30" "2013-07-31" I have tried seq.Date(as.Date("2013-01-31"),by="month",length.out=7) . But the output of this code is like this > seq.Date(as.Date("2013-01-31"),by="month",length.out=7) [1] "2013-01-31" "2013-03-03" "2013-03-31" "2013-05-01" "2013-05-31" "2013-07-01" "2013-07-31" So,what is the simplest solution to get the

Add missing xts/zoo data with linear interpolation in R

寵の児 提交于 2019-11-29 02:22:19
I do have problems with missing data, but I do not have NAs - otherwise would be easier to handle... My data looks like this: time, value 2012-11-30 10:28:00, 12.9 2012-11-30 10:29:00, 5.5 2012-11-30 10:30:00, 5.5 2012-11-30 10:31:00, 5.5 2012-11-30 10:32:00, 9 2012-11-30 10:35:00, 9 2012-11-30 10:36:00, 14.4 2012-11-30 10:38:00, 12.6 As you can see - there are missing some minute values - it is xts/zoo so I use as.POSIXct... to set the date as an index. How to add the missing timesteps to get a full ts? I want to fill the missing values with linear interpolation. Thank you for your help! You

R: Filling missing dates in a time series?

﹥>﹥吖頭↗ 提交于 2019-11-29 02:20:21
问题 I have a zoo time series with missing days. In order to fill it and have a continuous series I do... I generate a chron date-time sequence from start to end. I merge my series with this one. I use na.locf to substitute NAs with las obsservation. I remove the syntetic chron sequence. Can I do same easier? Maybe with some index function related to the frequency? 回答1: It's slightly easier if you use a "empty" zoo object with an index. > x <- zoo(1:10,Sys.Date()-10:1)[c(1,3,5,7,10)] > empty <-

Convert daily to weekly/monthly data with R

天涯浪子 提交于 2019-11-29 00:10:49
I have daily prices series over a wide range of products; I want to convert to a new dataframe with weekly or monthly data. I first used xts in order to apply the to.weekly function...which works only for OHLC format. I am sure there may exist a function similar to to.weekly but for dataframe where the format is not OHLC. There a different posts already related to this as the following: Does rollapply() allow an array of results from call to function? or Averaging daily data into weekly data I am eventually using: length(bra) 1 2416 test<-bra[seq(1,2416,7),] Would there be a more efficient

Java方法引用

梦想与她 提交于 2019-11-28 20:36:11
1、什么是方法引用 方法引用是一种 简写lambda表达式 的方式。 等同于lambda表达式 如: List<String> stringsArray = Arrays.asList("sdf","gsdf","gsdf"); Collections.sort(stringsArray, (a,b)-> a.compareToIgnoreCase(b)); 可简写为: List<String> stringsArray = Arrays.asList("sdf","gsdf","gsdf"); Collections.sort(stringsArray, String::compareToIgnoreCase); 这就是方法引用 Java8特性。用::表示    2、什么情况下使用 当我们使用lamdba表达式,如果lamdba表达式实现体 只调用了一个外部已经存在的方法 时。 这种情况 就可以使用方法引用。 如上的例子 lamdba体中只调用了String的compareToIgnoreCase一个方法,就可以使用方法引用 3、分类 静态方法引用、实例方法引用、类型的实例方法引用、构造方法引用、数组构造方法引用 静态方法引用: class Zoo{ private int age; public Zoo(int age) { this.age = age; } public