Re: [R] Working with string

2013-08-11 Thread arun
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

Re: [R] Working with string

2013-08-11 Thread Bert Gunter
But posters frequently seem to disregard this. >> >> -- Bert >> >> On Sun, Aug 11, 2013 at 8:43 AM, arun wrote: >> > >> > >> > Hi, >> > >> > May be this helps: >> > chnew<-CH >> > >> > chnew[dupli

Re: [R] Working with string

2013-08-11 Thread Christofer Bogaso
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

Re: [R] Working with string

2013-08-11 Thread arun
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

Re: [R] Working with string

2013-08-11 Thread Christofer Bogaso
;well duhhh!" > But posters frequently seem to disregard this. > > -- Bert > > On Sun, Aug 11, 2013 at 8:43 AM, arun wrote: > > > > > > Hi, > > > > May be this helps: > > chnew<-CH > > > chnew[duplicated(toupper(CH))]<-CH[dup

Re: [R] Working with string

2013-08-11 Thread Bert Gunter
mLast=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:3

Re: [R] Working with string

2013-08-11 Thread arun
fer Bogaso To: r-help Cc: Sent: Sunday, August 11, 2013 8:39 AM Subject: [R] Working with string Hello again, Let say I have a lengthy character vector like: CH <- c("aBd", "sTb", "ABD", "dFDasd", "asd", "DFDASD") Now I want to create

Re: [R] Working with string

2013-08-11 Thread Bert Gunter
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

Re: [R] Working with string

2013-08-11 Thread Bert Gunter
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

[R] Working with string

2013-08-11 Thread Christofer Bogaso
Hello again, Let say I have a lengthy character vector like: CH <- c("aBd", "sTb", "ABD", "dFDasd", "asd", "DFDASD") Now I want to create a vector like: CH_New <- c("aBd", "sTb", "aBd", "dFDasd", "asd", "dFDasd") ## the 3rd and 6th element replaced Basically, the goal is: If an element has a

Re: [R] Working with string

2013-03-14 Thread arun
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

Re: [R] Working with string

2013-03-14 Thread Bert Gunter
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.'

Re: [R] Working with string

2013-03-14 Thread Marc Schwartz
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

Re: [R] Working with string

2013-03-14 Thread arun
K. - Original Message - From: Christofer Bogaso To: r-help Cc: Sent: Thursday, March 14, 2013 10:42 AM Subject: [R] Working with string Hello again, Let say I have following string: Vec <- c("sada", "asdsa", "sa") Now I want to make each element of th

Re: [R] Working with string

2013-03-14 Thread Bert Gunter
?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

[R] Working with string

2013-03-14 Thread Christofer Bogaso
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 ") Therefore we can get: > nchar(c("sada ", "asdsa", "sa ")) [1] 5 5 5 Is there any

Re: [R] Working with string

2011-07-07 Thread Marc Schwartz
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: >

Re: [R] Working with string

2011-07-07 Thread Bogaso Christofer
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

Re: [R] Working with string

2011-07-07 Thread Marc Schwartz
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

[R] Working with string

2011-07-07 Thread Bogaso Christofer
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 numbers. Examples of such string is "fdahsdfcha163517253c463278643"