Closed chasec closed 2 years ago
Is it fixed? If not, can you update your dplyr
to the latest?
Mine is dplyr_0.7.4
and it works fine.
I also cannot reproduce this:
library(widyr)
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
dat <- data_frame(group = rep(1:5, each = 2),
letter = c("a", "b",
"a", "c",
"a", "c",
"b", "e",
"b", "f"))
pairwise_count(dat, letter, group)
#> # A tibble: 8 x 3
#> item1 item2 n
#> <chr> <chr> <dbl>
#> 1 b a 1.00
#> 2 c a 2.00
#> 3 a b 1.00
#> 4 e b 1.00
#> 5 f b 1.00
#> 6 a c 2.00
#> 7 b e 1.00
#> 8 b f 1.00
I would try updating to the latest versions of widyr and dplyr and check it out again.
After updating to R 3.4.4, I was getting a similar warning from pairwise_count (warning from distinct()) , and reinstalling did not fix the error, I eventually got a bindrcpp error about "bindrcpp_RcppExport_validate" not being in bindrcpp, that led me to https://github.com/tidyverse/dplyr/issues/3079.
I fixed the warning by following the comment in the tidyverse issue by doing:
remove.packages(c("dplyr", "Rcpp", "bindr", "bindrcpp", "BH", "glue", "rlang")) and then of course: install.packages(c("dplyr", "Rcpp", "bindr", "bindrcpp", "BH", "glue", "rlang"))
Though I suspect just removing and installing "bindrcpp" may have fixed it.
I also get the error when I try to run the pairwise_count example code.
I tried
remove.packages(c("dplyr", "Rcpp", "bindr", "bindrcpp", "BH", "glue", "rlang")) and then of course: install.packages(c("dplyr", "Rcpp", "bindr", "bindrcpp", "BH", "glue", "rlang")).
as suggested by jayjacobs, but still got the error.
library(widyr)
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
dat <- data_frame(group = rep(1:5, each = 2),
letter = c("a", "b",
"a", "c",
"a", "c",
"b", "e",
"b", "f"))
# count the number of times two letters appear together
pairwise_count(dat, letter, group)
#> Warning: Trying to compute distinct() for variables not found in the data:
#> - `row_col`, `column_col`
#> This is an error, but only a warning is raised for compatibility reasons.
#> The operation will return the input unchanged.
#> # A tibble: 8 x 3
#> item1 item2 n
#> <chr> <chr> <dbl>
#> 1 b a 1
#> 2 c a 2
#> 3 a b 1
#> 4 e b 1
#> 5 f b 1
#> 6 a c 2
#> 7 b e 1
#> 8 b f 1
Created on 2018-07-31 by the reprex package (v0.2.0).
Just tried the same code on my windows machine at work and got the same error.
I googled the error message and saw that it came from something in tidytext that was fixed in June. After I installed tidytext from GitHub. Now I have version of 0.1.9.900 in tidytext and the pairwise_count example works without an error message.
It seems that the error still persits:
dat <- tibble(group = rep(1:5, each = 2),
letter = c("a", "b",
"a", "c",
"a", "c",
"b", "e",
"b", "f"))
pairwise_count(dat, letter, group)
Error in `colnames<-`(`*tmp*`, value = c("item1", "item2", "value")) :
attempt to set 'colnames' on an object with less than two dimensions
Any idea what to do?
sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Manjaro Linux
Matrix products: default
BLAS: /usr/lib/libblas.so.3.9.0
LAPACK: /usr/lib/liblapack.so.3.9.0
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=sl_SI.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=sl_SI.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=sl_SI.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=sl_SI.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] tidytext_0.2.4 remotes_2.1.1 forcats_0.5.0 stringr_1.4.0
[5] purrr_0.3.3 tibble_3.0.0 ggplot2_3.3.0 tidyverse_1.3.0
[9] tidyr_1.0.2 readr_1.3.1 widyr_0.1.3 dplyr_0.8.99.9002
[13] stringi_1.4.6
loaded via a namespace (and not attached):
[1] tidyselect_1.0.0 haven_2.2.0 lattice_0.20-38 colorspace_1.4-1
[5] vctrs_0.2.99.9011 generics_0.0.2 SnowballC_0.7.0 rlang_0.4.5.9000
[9] pillar_1.4.3 glue_1.4.0 withr_2.1.2 DBI_1.1.0
[13] dbplyr_1.4.2 modelr_0.1.6 readxl_1.3.1 lifecycle_0.2.0
[17] munsell_0.5.0 gtable_0.3.0 cellranger_1.1.0 rvest_0.3.5
[21] curl_4.3 fansi_0.4.1 broom_0.5.3.9000 tokenizers_0.2.1
[25] Rcpp_1.0.4.6 scales_1.1.0 backports_1.1.6 jsonlite_1.6.1
[29] fs_1.4.1 hms_0.5.3 grid_3.6.3 cli_2.0.2
[33] tools_3.6.3 magrittr_1.5 janeaustenr_0.1.5 crayon_1.3.4
[37] pkgconfig_2.0.3 ellipsis_0.3.0 Matrix_1.2-18 xml2_1.3.1
[41] reprex_0.3.0 lubridate_1.7.8 assertthat_0.2.1 httr_1.4.1
[45] rstudioapi_0.11 R6_2.4.1 compiler_3.6.3
Have there been any updates to this error? I have been searching for a couple hours now and have not found a way to get this function example code to run without the same error mentioned above.
Have you tried installing the current GitHub version of widyr, and updating packages such as rlang and dplyr (with update.packages()
)?
devtools::install_github("dgrtwo/widyr")
I believe the one thing you should get right now is a warning about distinct_
:
library(widyr)
library(tibble)
dat <- tibble(group = rep(1:5, each = 2),
letter = c("a", "b",
"a", "c",
"a", "c",
"b", "e",
"b", "f"))
pairwise_count(dat, letter, group)
#> Warning: `distinct_()` is deprecated as of dplyr 0.7.0.
#> Please use `distinct()` instead.
#> See vignette('programming') for more help
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_warnings()` to see where this warning was generated.
#> # A tibble: 8 x 3
#> item1 item2 n
#> <chr> <chr> <dbl>
#> 1 b a 1
#> 2 c a 2
#> 3 a b 1
#> 4 e b 1
#> 5 f b 1
#> 6 a c 2
#> 7 b e 1
#> 8 b f 1
Created on 2020-07-15 by the reprex package (v0.3.0.9001)
Thank you! That was the issue! It was an outdated dplyr package. It is working now.
I'm still getting the same error. I've updated the packages and no luck. Any thoughts?
library(widyr)
library(tibble)
dat <- tibble(group = rep(1:5, each = 2),
` letter = c("a", "b",`
` "a", "c",`
"a", "c",
"b", "e",
"b", "f"))
pairwise_count(dat, letter, group)
Result:
Error in `colnames<-`(`*tmp*`, value = c("item1", "item2", "value")) : attempt to set 'colnames' on an object with less than two dimensions
Hi! I'm getting the same error as @rentheduke with the same code. I've also updated all the packages. Any ideas on how else to resolve the error? Thank you!
This has now been fixed in the new widyr 0.1.5 that just went to CRAN:
library(tidyverse)
library(widyr)
dat <- data_frame(group = rep(1:5, each = 2),
letter = c("a", "b",
"a", "c",
"a", "c",
"b", "e",
"b", "f"))
#> Warning: `data_frame()` was deprecated in tibble 1.1.0.
#> Please use `tibble()` instead.
pairwise_count(dat, letter, group)
#> # A tibble: 8 × 3
#> item1 item2 n
#> <chr> <chr> <dbl>
#> 1 b a 1
#> 2 c a 2
#> 3 a b 1
#> 4 e b 1
#> 5 f b 1
#> 6 a c 2
#> 7 b e 1
#> 8 b f 1
Created on 2022-09-13 with reprex v2.0.2
Thanks! 🙌
I'm having trouble getting the example from ?pairwise_count to run:
Results in:
Here's my session info: