Skip to content

Using while statements to insert rows in a dataframe

3 messages · Eric McKibben, Dieter Menne, Luc Villandre

#
Eric McKibben wrote:
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
#
Eric McKibben wrote:
Hi Eric,

Using a /while/ statement would probably work, but it would imply not 
making use of R's convenient indexing aspect. What I suggest is the 
following (my.data is the data.frame you provided) :
This should do the trick.

Cheers,