0

I'm using R. I have an excel file which each rows of it consists of two or three lines description. I wish to write each rows in a separate text file. So, suppose I have a excel file with 100 rows, I will need 100 separate text files.

Is there any idea on how to do it in an efficient way?

HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47
Goli
  • 1
  • 3
  • 3
    Hi, welcome to SO. This is not a code-writing service. Please provide a reproducible example, including (a part of) your data, your expected output and what you've already tried. If you're unsure how to do that, here's [how](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – Heroka Sep 08 '15 at 16:09

1 Answers1

0

Save the file/ sheet as a csv and use read.csv to read in the csv as an R data frame.

You can then use mapply with the data frame variable (say it's called x, with a column $desc for the description). Make a character vector with one entry for each row of your data frame called fnms. Use `fnms <- paste0("text", 1:nrow(x), ".txt") or similar.

Put:

mapply(write, x$desc, fnms)
CJB
  • 1,759
  • 17
  • 26