How to specify the library of the operator %+% such as pkg:: or pkg:::












2















The operator %+% are used in two packages, i.e., ggplot2 and crayou.



The function %+% in crayon sometimes not work, I think the operator %+% are considered in ggplot2. I try to identify by crayon::%+% but this does not work.



cat(green(
'I am a green line ' %+%
blue$underline$bold('with a blue substring') %+%
' that becomes green again!'
))


---- based on comments : I think the following error occur for my miss understanding--------



I try to run the following code using crayon::(backtick)%+%(backtick) instead of %+%



cat(green(
'I am a green line ' crayon::`%+%`
blue$underline$bold('with a blue substring') crayon::`%+%`
' that becomes green again!'
))


But the following error occurs:



  > cat(green(
+ 'I am a green line ' crayon::`%+%`
Error: unexpected symbol in:
"cat(green(
'I am a green line ' crayon"
> blue$underline$bold('with a blue substring') crayon::`%+%`
Error: unexpected symbol in " blue$underline$bold('with a blue substring') crayon"
> ' that becomes green again!'
[1] " that becomes green again!"
> ))
Error: unexpected ')' in ")"









share|improve this question




















  • 3





    try it with backticks, e.g. ggplot2::(backtick)%+%(backtick) -- unfortunately if I use backtick in comments it converts to code formating

    – gfgm
    Nov 21 '18 at 10:31








  • 1





    The import package also has a mechanism to deal with this kind of situation, with import::from(ggplot2, "+") for example.

    – meriops
    Nov 21 '18 at 11:14






  • 3





    crayon::`%+%` (just put backslashes before the backtick @gfgm)

    – hrbrmstr
    Nov 21 '18 at 12:42













  • Thank you @gfgm,and @hrbrmstr. I try the code crayon::%+%`, however it does not go well.

    – Camford Oxbridge
    Nov 22 '18 at 0:30













  • Thank you @meriops, I develop some package, so I can understand what you say and I think #'@importFrom crayon %+% may give the same solution ? Thank you for letting me the way use library(import"), I did not know this package.

    – Camford Oxbridge
    Nov 22 '18 at 0:37
















2















The operator %+% are used in two packages, i.e., ggplot2 and crayou.



The function %+% in crayon sometimes not work, I think the operator %+% are considered in ggplot2. I try to identify by crayon::%+% but this does not work.



cat(green(
'I am a green line ' %+%
blue$underline$bold('with a blue substring') %+%
' that becomes green again!'
))


---- based on comments : I think the following error occur for my miss understanding--------



I try to run the following code using crayon::(backtick)%+%(backtick) instead of %+%



cat(green(
'I am a green line ' crayon::`%+%`
blue$underline$bold('with a blue substring') crayon::`%+%`
' that becomes green again!'
))


But the following error occurs:



  > cat(green(
+ 'I am a green line ' crayon::`%+%`
Error: unexpected symbol in:
"cat(green(
'I am a green line ' crayon"
> blue$underline$bold('with a blue substring') crayon::`%+%`
Error: unexpected symbol in " blue$underline$bold('with a blue substring') crayon"
> ' that becomes green again!'
[1] " that becomes green again!"
> ))
Error: unexpected ')' in ")"









share|improve this question




















  • 3





    try it with backticks, e.g. ggplot2::(backtick)%+%(backtick) -- unfortunately if I use backtick in comments it converts to code formating

    – gfgm
    Nov 21 '18 at 10:31








  • 1





    The import package also has a mechanism to deal with this kind of situation, with import::from(ggplot2, "+") for example.

    – meriops
    Nov 21 '18 at 11:14






  • 3





    crayon::`%+%` (just put backslashes before the backtick @gfgm)

    – hrbrmstr
    Nov 21 '18 at 12:42













  • Thank you @gfgm,and @hrbrmstr. I try the code crayon::%+%`, however it does not go well.

    – Camford Oxbridge
    Nov 22 '18 at 0:30













  • Thank you @meriops, I develop some package, so I can understand what you say and I think #'@importFrom crayon %+% may give the same solution ? Thank you for letting me the way use library(import"), I did not know this package.

    – Camford Oxbridge
    Nov 22 '18 at 0:37














