Importing one long line of data into R

前端 未结 6 1617
醉酒成梦
醉酒成梦 2021-02-05 18:58

I have a large data file consisting of a single line of text. The format resembles

Cat    14  Dog    15  Horse  16

I\'d eventually like to get

6条回答
  •  野的像风
    2021-02-05 19:48

    Here is another approach

    string <- readLines(textConnection(x))
    string <- gsub("(\\d+)", "\\1\n", string, perl = TRUE)
    dat    <- read.table(text = string, sep = "")
    

提交回复
热议问题