Dear Dennis/Santosh
Got some ideas from both your suggestions.. Here is what finally i derived
as a solution to my problem..
The final R object string2 holds what i want now as a vector of substrings
of the desired length derived from the main string.
string<-"ABC DEFG HIJKLM NOPQ RSTUV WXY"
stri
Hi:
I think I misread your intentions the first time. Is this more in line
with what you want?
f <- function(s) {
ssp <- unlist(strsplit(string, ""))
n <- length(ssp)
splits <- grep(' ', ssp)
sapply(splits, function(x) paste(ssp[-(1:x)], collapse = ""))
}
> f(string)
[1] "D
Is this what you're looking for?
string <- "ABC DEFG HIJKLM NOPQ RSTUV WXY"
unlist(strsplit(string, " "))
[1] "ABC""DEFG" "HIJKLM" "NOPQ" "RSTUV" "WXY"
HTH,
Dennis
On Sat, Jun 18, 2011 at 1:36 AM, Vijayan Padmanabhan
wrote:
> Dear R Group
> Here is what i am trying to do.. but couldnt
Hello Vijayan,
Depending on your end goal the following could possibly help
substr(string,nchar(string1)+1, nchar(string))
or
strsplit(string," ")
HTH,
Santosh
On Sat, Jun 18, 2011 at 2:06 PM, Vijayan Padmanabhan
wrote:
> Dear R Group
> Here is what i am trying to do.. but couldnt figure ou
Dear R Group
Here is what i am trying to do.. but couldnt figure out how..
string<-"ABC DEFG HIJKLM NOPQ RSTUV WXY"
string1<-substr(string,1,4)
I want to create an R object string 2 ( following the logic shown).. R does
not allow string subtraction.. any suggestions how to achieve this?
string
5 matches
Mail list logo