2












2








2








The operator %+% are used in two packages, i.e., ggplot2 and crayou.



The function %+% in crayon sometimes not work, I think the operator %+% are considered in ggplot2. I try to identify by crayon::%+% but this does not work.



cat(green(
'I am a green line ' %+%
blue$underline$bold('with a blue substring') %+%
' that becomes green again!'
))


---- based on comments : I think the following error occur for my miss understanding--------



I try to run the following code using crayon::(backtick)%+%(backtick) instead of %+%



cat(green(
'I am a green line ' crayon::`%+%`
blue$underline$bold('with a blue substring') crayon::`%+%`
' that becomes green again!'
))


But the following error occurs:



  > cat(green(
+ 'I am a green line ' crayon::`%+%`
Error: unexpected symbol in:
"cat(green(
'I am a green line ' crayon"
> blue$underline$bold('with a blue substring') crayon::`%+%`
Error: unexpected symbol in " blue$underline$bold('with a blue substring') crayon"
> ' that becomes green again!'
[1] " that becomes green again!"
> ))
Error: unexpected ')' in ")"









share|improve this question
















The operator %+% are used in two packages, i.e., ggplot2 and crayou.



The function %+% in crayon sometimes not work, I think the operator %+% are considered in ggplot2. I try to identify by crayon::%+% but this does not work.



cat(green(
'I am a green line ' %+%
blue$underline$bold('with a blue substring') %+%
' that becomes green again!'
))


---- based on comments : I think the following error occur for my miss understanding--------



I try to run the following code using crayon::(backtick)%+%(backtick) instead of %+%



cat(green(
'I am a green line ' crayon::`%+%`
blue$underline$bold('with a blue substring') crayon::`%+%`
' that becomes green again!'
))


But the following error occurs:



  > cat(green(
+ 'I am a green line ' crayon::`%+%`
Error: unexpected symbol in:
"cat(green(
'I am a green line ' crayon"
> blue$underline$bold('with a blue substring') crayon::`%+%`
Error: unexpected symbol in " blue$underline$bold('with a blue substring') crayon"
> ' that becomes green again!'
[1] " that becomes green again!"
> ))
Error: unexpected ')' in ")"






r ggplot2






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 '18 at 3:00







Camford Oxbridge

















asked Nov 21 '18 at 10:20









Camford OxbridgeCamford Oxbridge

1019




1019








  • 3





    try it with backticks, e.g. ggplot2::(backtick)%+%(backtick) -- unfortunately if I use backtick in comments it converts to code formating

    – gfgm
    Nov 21 '18 at 10:31








  • 1





    The import package also has a mechanism to deal with this kind of situation, with import::from(ggplot2, "+") for example.

    – meriops
    Nov 21 '18 at 11:14






  • 3





    crayon::`%+%` (just put backslashes before the backtick @gfgm)

    – hrbrmstr
    Nov 21 '18 at 12:42













  • Thank you @gfgm,and @hrbrmstr. I try the code crayon::%+%`, however it does not go well.

    – Camford Oxbridge
    Nov 22 '18 at 0:30













  • Thank you @meriops, I develop some package, so I can understand what you say and I think #'@importFrom crayon %+% may give the same solution ? Thank you for letting me the way use library(import"), I did not know this package.

    – Camford Oxbridge
    Nov 22 '18 at 0:37














  • 3





    try it with backticks, e.g. ggplot2::(backtick)%+%(backtick) -- unfortunately if I use backtick in comments it converts to code formating

    – gfgm
    Nov 21 '18 at 10:31








  • 1





    The import package also has a mechanism to deal with this kind of situation, with import::from(ggplot2, "+") for example.

    – meriops
    Nov 21 '18 at 11:14






  • 3





    crayon::`%+%` (just put backslashes before the backtick @gfgm)

    – hrbrmstr
    Nov 21 '18 at 12:42













  • Thank you @gfgm,and @hrbrmstr. I try the code crayon::%+%`, however it does not go well.

    – Camford Oxbridge
    Nov 22 '18 at 0:30













  • Thank you @meriops, I develop some package, so I can understand what you say and I think #'@importFrom crayon %+% may give the same solution ? Thank you for letting me the way use library(import"), I did not know this package.

    – Camford Oxbridge
    Nov 22 '18 at 0:37








