Reputation: 73
I have data frame like this
vf<-data.frame(A=c("v1v2"),B=c("v2v3"))
is it possible to split the content as v1 and v2 ..etc ..into two columns.
I used
ddply
,but how different number separated?
expected out put
Also I stored my row name as variable
na<-rownames(vf)
It stored as "1", so I can't use it as vf[na]..
How can I store my row name in a variable and use it in function rownames()
?
Upvotes: 1
Views: 66
Reputation: 15441
vf$A.1 <- substr(vf[,1], 1,2)
vf$A.2 <- substr(vf[,1], 3,4)
#> vf
# A B A.1 A.2
#1 v1v2 v2v3 v1 v2
Upvotes: 1