Reputation: 205
I have a long string.
gs <- "`집합투자 `지정참가 `신탁업자 `일반사무 `총보수 `기타 `총수비 `동종유형 `거래비용 `0.6400 `0.0200 `0.0200 `0.0200 `0.7000 `9.9999 `0.7000 `1.5000 `9.9999"
and I marked this string using `, to divide the string easily when I convert this to table.
Then I used read.table function
gsdf <- read.table(text = gs, sep="`", stringsAsFactors = TRUE)
But the result is not that good, cuz
as you can see, it has just 0 obs, 19 variables...
What I just want to do is like below picture.
just 9row by 2col.
How can I convert my string like this?
any function like as.data.frame .. else will be welcomed. please leave for me any reply.
Upvotes: 0
Views: 40
Reputation: 169
Use matrix
instead of read.table
.
gs <- strsplit(gs, '`')[[1]]
gs <- gs[which(gs!='')]
gs <- matrix(gs, ncol = 2)
Upvotes: 1