2016-07-07 41 views
2

我有兩個系統。點代詞在某些系統上失敗,但不是其他系統

下面的代碼傳遞System A但不是System B

responses <- data.frame(a = c(0,1,2,3,4),b = c(0,1,2,3,4)) 
section_vars <- c("a","b") 

mutate_each(responses, funs(mean),one_of(section_vars)) %>% 
    mutate(col1 = 
      rowSums(
       select(.,one_of(section_vars)), 
       na.rm = TRUE 
      ) %>% as.integer() 
    ) %>% .$col1 

它失敗,錯誤:

Error "." not found 

系統A(工作):

R version 3.2.3 (2015-12-10) 
Platform: x86_64-pc-linux-gnu (64-bit) 
Running under: Ubuntu 16.04 LTS 

locale: 
[1] C 

attached base packages: 
[1] stats  graphics grDevices utils  datasets methods base  

other attached packages: 
[1] dataBroker_1.141.0.0 dplyr_0.5.0   tidyr_0.5.1   
[4] data.table_1.9.6  RMySQL_0.10.9  DBI_0.4-1   

loaded via a namespace (and not attached): 
[1] Rcpp_0.12.5  codetools_0.2-14 withr_1.0.2  digest_0.6.9  
[5] psych_1.6.6  foreach_1.4.3  assertthat_0.1 plyr_1.8.4  
[9] chron_2.3-47  R6_2.1.2   magrittr_1.5  lazyeval_0.2.0 
[13] doParallel_1.0.10 devtools_1.12.0 iterators_1.0.8 tools_3.2.3  
[17] parallel_3.2.3 yaml_2.1.13  mnormt_1.5-4  memoise_1.0.0  
[21] tibble_1.0 

系統B(錯誤):

R version 3.2.5 (2016-04-14) 
Platform: x86_64-pc-linux-gnu (64-bit) 
Running under: Ubuntu precise (12.04.5 LTS) 

locale: 
[1] C 

attached base packages: 
[1] stats  graphics grDevices utils  datasets methods base  

other attached packages: 
[1] dataBroker_1.141.0.2 dplyr_0.5.0   tidyr_0.5.1   data.table_1.9.6  RMySQL_0.9-3   DBI_0.3.1   

loaded via a namespace (and not attached): 
[1] Rcpp_0.12.4  codetools_0.2-14 psych_1.4.8.11 foreach_1.4.2 assertthat_0.1 plyr_1.8.1  chron_2.3-47  R6_2.1.2   magrittr_1.0.1 lazyeval_0.1.10 doParallel_1.0.8 
[12] iterators_1.0.7 tools_3.2.5  yaml_2.1.13  parallel_3.2.5 
+2

也許更新B上的'magrittr'?你在A上運行版本1.5,在B上運行1.0.1,它是定義'%>%'和相應的'.'的包。 – Gregor

+0

@gregor謝謝!我會試試這個。 –

+0

我以爲'%>和'.'都包含在'dplyr'中? –

回答

1

%>%操作者來從magrittr包,所以請確保您的magrittr版本是最新的。

相關問題