3




3





try it with backticks, e.g. ggplot2::(backtick)%+%(backtick) -- unfortunately if I use backtick in comments it converts to code formating

– gfgm
Nov 21 '18 at 10:31







try it with backticks, e.g. ggplot2::(backtick)%+%(backtick) -- unfortunately if I use backtick in comments it converts to code formating

– gfgm
Nov 21 '18 at 10:31






1




1





The import package also has a mechanism to deal with this kind of situation, with import::from(ggplot2, "+") for example.

– meriops
Nov 21 '18 at 11:14





The import package also has a mechanism to deal with this kind of situation, with import::from(ggplot2, "+") for example.

– meriops
Nov 21 '18 at 11:14




3




3





crayon::`%+%` (just put backslashes before the backtick @gfgm)

– hrbrmstr
Nov 21 '18 at 12:42







crayon::`%+%` (just put backslashes before the backtick @gfgm)

– hrbrmstr
Nov 21 '18 at 12:42















Thank you @gfgm,and @hrbrmstr. I try the code crayon::%+%`, however it does not go well.

– Camford Oxbridge
Nov 22 '18 at 0:30







Thank you @gfgm,and @hrbrmstr. I try the code crayon::%+%`, however it does not go well.

– Camford Oxbridge
Nov 22 '18 at 0:30















Thank you @meriops, I develop some package, so I can understand what you say and I think #'@importFrom crayon %+% may give the same solution ? Thank you for letting me the way use library(import"), I did not know this package.

– Camford Oxbridge
Nov 22 '18 at 0:37





Thank you @meriops, I develop some package, so I can understand what you say and I think #'@importFrom crayon %+% may give the same solution ? Thank you for letting me the way use library(import"), I did not know this package.

– Camford Oxbridge
Nov 22 '18 at 0:37












1 Answer
1






active

oldest

votes


















1














One option is to not library(crayon) or requireNamespace(crayon) and fully qualify all crayon references:



cat(crayon::green(
'I am a green line ' %c+%
crayon::blue$underline$bold('with a blue substring') crayon::`%+%`
' that becomes green again!'
))


That's annoying, though. So, you can also hand-import and rename things you need without the need for a separate, non-core package:



`%c+%` <- getFromNamespace("%+%", "crayon") # changed to not break other things
green <- getFromNamespace("green", "crayon")
blue <- getFromNamespace("blue", "crayon")

cat(green(
'I am a green line ' %c+%
blue$underline$bold('with a blue substring') %c+%
' that becomes green again!'
))





share|improve this answer
























  • I can’t think of such good codes. Allow me to use your code in my package.

    – Camford Oxbridge
    Nov 22 '18 at 0:47











  • Note that the first code of @hrbrmstr 's does not go well ( even if after fixing from $%c+%$ to $%+%$. So, as I said in above comment, crayon::(backtick)%+%(backtick) does not go well.

    – Camford Oxbridge
    Nov 22 '18 at 1:15













  • You are doing something amiss then

    – hrbrmstr
    Nov 22 '18 at 2:49











  • So many people suggest the code crayon::(backtick)%+%(backtick), it would go well in their PC. I think I am somthing wrong, but I cannot come up.

    – Camford Oxbridge
    Nov 22 '18 at 2:58











  • I guess I'd also add "what are these superfluous colors adding to your message that plaintext can't convey?" but ultra-sensitive SO moderators might interpret that as being mean (so I can't "win" either way)

    – hrbrmstr
    Nov 22 '18 at 3:07











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53409877%2fhow-to-specify-the-library-of-the-operator-such-as-pkg-or-pkg%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














One option is to not library(crayon) or requireNamespace(crayon) and fully qualify all crayon references:



cat(crayon::green(
'I am a green line ' %c+%
crayon::blue$underline$bold('with a blue substring') crayon::`%+%`
' that becomes green again!'
))


That's annoying, though. So, you can also hand-import and rename things you need without the need for a separate, non-core package:



