Question: I have a vector call id as below:

```
id<-c("US_01_01", "US_01_02", "US_01_03", "UK_02_01", "UK_02_02", "UK_02_03", "CA_03_01", "CA_03_02", "CA_03_03")

```

I wish to save the output in a format as below into an object called obj:

```
US  01  01
US  01  02
US  01  03
UK  02  01
UK  02  02
UK  02  03
CA  03  01
CA  03  02
CA  03  03

```

The following is my code:

```
sp<-strsplit(id,"_")

sp<-as.array(sp)

obj<-vector("list",dim(sp))

for (i in 1:dim(sp)){
    obj[[i]] <- cat(sprintf("%s %s %s\n", sp[[i]][1], sp[[i]][2], sp[[i]][3]))
}

```

However, I don't know why the the output can't be saved into the object obj.

Thank you for help!

Answer: 
`cat` does not have a return value. Getting rid of it...

```
for (i in 1:dim(sp)){
    obj[[i]] <- sprintf("%s %s %s\n", sp[[i]][1], sp[[i]][2], sp[[i]][3])
}

```

Now we can attach the items together:

```
obj_full <- do.call(paste0,obj)

```

And you can `cat` that any time you want:

```
cat(obj_full)
# US 01 01
# US 01 02
# US 01 03
# UK 02 01
# UK 02 02
# UK 02 03
# CA 03 01
# CA 03 02
# CA 03 03

```

Of course, if you want to `cat` during the loop as well, you can just add another line for that. 

---

**Finding documentation.** The "Value" section on the help page, `?cat`, explains that it returns nothing. This section is sometimes omitted, so it's also worth reviewing the "Description" section.
Try `read.table`

```
 read.table(text=id, sep='_', colClasses=rep('character',3))
 #  V1 V2 V3
 #1 US 01 01
 #2 US 01 02
 #3 US 01 03
 #4 UK 02 01
 #5 UK 02 02
 #6 UK 02 03
 #7 CA 03 01
 #8 CA 03 02
 #9 CA 03 03

```

Or

```
 library(splitstackshape)
 cSplit(as.data.frame(id), 'id', sep='_', type.convert=FALSE)

```