Using while statements to insert rows in a dataframe
Eric McKibben wrote:
Within column 6 (Question) the numbers 1:33 repeat down the entire column. Occasionally, however, another value (-32767) appears. I need to locate this value everytime it appears and in its place insert 33 rows that are numbered 1:33 in column Question. Additionally, I need to maintain the integrity of the other columns so that the values at that location in each column are also repeated 33 times. So, in the example below, I currently have 68 rows of data, but I actually need 132 rows (two -32767 values need to be replaced). Year Month Day Time PartID Question Latency Response 2008 2 7 194556 6 1 265 -1 2008 2 7 194556 6 2 466 84 2008 2 7 194556 6 3 199 68 .. 2008 2 8 122203 6 -32767 0 NA
It's always good to boil down you example to the minimal possible, your example is too big. To clarify you point: assuming there are only two questions: You have: Question Latency Response 1 265 -1 2 466 84 -32767 0 NA You need? Question Latency Response 1 265 -1 2 466 84 1 265 -1 2 466 84
View this message in context: http://www.nabble.com/Using-while-statements-to-insert-rows-in-a-dataframe-tp23618849p23619171.html Sent from the R help mailing list archive at Nabble.com.