0
votes

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

This is what my data looks like

When I usedput(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!

1
If you just read it in from a file, then use read.table("thefile.tsv"), and it will be done right the first time.r2evans

1 Answers

2
votes

You forgot to specify the col argument that you need to specify, even if your data frame has only one column:

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