Question: My data frame looks like:

```
b <- data.frame(height = c(190,165,174,176), name = c('John Smith 34','Mr.Turner 54', 'Antonio P. 23', 'John Brown 31'))

#   height          name
# 1    190 John Smith 34
# 2    165  Mr.Turner 54
# 3    174 Antonio P. 23
# 4    176 John Brown 31

```

As we can see name and age are the same value. So I want to split it by last two characters in string:

```
  height       name age
1    190 John Smith  34
2    165  Mr.Turner  54
3    174 Antonio P.  23
4    176 John Brown  31

```

How I can do that?

Answer: 
many options here using regular expression.I would use `substr` because you want know exactly the number of characters to extract. 

Within `data.table` (for syntax-sugar):

```
library(data.table)
setDT(b)[,c("name","age"):=list(
  substr(name,1,nchar(name)-3),
  substr(name,nchar(name)-2,nchar(name)))]

   height       name age
1:    190 John Smith  34
2:    165  Mr.Turner  54
3:    174 Antonio P.  23
4:    176 John Brown  31

```

Note that *name* should be a `character` :

```
  b <- data.frame(
  height = c(190,165,174,176), 
  name = c('John Smith 34','Mr.Turner 54', 'Antonio P. 23', 'John Brown 31'),
  stringsAsFactors = FALSE)

```
With base R (the same data used in @agstudy's answer):

```
data.frame(t(apply(b,1,function(x) {s <- unlist(strsplit(trimws(x[2]), " "));
           c(x[1],paste0(head(s,-1),collapse=" "),tail(s,1)) })))

   # X1         X2 X3
# 1 190 John Smith 34
# 2 165  Mr.Turner 54
# 3 174 Antonio P. 23
# 4 176 John Brown 31

```

To be on the safe side, we split the *trimmed* `name` column by space (i.e. `strsplit(trimws(x[2]), " ")`) and take the last part (i.e. `tail(s,1)`) as `age` and the rest (i.e. `head(s,-1)`) as name.