1

当我运行unnest文档中的示例时,我收到以下错误:

Error in captureDots() : the argument has already been evaluated.

我也在这里的示例中遇到错误:https ://blog.rstudio.org/2016/02/02/tidyr-0-4-0/ 。

> version
               _                           
platform       x86_64-apple-darwin13.4.0   
arch           x86_64                      
os             darwin13.4.0                
system         x86_64, darwin13.4.0        
status                                     
major          3                           
minor          3.2                         
year           2016                        
month          10                          
day            31                          
svn rev        71607                       
language       R                           
version.string R version 3.3.2 (2016-10-31)
nickname       Sincere Pumpkin Patch       
> library(tidyr)
> library(dplyr)

Attaching package: ‘dplyr’

The following objects are masked from ‘package:stats’:

    filter, lag

The following objects are masked from ‘package:base’:

    intersect, setdiff, setequal, union

> df <- data_frame(
+     x = 1:3,
+     y = c("a", "d,e,f", "g,h")
+ )
> df %>%
+     transform(y = strsplit(y, ",")) %>%
+     unnest(y)
  x y
1 1 a
2 2 d
3 2 e
4 2 f
5 3 g
6 3 h
> 
> # Or just
> df %>%
+     unnest(y = strsplit(y, ","))
# A tibble: 6 × 2
      x     y
  <int> <chr>
1     1     a
2     2     d
3     2     e
4     2     f
5     3     g
6     3     h
> 
> # It also works if you have a column that contains other data frames!
> df <- data_frame(
+     x = 1:2,
+     y = list(
+         data_frame(z = 1),
+         data_frame(z = 3:4)
+     )
+ )
> df %>% unnest(y)
Error in captureDots() : the argument has already been evaluated
4

1 回答 1

1

安装了最新版本dplyr,tidyrtidyverse, 现在可与 R 3.2.2 一起使用。

于 2017-04-20T15:44:24.660 回答