Q:

Separate column into two columns r

To be straightforward, I need to split one column into two splitting along rows. 
Here is some dummy data:
structure(list(id = structure(1:8, .Label = c("A1", "A2", "A3", 
"A4", "B1", "B2", "B3", "B4"), class = "factor"), value = c(0.360828393837437, 
0.671899559209123, 0.905935228336602, 0.934275768464431, 0.450348142534494, 
0.99131133640185, 0.696797786746174, 0.104902224382386)), class = "data.frame", row.names = c(NA, 
-8L))

dummy_data
  id     value
1 A1 0.3608284
2 A2 0.6718996
3 A3 0.9059352
4 A4 0.9342758
5 B1 0.4503481
6 B2 0.9913113
7 B3 0.6967978
8 B4 0.1049022

Now what I need to do is split from B1 to B4. I could do this using slice() and recombine them later but I'm looking to learn possibly how to do this in a one-liner.
 Thanks in advance and apologies if such a question already exists, couldn't find it. 

A:

In base R you can use split and Reduce
out <- Reduce(cbind, split(dummy_data, substr(dummy_data$id, 1, 1)))
names(out) <- make.names(names(out), unique = TRUE)
out
#  id     value id.1   value.1
#1 A1 0.3608284   B1 0.4503481
#2 A2 0.6718996   B2 0.9913113
#3 A3 0.9059352   B3 0.6967978
#4 A4 0.9342758   B4 0.1049022

The idea is to split the data by the first letter of column id, this returns a list. We then combine the list back to a data frame using cbind.

Though a better option might be do.call instead of Reduce because this gives unique names and makes the call to makes.names obsolet.
do.call(cbind, split(dummy_data, substr(dummy_data$id, 1, 1)))
#  A.id   A.value B.id   B.value
#1   A1 0.3608284   B1 0.4503481
#2   A2 0.6718996   B2 0.9913113
#3   A3 0.9059352   B3 0.6967978
#4   A4 0.9342758   B4 0.1049022

