[R] Data Gaps

dpender d.pender at civil.gla.ac.uk
Wed Oct 13 14:31:50 CEST 2010


Dennis,

Thanks for that.  The problem now is that I am trying to use it in a for
loop.  Based on the example before, 2 entries are required after H[3] as
specified by O.  The problem is that when inserting values the length of the
array changes so I don't know how to tell the loop that.  This is what I
have:

for (i in 1:length(H)) 	{
	if (o[i]>0) {append(H, -1, after = i-1)}
				}

Any ideas how to create a loop that allows the inclusion of more than 1
value?

Cheers,

Doug


djmuseR wrote:
> 
> Hi:
> 
> Perhaps
> 
> ?append
> 
> for simple insertions...
> 
> HTH,
> Dennis
> 
> On Wed, Oct 13, 2010 at 1:24 AM, dpender <d.pender at civil.gla.ac.uk> wrote:
> 
>>
>> R community,
>>
>> I am trying to write a code that fills in data gaps in a time series.  I
>> have no R or statistics background at all but the use of R is proving to
>> be
>> a large portion of my PhD research.
>>
>> So far my code identifies where and the number of new entries required
>> but
>> I
>> do not know how to add additional rows or columns into an array.  Any
>> advice
>> on how this can be done?
>>
>> Here is an example:
>>
>> H [0.88 0.72 0.89 0.93 1.23 0.86]
>> T [7.14 7.14 7.49 8.14 7.14 7.32]
>> O [0 0 0 2 0 0]
>>
>> This says that in order to complete the data set 2 entries are required
>> prior to H[4] and T[4] i.e. where O = 2.
>>
>> Thanks,
>>
>> Doug
>> --
>> View this message in context:
>> http://r.789695.n4.nabble.com/Data-Gaps-tp2993317p2993317.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: http://r.789695.n4.nabble.com/Data-Gaps-tp2993317p2993582.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list