0

I have a csv file file1. I'm reading from it and modifying certain columns in it. If I use write.table(modifieddataframe, file1,..), instead of modifying the existing data, new data is getting added. How do I modify already present data.

Example:

Input

c1   c2   c3 
..   b1   ..
..   b2   ..
..   b3   ..

Output

c1   c2   c3 
..   a1   ..
..   a2   ..
..   a3   ..
Jab
  • 119
  • 1
  • 2
  • 17
  • 3
    By default `write.table` overwrite the file, it doesn't add to it unless you explicitly set the `append=TRUE` parameter. Are you sure that's what is going on? Please try to provide a more [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – MrFlick Jun 19 '17 at 16:56
  • Could you make a clearer example, or better, a reproducible one? In this exact example, you could use a combination of `dplyr::mutate` with `gsub` to change the `b` to `a`, but it isn't clear this is what you want more generally. – RobertMyles Jun 19 '17 at 16:56
  • @MrFlick. That resolved it. I was using with append = TRUe. Thanks! – Jab Jun 19 '17 at 17:08

0 Answers0