input <- read.table(header=F, text=\"abc 2 def 3 pq 2\") colnames(input) <- c(\"text\",\"count\")
I have input
Or
as.data.frame(lapply(input, function(x) rep(x, input$count))) # text count # 1 abc 2 # 2 abc 2 # 3 def 3 # 4 def 3 # 5 def 3 # 6 pq 2 # 7 pq 2