`%c+%` <- getFromNamespace("%+%", "crayon") # changed to not break other things
green <- getFromNamespace("green", "crayon")
blue <- getFromNamespace("blue", "crayon")

cat(green(
'I am a green line ' %c+%
blue$underline$bold('with a blue substring') %c+%
' that becomes green again!'
))





share|improve this answer
























  • I can’t think of such good codes. Allow me to use your code in my package.

    – Camford Oxbridge
    Nov 22 '18 at 0:47











  • Note that the first code of @hrbrmstr 's does not go well ( even if after fixing from $%c+%$ to $%+%$. So, as I said in above comment, crayon::(backtick)%+%(backtick) does not go well.

    – Camford Oxbridge
    Nov 22 '18 at 1:15













  • You are doing something amiss then

    – hrbrmstr
    Nov 22 '18 at 2:49











  • So many people suggest the code crayon::(backtick)%+%(backtick), it would go well in their PC. I think I am somthing wrong, but I cannot come up.

    – Camford Oxbridge
    Nov 22 '18 at 2:58











  • I guess I'd also add "what are these superfluous colors adding to your message that plaintext can't convey?" but ultra-sensitive SO moderators might interpret that as being mean (so I can't "win" either way)

    – hrbrmstr
    Nov 22 '18 at 3:07
















1














One option is to not library(crayon) or requireNamespace(crayon) and fully qualify all crayon references:



cat(crayon::green(
'I am a green line ' %c+%
crayon::blue$underline$bold('with a blue substring') crayon::`%+%`
' that becomes green again!'
))


That's annoying, though. So, you can also hand-import and rename things you need without the need for a separate, non-core package:



`%c+%` <- getFromNamespace("%+%", "crayon") # changed to not break other things
green <- getFromNamespace("green", "crayon")
blue <- getFromNamespace("blue", "crayon")

cat(green(
'I am a green line ' %c+%
blue$underline$bold('with a blue substring') %c+%
' that becomes green again!'
))





share|improve this answer
























  • I can’t think of such good codes. Allow me to use your code in my package.

    – Camford Oxbridge
    Nov 22 '18 at 0:47











  • Note that the first code of @hrbrmstr 's does not go well ( even if after fixing from $%c+%$ to $%+%$. So, as I said in above comment, crayon::(backtick)%+%(backtick) does not go well.

    – Camford Oxbridge
    Nov 22 '18 at 1:15













  • You are doing something amiss then

    – hrbrmstr
    Nov 22 '18 at 2:49











  • So many people suggest the code crayon::(backtick)%+%(backtick), it would go well in their PC. I think I am somthing wrong, but I cannot come up.

    – Camford Oxbridge
    Nov 22 '18 at 2:58











  • I guess I'd also add "what are these superfluous colors adding to your message that plaintext can't convey?" but ultra-sensitive SO moderators might interpret that as being mean (so I can't "win" either way)

    – hrbrmstr
    Nov 22 '18 at 3:07














1












1








1







One option is to not library(crayon) or requireNamespace(crayon) and fully qualify all crayon references:



cat(crayon::green(
'I am a green line ' %c+%
crayon::blue$underline$bold('with a blue substring') crayon::`%+%`
' that becomes green again!'
))


That's annoying, though. So, you can also hand-import and rename things you need without the need for a separate, non-core package:



`%c+%` <- getFromNamespace("%+%", "crayon") # changed to not break other things
green <- getFromNamespace("green", "crayon")
blue <- getFromNamespace("blue", "crayon")

cat(green(
'I am a green line ' %c+%
blue$underline$bold('with a blue substring') %c+%
' that becomes green again!'
))





share|improve this answer













One option is to not library(crayon) or requireNamespace(crayon) and fully qualify all crayon references:



cat(crayon::green(
'I am a green line ' %c+%
crayon::blue$underline$bold('with a blue substring') crayon::`%+%`
' that becomes green again!'
))


That's annoying, though. So, you can also hand-import and rename things you need without the need for a separate, non-core package:



`%c+%` <- getFromNamespace("%+%", "crayon") # changed to not break other things
green <- getFromNamespace("green", "crayon")
blue <- getFromNamespace("blue", "crayon")

