Re: [R] Replacing text with a carriage return

2012-06-25 Thread Rui Barradas
Hello, Instead of replacing "record_start" with newlines, you can split the string by it. And use 'gsub' to make it prettier. x <- readLines("test.txt") x y <- gsub("\"", "", x) # remove the double quotes y <- unlist(strsplit(y, "record_start,")) # do the split, with comma # remove leading

[R] Replacing text with a carriage return

2012-06-25 Thread Thomas
I have a comma separated data file with no carriage returns and what I'd like to do is 1. read the data as a block text 2. search for the string that starts each record "record_start", and replace this with a carriage return. Replace will do, or just add a carriage return before it. The str