[Stacomir-commits] r280 - pkg/stacomir/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Feb 3 11:37:09 CET 2017
Author: briand
Date: 2017-02-03 11:37:08 +0100 (Fri, 03 Feb 2017)
New Revision: 280
Modified:
pkg/stacomir/R/BilanMigrationInterAnnuelle.r
Log:
Modified: pkg/stacomir/R/BilanMigrationInterAnnuelle.r
===================================================================
--- pkg/stacomir/R/BilanMigrationInterAnnuelle.r 2017-02-03 10:16:59 UTC (rev 279)
+++ pkg/stacomir/R/BilanMigrationInterAnnuelle.r 2017-02-03 10:37:08 UTC (rev 280)
@@ -220,21 +220,26 @@
#' @export
setMethod("calcule",signature=signature("BilanMigrationInterannuelle"),definition=function(object,silent=FALSE){
#bilanMigrationInterAnnuelle<-bmi;silent=FALSE
+ #require(dplyr)
bilanMigrationInterAnnuelle<-object
calcdata<-list()
dic<-bilanMigrationInterAnnuelle at dc@dc_selectionne
for (i in 1:length(dic)){
#i=1
- datadic<-bilanMigrationInterAnnuelle at data[bilanMigrationInterAnnuelle at data$bjo_dis_identifiant==dic[i],]
+ datadic<-bilanMigrationInterAnnuelle at data[bilanMigrationInterAnnuelle at data$bjo_dis_identifiant==dic[i]&bilanMigrationInterAnnuelle at data$bjo_labelquantite=="Effectif_total",]
datadic<-funtraitementdate(datadic, nom_coldt = "bjo_jour", jour_an = TRUE, quinzaine = TRUE)
- wtd.mean(as.numeric(datadic$jour_365),
+ Hmisc::wtd.mean(as.numeric(datadic$jour_365),
weights=datadic$bjo_valeur)
- fnquant<-function(data){
- wtd.quantile(as.numeric(data$jour_365),
- weights=data$bjo_valeur,
- probs=c(0, .05, .5, .95, 1))
+ c(0, .05, .5, .95, 1)
+ fnquant<-function(value, probs){
+ Hmisc::wtd.quantile(as.numeric(data$jour_365),
+ weights=value,
+ probs=probs)
}
-
+ dplyr::select(datadic,bjo_annee,bjo_tax_code,bjo_std_code,bjo_valeur,jour_365)%>%
+ group_by(bjo_annee,bjo_tax_code,bjo_std_code)%>%
+ summarize(q0=fnquant(value=bjo_valeur,probs=0))
+
}
bilanMigrationInterAnnuelle at calcdata<-""
return(bilanMigrationInterAnnuelle)
More information about the Stacomir-commits
mailing list