0

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 outcome

as you can see, it has just 0 obs, 19 variables...

What I just want to do is like below picture.

hope

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.

1 Answer 1

1

Use matrix instead of read.table.

gs <- strsplit(gs, '`')[[1]]
gs <- gs[which(gs!='')]
gs <- matrix(gs, ncol = 2)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.