> 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
> mycars <- as_data_frame(mtcars)
> select(mycars, vs:carb)
Source: local data frame [32 x 4]
vs am gear carb
(dbl) (dbl) (dbl) (dbl)
1 0 1 4 4
2 0 1 4 4
3 1 1 4 1
4 1 0 3 1
5 0 0 3 2
6 1 0 3 1
7 0 0 3 4
8 1 0 4 2
9 1 0 4 2
10 1 0 4 4
.. ... ... ... ...
>
> # Here I load MASS, whose "select" function
> # masks the one from dplyr, causing trouble:
> library("MASS")
Attaching package: ‘MASS’
The following object is masked from ‘package:dplyr’:
select
> select(mycars,vs:carb)
Error in select(mycars, vs:carb) : unused argument (vs:carb)
>
> # So I thought reloading dplyr would cause
> # its "select" function to mask the one
> # from MASS, but it does not!
> library("dplyr")
> select(mycars,vs:carb)
Error in select(mycars, vs:carb) : unused argument (vs:carb)
>
> # Detaching MASS fixes it
> detach("package:MASS")
> select(mycars,vs:carb)
Source: local data frame [32 x 4]
vs am gear carb
(dbl) (dbl) (dbl) (dbl)
1 0 1 4 4
2 0 1 4 4
3 1 1 4 1
4 1 0 3 1
5 0 0 3 2
6 1 0 3 1
7 0 0 3 4
8 1 0 4 2
9 1 0 4 2
10 1 0 4 4
.. ... ... ... ...
>
> # But the Deducer package requires MASS!
> # This analysis is my actual goal.
> options(DeducerNoGUI=TRUE)
> library("Deducer")
Loading required package: ggplot2
Loading required package: JGR
Loading required package: rJava
Loading required package: JavaGD
Loading required package: iplots
Loading required package: car
Loading required package: MASS
Attaching package: ‘MASS’
The following object is masked from ‘package:dplyr’:
select
Loading Deducer without GUI. If you wish the GUI to load, run options(DeducerNoGUI=FALSE) before loading Deducer
> frequencies(
+ select(mycars,vs:carb) )
Error in select(mycars, vs:carb) : unused argument (vs:carb)
>
> # Now Deducer won't allow MASS to be detached!
> detach("package:MASS")
Error: package ‘MASS’ is required by ‘Deducer’ so will not be detached
>
> # So the only solution is to use:
> frequencies(
+ dplyr::select(mycars,vs:carb) )
$vs
------------------------------------------------------------
-- Frequencies --
-- --
Value # of Cases % Cumulative %
1 0 18 56.2 56.2
2 1 14 43.8 100.0
-- --
-- Case Summary --
-- --
Valid Missing Total
# of cases 32 0 1
-- --
-- --
------------------------------------------------------------
$am
------------------------------------------------------------
-- Frequencies --
-- --
Value # of Cases % Cumulative %
1 0 19 59.4 59.4
2 1 13 40.6 100.0
-- --
-- Case Summary --
-- --
Valid Missing Total
# of cases 32 0 1
-- --
-- --
------------------------------------------------------------
$gear
------------------------------------------------------------
-- Frequencies --
-- --
Value # of Cases % Cumulative %
1 3 15 46.9 46.9
2 4 12 37.5 84.4
3 5 5 15.6 100.0
-- --
-- Case Summary --
-- --
Valid Missing Total
# of cases 32 0 1
-- --
-- --
------------------------------------------------------------
$carb
------------------------------------------------------------
-- Frequencies --
-- --
Value # of Cases % Cumulative %
1 1 7 21.9 21.9
2 2 10 31.2 53.1
3 3 3 9.4 62.5
4 4 10 31.2 93.8
5 6 1 3.1 96.9
6 8 1 3.1 100.0
-- --
-- Case Summary --
-- --
Valid Missing Total
# of cases 32 0 1
-- --
-- --
------------------------------------------------------------
>
> sessionInfo()
R version 3.3.0 (2016-05-03)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] Deducer_0.7-9 MASS_7.3-45 car_2.1-2 JGR_1.7-16 iplots_1.1-7
[6] JavaGD_0.6-1 rJava_0.9-8 ggplot2_2.1.0 dplyr_0.4.3
loaded via a namespace (and not attached):
[1] Rcpp_0.12.5 nloptr_1.0.4 plyr_1.8.3
[4] effects_3.1-1 class_7.3-14 tools_3.3.0
[7] lme4_1.1-12 gtable_0.2.0 nlme_3.1-128
[10] lattice_0.20-33 mgcv_1.8-12 png_0.1-7
[13] Matrix_1.2-6 DBI_0.4-1 parallel_3.3.0
[16] mvtnorm_1.0-5 SparseM_1.7 e1071_1.6-7
[19] MatrixModels_0.4-1 grid_3.3.0 nnet_7.3-12
[22] R6_2.1.2 survival_2.39-4 foreign_0.8-66
[25] multcomp_1.4-5 TH.data_1.0-7 minqa_1.2.4
[28] magrittr_1.5 codetools_0.2-14 scales_0.4.0
[31] splines_3.3.0 assertthat_0.1 pbkrtest_0.4-6
[34] colorspace_1.2-6 quantreg_5.24 sandwich_2.3-4
[37] lazyeval_0.1.10 munsell_0.4.3 zoo_1.7-13