dabestr icon indicating copy to clipboard operation
dabestr copied to clipboard

Error in xy.coords(x, y, xlabel, ylabel, log) : 'language' object cannot be coerced to type 'double'

Open benjaminwnelson opened this issue 4 years ago • 3 comments

Hello,

Thanks for this great package! I get the following error when I try to create the plot.

Error in xy.coords(x, y, xlabel, ylabel, log) : 'language' object cannot be coerced to type 'double'

benjaminwnelson avatar Nov 10 '20 22:11 benjaminwnelson

Hi Ben,

Could you kindly include a reproducible example to aid us?

Best, Joses

josesho avatar Nov 14 '20 00:11 josesho

Hello there, I get the same problem and would like to know what causes this!.

Here is a reproducible example, so that you have useful data to work with ;) .

data<- structure(list(sex = structure(c(2L, 1L, 1L, 2L, 1L, 2L, 1L, 
2L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 
1L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 1L, 2L, 
2L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 1L, 
2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 
2L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 
1L, 2L, 1L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 
1L, 2L, 2L), .Label = c("M", "F"), class = "factor"), treatment = structure(c(2L, 
1L, 2L, 1L, 1L, 2L, 1L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 1L, 1L, 1L, 
2L, 1L, 2L, 1L, 2L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 2L, 1L, 
1L, 2L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 
2L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 1L, 2L, 
1L, 2L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 1L, 2L, 1L, 
1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 
1L, 1L, 1L, 2L, 1L, 2L, 1L, 2L, 1L), .Label = c("no", "yes"), class = "factor"), 
    meancount = c(1.25, 3.25, 2.41666666666667, 2.16666666666667, 
    4.08333333333333, 6.66666666666667, 2.83333333333333, 12.1666666666667, 
    0.166666666666667, 3.25, 1.5, 1.41666666666667, 1.25, 0.0833333333333333, 
    0.166666666666667, 1.5, 0.625, 2.33333333333333, 3.5, 1.83333333333333, 
    0.916666666666667, 2, 3.91666666666667, 6.25, 4.41666666666667, 
    6.25, 5.16666666666667, 8, 0.25, 1, 3.5, 0.333333333333333, 
    0, 15.4166666666667, 4.41666666666667, 5, 6.25, 0.583333333333333, 
    3.25, 4.75, 6.58333333333333, 1.16666666666667, 8.16666666666667, 
    7, 3.5, 4.91666666666667, 9, 0.333333333333333, 5.33333333333333, 
    0.75, 0.583333333333333, 3.75, 7.58333333333333, 13.8333333333333, 
    0, 1.33333333333333, 0.25, 0.0833333333333333, 0, 0.0833333333333333, 
    0.0833333333333333, 0, 0.166666666666667, 0.25, 0.25, 2.16666666666667, 
    0.0833333333333333, 0.333333333333333, 0.0833333333333333, 
    1.33333333333333, 0.5, 0.0833333333333333, 0.0833333333333333, 
    0, 0, 3.66666666666667, 6.58333333333333, 9.91666666666667, 
    6.16666666666667, 8, 3.66666666666667, 8.83333333333333, 
    8.75, 9.58333333333333, 6.5, 16, 14.5, 6.41666666666667, 
    11.75, 10.25, 10.4166666666667, 13.75, 2.83333333333333, 
    6.58333333333333, 14.3333333333333, 10.8333333333333, 5, 
    0.166666666666667, 12.0833333333333, 7.25, 1.25, 3.16666666666667, 
    0.833333333333333, 0.166666666666667, 0.25, 0.5, 1.83333333333333, 
    2.33333333333333, 0.25, 0.25, 1.91666666666667, 3.5, 0.333333333333333, 
    0.5, 2.41666666666667, 0.0833333333333333, 3.25, 8.5, 3.33333333333333, 
    7.58333333333333, 0.833333333333333, 0.666666666666667)), row.names = c(1L, 
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 
16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 
29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 
42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 54L, 
55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L, 63L, 64L, 65L, 66L, 67L, 
68L, 69L, 70L, 71L, 72L, 73L, 74L, 75L, 76L, 77L, 78L, 79L, 80L, 
81L, 82L, 83L, 84L, 85L, 86L, 87L, 88L, 89L, 90L, 91L, 92L, 93L, 
94L, 95L, 96L, 97L, 98L, 99L, 100L, 101L, 102L, 103L, 104L, 105L, 
106L, 107L, 108L, 109L, 110L, 111L, 112L, 113L, 115L, 116L, 117L, 
118L, 119L, 120L, 121L, 122L, 123L), class = "data.frame")

then, when I try to run what I usually succeeded before:

two.group.unpaired <- 
sub %>% 
  dabest(treatment, meancount, 
         idx = c("no", "yes"), 
         paired = FALSE)

plot(two.group.unpaired, 
     color.column = sex,
     rawplot.markersize = 2,
     rawplot.groupwidth = 0.15, palette = "Dark2",
     rawplot.ylabel = "Mean count",
     effsize.ylabel = "Difference between treatment
(Bootstrap 95% C.I.)")

I get the following error message:

Error in xy.coords(x, y, xlabel, ylabel, log) : 
  'language' object cannot be coerced to type 'double'

florentdery avatar Dec 03 '20 16:12 florentdery

Oh, nevermind, I think I found my error. Instead of

plot(two.group.unpaired, 
     color.column = sex,
     rawplot.markersize = 2,
     rawplot.groupwidth = 0.15, palette = "Dark2",
     rawplot.ylabel = "Mean count",
     effsize.ylabel = "Difference between treatment
(Bootstrap 95% C.I.)")

I need to put mean_diff(two.group.unpaired) Now it works like a charm. In April, when I initially wrote this code, I did not have to do this, however. Maybe this will adress @benjaminwnelson 's problem.

florentdery avatar Dec 03 '20 17:12 florentdery