t;ppbzJG" "ppbzJG"
A.K.
From: Christofer Bogaso
To: arun
Cc: R help ; Bert Gunter
Sent: Sunday, August 11, 2013 2:19 PM
Subject: Re: [R] Working with string
Hello Arun,
Thank you for your prompt reply.
However if I use your new code, I am no
Christopher:
Yes, I warned you about both cases: In your second example there is no
match since there is no nonupper case version of the all upper case
entries. As you did not specify what should be done in that case, I
leave it to you to figure out the necessary modifications of my code.
Possibl
t; chnew[duplicated(toupper(CH1))]<-
> CH1[duplicated(toupper(CH1),fromLast=TRUE)]
> sort(chnew)
> #[1] "MRTZIt" "MRTZIt" "ppbzJG" "ppbzJG"
> A.K.
>
>
>
>
> From: Christofer Bogaso
> To: Bert G
MRTZIt" "ppbzJG" "ppbzJG"
A.K.
From: Christofer Bogaso
To: Bert Gunter
Cc: arun ; R help
Sent: Sunday, August 11, 2013 1:54 PM
Subject: Re: [R] Working with string
Thanks Bert and Arun for your help.
As Bert already pointed out, Arun's co
Thanks Bert and Arun for your help.
As Bert already pointed out, Arun's code is working well, however except
this:
> CH <- c("MRTZIt", "MRTZIT", "PPBZJG", "ppbzJG")
> chnew<-CH
> chnew[duplicated(toupper(CH))]<-CH[duplicated(toupper(CH),fromLast=TRUE)]
> CH
[1] "MRTZIt" "MRTZIT" "PPBZJG" "ppbzJG"
Well, maybe: it assumes that the uppercase string version always
occurs after the nonuppercase version. That's why I rejected it.
However, it points out something important: details matter. The more
one knows about the nature of the problem, the better the solution one
can tailor -- a remark for w
Hi,
May be this helps:
chnew<-CH
chnew[duplicated(toupper(CH))]<-CH[duplicated(toupper(CH),fromLast=TRUE)]
chnew
#[1] "aBd" "sTb" "aBd" "dFDasd" "asd" "dFDasd"
A.K.
- Original Message -
From: Christofer Bogaso
To: r-help
Cc:
Sent: Sunday, August 11, 2013 8:39 AM
Subjec
Oh, sorry. One type. Here's the correct version
On Sun, Aug 11, 2013 at 7:54 AM, Bert Gunter wrote:
> Christofer:
>
> You may have to fortify the following a bit to allow for the
> possibility that some of your caps strings don't match. But other than
> that, I think this will do:
>
>> CH <- c("a
Christofer:
You may have to fortify the following a bit to allow for the
possibility that some of your caps strings don't match. But other than
that, I think this will do:
> CH <- c("aBd", "sTb", "ABD", "dFDasd", "asd", "DFDASD")
> caps <- CH %in% z
> noncaps <- CH[!caps]
> chnew <- CH
> chnew[ca
format(Vec,justify="right")
#[1] " sada" "asdsa" " sa"
A.K.
- Original Message -
From: Marc Schwartz
To: Christofer Bogaso
Cc: r-help
Sent: Thursday, March 14, 2013 11:02 AM
Subject: Re: [R] Working with string
On Mar 14, 2013, at 9:42 AM, Christofe
Duhhh... You already knew about nchar!!
So (untested):
nc <- nchar(vec)
mx <- max(nc)
blanks <- rep(" ",mx-nchar+1) ## +1 needed for rep
paddedvec <-substring(paste(vec,blanks,sep=""),1,mx)
You can also do this at one go with str_pad in the stringr package, found
by searching on "pad strings.'
On Mar 14, 2013, at 9:42 AM, Christofer Bogaso
wrote:
> Hello again,
>
> Let say I have following string:
>
> Vec <- c("sada", "asdsa", "sa")
>
> Now I want to make each element of this vector with equal length.
> Basically I want following vector:
>
> c("sada ", "asdsa", "sa ")
>
> There
library(stringr)
str_pad(Vec,5,"right")
#[1] "sada " "asdsa" "sa "
#or
str_pad(Vec,max(nchar(Vec)),"right")
#[1] "sada " "asdsa" "sa "
str_count(str_pad(Vec,5,"right"),"")
#[1] 5 5 5
A.K.
- Original Message -
From: Christofer Bogaso
To: r-help
Cc:
Sent: Thursday, March 14, 20
?nchar will tell you how many characters are in each string (mod multibyte
locales)
and you can use this to extend any that are shorter than the max with
blanks or whatever.
-- Bert
On Thu, Mar 14, 2013 at 7:42 AM, Christofer Bogaso <
bogaso.christo...@gmail.com> wrote:
> Hello again,
>
> Let
nks,
>
> -Original Message-
> From: Marc Schwartz [mailto:marc_schwa...@me.com]
> Sent: 07 July 2011 21:54
> To: Bogaso Christofer
> Cc: r-help@r-project.org
> Subject: Re: [R] Working with string
>
> On Jul 7, 2011, at 11:21 AM, Bogaso Christofer wrote:
>
t: 07 July 2011 21:54
To: Bogaso Christofer
Cc: r-help@r-project.org
Subject: Re: [R] Working with string
On Jul 7, 2011, at 11:21 AM, Bogaso Christofer wrote:
> Hi there, I have to extract some relevant portion from a defined
> string, which is a mix of numeric and character. However this
On Jul 7, 2011, at 11:21 AM, Bogaso Christofer wrote:
> Hi there, I have to extract some relevant portion from a defined string,
> which is a mix of numeric and character. However this has following
> sequence:
>
>
>
> Some String - Some numerical - "c/C" (or "p/P") - then again some set of
> n
17 matches
Mail list logo