0

I have a column vector composed of characters like these : "2L.70660", "2L.80704" and "X.92727". I want to split this single vector at the "." into two new columns "2L", "2L" and "70660", "80704", and "92727". I'm not really sure the best way to do this? Thanks.

bactro
  • 79
  • 6
  • 1
    See [this](https://stackoverflow.com/questions/7069076/split-column-at-delimiter-in-data-frame) or `strsplit` or `tidyr::separate`. – Rui Barradas Jul 20 '19 at 23:25

1 Answers1

1

Using v in the Note at the end use read.table. No packages are used.

read.table(text = v, sep = ".", as.is = TRUE)

giving this data.frame:

  V1    V2
1 2L 70660
2 2L 80704
3  X 92727

Note

The input in reproducible form:

v <- c("2L.70660", "2L.80704", "X.92727")
G. Grothendieck
  • 254,981
  • 17
  • 203
  • 341