简体   繁体   中英

How to separate the list of data into two column?

I am trying to separate one list of data into two but I don't know how to correctly do it.

这就是我的数据

When I use dput(a) My data is like

structure(list(V1 = structure(c(1L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 2L, 3L, 4L, 5L, 6L, 7L, 8L), .Label = c("1\\t1200.30 ", "10\\t1305.80 ", "11\\t1263.02 ", "12\\t1312.67 ", "13\\t1229.85 ", "14\\t1247.43 ", "15\\t1288.56 ", "16\\t1287.84 ", "2\\t1247.44 ", "3\\t1234.20 ", "4\\t1279.93 ", "5\\t1249.77 ", "6\\t1285.62 ", "7\\t1204.17 ", "8\\t1249.72 ", "9\\t1245.15 "), class = "factor")), .Names = "V1", class = "data.frame", row.names = c(NA, -16L))

I want to make it as two columns like this:

asd  qut
1   1200.3
2   1305.80
3   1263.02

But I have tried to use separate(a, into =c("asd", "qut"), sep = "\\t") , it returns

Error: var must evaluate to a single number or a column name, not a character vector

Could anyone help me with it? Thank you!

您忘记了需要指定的col参数,即使数据框只有一列也是如此:

tidyr::separate(a, col = V1, into = c("asd", "qut"), sep = "\t")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM