I want to compute my data according to rule that number+W is number*2.
dat=\"1W 16 2W 16
1 16 2W 0
1W 16 16 0
4 64 6
Here's a rather bizarre approach, which does work just fine:
library(sfsmisc)
foo<- c('2','23', 'W4','W53','17')
bar<-sapply(foo, function(x)AsciiToInt(x))
barw<-sapply(bar,function(x)x[x!=87])
bard<-logical(length(foo))
for (i in 1:length(foo) ) bard[i]<-length(barw[[i]])== length(bar[[i]])
foow<-vector()
for(i in 1:length(foo)) foow[i]<-as.numeric(paste0(chars8bit(barw[[i]]),collapse='') ) *(1+!bard[i])