Elegant I don't know, but I think the appended does the trick.
-- Mike
> foo <- c(" 1 X[0,SMITH] * 0 0 1 ",
+ " 2 X[0,JOHNSON] * 0 0 1 ",
+ " 3 X[0,WILLIAMS] * 1 0 1 ",
Hi Abhinaba,
I'm sure that someone will post a terrifyingly elegant regular
expression that does this, but:
ardat<-
c([1] " 1 X[0,SMITH] * 0 0 1 ",
...
numpoststar<-function(x) {
xsplit<-unlist(strsplit(x,""))
starpos<-which(xsplit=="*")
# watch out
On 23.01.2017 13:29, Abhinaba Roy wrote:
Hi,
How do I extract the first number after '*' in a vector?
The vector is given below
dput(out[1:10])
c(" 1 X[0,SMITH] * 0 0 1 ",
" 2 X[0,JOHNSON] * 0 0 1 ",
"
Hi,
How do I extract the first number after '*' in a vector?
The vector is given below
> dput(out[1:10])
c(" 1 X[0,SMITH] * 0 0 1 ",
" 2 X[0,JOHNSON] * 0 0 1 ",
" 3 X[0,WILLIAMS]", "*
4 matches
Mail list logo