multidplyr

R spread dataframe [duplicate]

烂漫一生 提交于 2021-02-04 21:33:54
问题 This question already has answers here : Reshape multiple value columns to wide format (5 answers) Closed 7 months ago . IN R language how to convert data1 into data2 data1 = fread(" id year cost pf loss A 2019-02 155 10 41 B 2019-03 165 14 22 B 2019-01 185 34 56 C 2019-02 350 50 0 A 2019-01 310 40 99") data2 = fread(" id item 2019-01 2019-02 2019-03 A cost 30 155 NA A pf 40 10 NA A loss 99 41 NA B cost 185 NA 160 B pf 34 NA 14 B loss 56 NA 22 C cost NA 350 NA C pf NA 50 NA C loss NA 0 NA") I

multidplyr: trial custom function

早过忘川 提交于 2021-01-28 09:51:09
问题 I'm trying to learn to run a custom function through multidplyr::do() on a cluster. Consider this simple self contained example. For example's sake, I'm trying to apply my custom function myWxTest to each common_dest (destinations with more than 50 flights) in the flight dataset: library(dplyr) library(multidplyr) library(nycflights13) library(quantreg) myWxTest <- function(x){ stopifnot(!is.null(x$dep_time)) stopifnot(!is.null(x$dep_delay)) stopifnot(!is.null(x$sched_dep_time)) stopifnot(!is

multidplyr : assign functions to cluster

北慕城南 提交于 2021-01-27 16:36:12
问题 (see working solution below) I want to use multidplyr to parallelize a function : calculs.R f <- function(x){ return(x+1) } main.R library(dplyr) library(multidplyr) source("calculs.R") d <- data.frame(a=1:1000,b=sample(1:2,1000),replace=T) result <- d %>% partition(b) %>% do(f(.)) %>% collect() I then get: Initialising 3 core cluster. Error in checkForRemoteErrors(lapply(cl, recvResult)) : 2 nodes produced errors; first error: could not find function "f" In addition: Warning message: group

multidplyr : assign functions to cluster

↘锁芯ラ 提交于 2021-01-27 16:33:34
问题 (see working solution below) I want to use multidplyr to parallelize a function : calculs.R f <- function(x){ return(x+1) } main.R library(dplyr) library(multidplyr) source("calculs.R") d <- data.frame(a=1:1000,b=sample(1:2,1000),replace=T) result <- d %>% partition(b) %>% do(f(.)) %>% collect() I then get: Initialising 3 core cluster. Error in checkForRemoteErrors(lapply(cl, recvResult)) : 2 nodes produced errors; first error: could not find function "f" In addition: Warning message: group