[R] How to pass a character string with a hyphen

Jeff Reichman re|chm@nj @end|ng |rom @bcg|ob@|@net
Wed Nov 18 01:59:40 CET 2020



I ended up using the paste command, its not pretty but it works thank you




From: Robert Knight <bobby.knight using gmail.com> 
Sent: Tuesday, November 17, 2020 3:56 PM
To: reichmanj using sbcglobal.net
Cc: r-help using r-project.org
Subject: Re: [R] How to pass a character string with a hyphen


Strip the left characters and strip the right characters into their own variables using one of the methods that can do that.  Then pass it using something like paste(left, "-", right).


On Tue, Nov 17, 2020, 2:43 PM Jeff Reichman <reichmanj using sbcglobal.net <mailto:reichmanj using sbcglobal.net> > wrote:


How does one pass a character string containing a hyphen? I have a function
that accesses an api if I hard code the object, for example

key_key <- "xxxx-yyyy" 

it works but when I pass the key  code to the function (say something like
key_code <- code_input)  it returns only xxxx. So R is seeing a string with
a negative operator I'm assuming


        [[alternative HTML version deleted]]

R-help using r-project.org <mailto:R-help using r-project.org>  mailing list -- To UNSUBSCRIBE and more, see
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

	[[alternative HTML version deleted]]

More information about the R-help mailing list