ijlyttle · GitHub

I'll allow for the possibility I am not using summarize() as I should, but...

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
mtcars_slim <- summarize(mtcars, mpg, cyl)
summary(mtcars_slim) # ok
##       mpg            cyl
##  Min.   :10.4   Min.   :4.00
##  1st Qu.:15.4   1st Qu.:4.00
##  Median :19.2   Median :6.00
##  Mean   :20.1   Mean   :6.19
##  3rd Qu.:22.8   3rd Qu.:8.00
##  Max.   :33.9   Max.   :8.00
str(mtcars_slim) # not ok
## 'data.frame':    1 obs. of  2 variables:
##  $ mpg: num  21 21 22.8 21.4 18.7 18.1 14.3 24.4 22.8 19.2 ...
##  $ cyl: num  6 6 4 6 8 6 8 4 4 6 ...
mtcars_slim # just weird
## Warning: corrupt data frame: columns will be truncated or padded with NAs
##    mpg cyl
## 1 21.0   6
mtcars_slim[3, ] # even weirder
##     mpg cyl
## NA 22.8   4
sessionInfo()
## R version 3.0.2 (2013-09-25)
## Platform: x86_64-apple-darwin10.8.0 (64-bit)
##
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
##
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base
##
## other attached packages:
## [1] dplyr_0.1.2  knitr_1.5.22
##
## loaded via a namespace (and not attached):
## [1] assertthat_0.1 evaluate_0.5.1 formatR_0.10   Rcpp_0.11.0
## [5] stringr_0.6.2  tools_3.0.2

Read the original on github.com ↗