cat(green(
'I am a green line ' %c+%
blue$underline$bold('with a blue substring') %c+%
' that becomes green again!'
))






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 21 '18 at 12:49









hrbrmstrhrbrmstr

60.9k688150




60.9k688150













  • I can’t think of such good codes. Allow me to use your code in my package.

    – Camford Oxbridge
    Nov 22 '18 at 0:47











  • Note that the first code of @hrbrmstr 's does not go well ( even if after fixing from $%c+%$ to $%+%$. So, as I said in above comment, crayon::(backtick)%+%(backtick) does not go well.

    – Camford Oxbridge
    Nov 22 '18 at 1:15













  • You are doing something amiss then

    – hrbrmstr
    Nov 22 '18 at 2:49











  • So many people suggest the code crayon::(backtick)%+%(backtick), it would go well in their PC. I think I am somthing wrong, but I cannot come up.

    – Camford Oxbridge
    Nov 22 '18 at 2:58











  • I guess I'd also add "what are these superfluous colors adding to your message that plaintext can't convey?" but ultra-sensitive SO moderators might interpret that as being mean (so I can't "win" either way)

    – hrbrmstr
    Nov 22 '18 at 3:07



















  • I can’t think of such good codes. Allow me to use your code in my package.

    – Camford Oxbridge
    Nov 22 '18 at 0:47











  • Note that the first code of @hrbrmstr 's does not go well ( even if after fixing from $%c+%$ to $%+%$. So, as I said in above comment, crayon::(backtick)%+%(backtick) does not go well.

    – Camford Oxbridge
    Nov 22 '18 at 1:15













  • You are doing something amiss then

    – hrbrmstr
    Nov 22 '18 at 2:49











  • So many people suggest the code crayon::(backtick)%+%(backtick), it would go well in their PC. I think I am somthing wrong, but I cannot come up.

    – Camford Oxbridge
    Nov 22 '18 at 2:58











  • I guess I'd also add "what are these superfluous colors adding to your message that plaintext can't convey?" but ultra-sensitive SO moderators might interpret that as being mean (so I can't "win" either way)

    – hrbrmstr
    Nov 22 '18 at 3:07

















I can’t think of such good codes. Allow me to use your code in my package.

– Camford Oxbridge
Nov 22 '18 at 0:47





I can’t think of such good codes. Allow me to use your code in my package.

– Camford Oxbridge
Nov 22 '18 at 0:47













Note that the first code of @hrbrmstr 's does not go well ( even if after fixing from $%c+%$ to $%+%$. So, as I said in above comment, crayon::(backtick)%+%(backtick) does not go well.

– Camford Oxbridge
Nov 22 '18 at 1:15







Note that the first code of @hrbrmstr 's does not go well ( even if after fixing from $%c+%$ to $%+%$. So, as I said in above comment, crayon::(backtick)%+%(backtick) does not go well.

– Camford Oxbridge
Nov 22 '18 at 1:15















You are doing something amiss then

– hrbrmstr
Nov 22 '18 at 2:49





You are doing something amiss then

– hrbrmstr
Nov 22 '18 at 2:49













So many people suggest the code crayon::(backtick)%+%(backtick), it would go well in their PC. I think I am somthing wrong, but I cannot come up.

– Camford Oxbridge
Nov 22 '18 at 2:58





So many people suggest the code crayon::(backtick)%+%(backtick), it would go well in their PC. I think I am somthing wrong, but I cannot come up.

– Camford Oxbridge
Nov 22 '18 at 2:58













I guess I'd also add "what are these superfluous colors adding to your message that plaintext can't convey?" but ultra-sensitive SO moderators might interpret that as being mean (so I can't "win" either way)

– hrbrmstr
Nov 22 '18 at 3:07





I guess I'd also add "what are these superfluous colors adding to your message that plaintext can't convey?" but ultra-sensitive SO moderators might interpret that as being mean (so I can't "win" either way)

– hrbrmstr
Nov 22 '18 at 3:07




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53409877%2fhow-to-specify-the-library-of-the-operator-such-as-pkg-or-pkg%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

'app-layout' is not a known element: how to share Component with different Modules

android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

WPF add header to Image with URL pettitions [duplicate]