You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Apologies if this is a dupe, or should be for dplyr. The following behavior chokes spread(). Here's a convoluted 'reprex':
library(dplyr)
library(tidyr)
s<- summarise(
group_by(iris, Species),
sepal_l= mean(Sepal.Length), sepal_w= mean(Sepal.Width),
petal_l= mean(Petal.Length), petal_w= mean(Petal.Width)
)
# The result of gather()
gather(s, Species, value)
# Source: local data frame [12 x 3]## Species Species.1 value#1 setosa sepal_l 5.006#2 versicolor sepal_l 5.936#3 virginica sepal_l 6.588# ... (abridged by br)# This is the problematic call
separate(
gather(s, Species, value),
Species.1, c("part", "orient"), sep="_"
)
# Error in matrix(unlist(pieces), ncol = n, byrow = TRUE) : # 'data' must be of a vector type, was 'NULL'
In similar-ish cases (tidyverse/dplyr#860, #51) ungrouping seemed to help. However, here only calling data.frame() on the data does.
separate( # Same error as above
ungroup(gather(s, Species, value)),
Species.1, c("part", "orient"), sep="_"
)
separate( # Same error as above
gather(ungroup(s), Species, value),
Species.1, c("part", "orient"), sep="_"
)
separate( # This worksdata.frame(gather(s, Species, value)),
Species.1, c("part", "orient"), sep="_"
)
# Desired result:# Species part orient value#1 setosa sepal l 5.006#2 versicolor sepal l 5.936#3 virginica sepal l 6.588#4 setosa sepal w 3.428# ... (abridged by br)
Comparing objects that work and those that don't, the the x.1 renaming convention for duplicate column names (in this case Species.1) seems to be the only difference. The tbl_df shows Species.1 as the column name, but seems to represent it as 'Species' internally, when unclassed. 'Species.1' is the col parameter in the problematic call to spread().
Apologies if this is a dupe, or should be for dplyr. The following behavior chokes spread(). Here's a convoluted 'reprex':
In similar-ish cases (tidyverse/dplyr#860, #51) ungrouping seemed to help. However, here only calling data.frame() on the data does.
Comparing objects that work and those that don't, the the x.1 renaming convention for duplicate column names (in this case Species.1) seems to be the only difference. The tbl_df shows Species.1 as the column name, but seems to represent it as 'Species' internally, when unclassed. 'Species.1' is the
col
parameter in the problematic call to spread().Versions:
Apologies for the verbose report!
The text was updated successfully, but these errors were encountered: