Hello,

This seems to be a conflict with a generic function margin() from another package you might have loaded. ggplot::margin is not generic, therefore there are no methods for it. And its arguments have default values, it wouldn't throw an error even when called with no arguments. (As it is in theme_tq).

The code I have loaded is

getAnywhere('margin')
A single object matching ‘margin’ was found
It was found in the following places
  package:ggplot2
  namespace:ggplot2
with value

function (t = 0, r = 0, b = 0, l = 0, unit = "pt")
{
    u <- unit(c(t, r, b, l), unit)
    class(u) <- c("margin", class(u))
    u
}
<bytecode: 0x78cc180>
<environment: namespace:ggplot2>


This is called 3 times in theme_tq and none of them causes problems.


Hope this helps,

Rui Barradas

Às 19:10 de 12/06/19, Bill Poling escreveu:
Well spoke too soon, maybe not for me Rui, weird?

g1 <- ednet %>%
+   ggplot(aes(Date2,NetEditRev)) +
+   geom_line(alpha=0.5, color = "#2c3e50") +
+   geom_smooth(method = "loess", span= 0.5) +#Fix Loess to loess
+   theme_tq()
Error in UseMethod("margin") :
   no applicable method for 'margin' applied to an object of class "NULL"

WHP


From: Rui Barradas <ruipbarra...@sapo.pt>
Sent: Wednesday, June 12, 2019 2:03 PM
To: Bill Poling <bill.pol...@zelis.com>; r-help (r-help@r-project.org) 
<r-help@r-project.org>
Subject: Re: [R] Please help with ggplot error

Hello,

Works with me, as soon as I corrected "Loess" to "loess".

Hope this helps,

Rui Barradas

Às 18:56 de 12/06/19, Bill Poling escreveu:

#RStudio Version 1.2.1335
sessionInfo()
#R version 3.6.0 Patched (2019-05-19 r76539)
#Platform: x86_64-w64-mingw32/x64 (64-bit)
#Running under: Windows 10 x64 (build 17134)

Hello

I am getting an error for which I have googled to remedy but have not found a 
resource for it.

I found this but it seems to pertain to ggmap?
https://stackoverflow.com/questions/52371655/ggmap-errors-when-using-aesthetics-beyond-x-y

#Error in UseMethod("margin") :
#no applicable method for 'margin' applied to an object of class "NULL"

I hope someone recognizes this error and can help me solve it .

Thank you.

str(ednet)

# Classes 'data.table' and 'data.frame':892 obs. of 2 variables:
# $ Date2 : Date, format: "2017-01-01" "2017-01-02" "2017-01-03" "2017-01-04" 
...
# $ NetEditRev: num -923 19222 -8397 37697 46075 ...
# - attr(*, ".internal.selfref")=<externalptr>

summary(ednet)
Date2 NetEditRev
Min. :2017-01-01 Min. :-176182.7500
1st Qu.:2017-08-11 1st Qu.: 2553.5700
Median :2018-03-22 Median : 49212.5800
Mean :2018-03-22 Mean : 45265.6394
3rd Qu.:2018-10-31 3rd Qu.: 75108.0175
Max. :2019-06-11 Max. : 164891.2500

head(ednet,n=35)
Date2 NetEditRev
1: 2017-01-01 -923.40
2: 2017-01-02 19222.09
3: 2017-01-03 -8396.82
4: 2017-01-04 37696.58
5: 2017-01-05 46075.34
6: 2017-01-06 38329.35
7: 2017-01-07 3110.51
8: 2017-01-08 21.39
9: 2017-01-09 63569.67
10: 2017-01-10 50777.00
11: 2017-01-11 55548.60
12: 2017-01-12 70217.73
13: 2017-01-13 62536.15
14: 2017-01-14 2696.83
15: 2017-01-15 2230.00
16: 2017-01-16 56310.90
17: 2017-01-17 58521.93
18: 2017-01-18 50057.73
19: 2017-01-19 57366.70
20: 2017-01-20 61390.94
21: 2017-01-21 1839.09
22: 2017-01-22 807.57
23: 2017-01-23 72209.44
24: 2017-01-24 70799.21
25: 2017-01-25 70240.88
26: 2017-01-26 51462.66
27: 2017-01-27 46852.37
28: 2017-01-28 2396.67
29: 2017-01-29 2051.62
30: 2017-01-30 72561.32
31: 2017-01-31 69630.69
32: 2017-02-01 -17304.22
33: 2017-02-02 11773.84
34: 2017-02-03 20703.69
35: 2017-02-04 2762.87


as_tibble(ednet)

# A tibble: 892 x 2
# Date2 NetEditRev
# <date> <dbl>
# 1 2017-01-01 -923.
# 2 2017-01-02 19222.
# 3 2017-01-03 -8397.
# 4 2017-01-04 37697.
# 5 2017-01-05 46075.
# 6 2017-01-06 38329.
# 7 2017-01-07 3111.
# 8 2017-01-08 21.4
# 9 2017-01-09 63570.
# 10 2017-01-10 50777
# ... with 882 more rows

#First blush look at the raw data
g1 <- ednet %>%
ggplot(aes(Date2,NetEditRev)) +
geom_line(alpha=0.5, color = "#2c3e50") +
geom_smooth(method = "Loess", span= 0.5) +
theme_tq()

#Error in UseMethod("margin") :
#no applicable method for 'margin' applied to an object of class "NULL"

WHP



Confidentiality Notice This message is sent from Zelis. ...{{dropped:13}}

______________________________________________
mailto:R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Confidentiality Notice This message is sent from Zelis. This transmission may 
contain information which is privileged and confidential and is intended for 
the personal and confidential use of the named recipient only. Such information 
may be protected by applicable State and Federal laws from this disclosure or 
unauthorized use. If the reader of this message is not the intended recipient, 
or the employee or agent responsible for delivering the message to the intended 
recipient, you are hereby notified that any disclosure, review, discussion, 
copying, or taking any action in reliance on the contents of this transmission 
is strictly prohibited. If you have received this transmission in error, please 
contact the sender immediately. Zelis, 2018.


______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to