[R] truncate/overwrite a data frame

P Ehlers
Thu, 08 Dec 2005 10:54:17 -0000

Guillaume,

Will functions unique() or duplicated() help you?

(Comment on trailing ";" withheld so as not to revive recent thread.)

Peter Ehlers

herodote at oreka.com wrote:
> hi all,
>
> I've got a data frame, this data frame have 76 columns and 22600 rows.
> The data inside can be redundant because the data can be captured
simultaneously and overlap each other.
>
> My aim is to supress these overlaps
>
> I've test some solutions to do that but they all give a big cpu load
and eat all of the memory then swap a lot, then killall R because it don't
end.
>
> actually i've tested this (it don't works but seems to be correct
for me...):
>
> My first try (i was trying to overwrite the table on the overlap):
>
>
tab[(no[off_set[i-1]+1]+(no[off_set[i]+1]-no[off_set[i-1]+1])):length(TotalFillTimeHours),1:length(tab)]<-tab[(no[off_set[i-1]+1]+(no[off_set[i]+1]-no[off_set[i-1]+1])):length(TotalFillTimeHours),1:length(tab)];
>
> My second idea was to make 2 tab without the overlap, then put them
together:
>
tab_tmp<-tab[1:(no[off_set[i-1]+1]+(no[off_set[i]+1]-no[off_set[i-1]+1])),1:length(tab)];
>
tab_tmp1<-tab[(no[off_set[i-1]+1]+(no[off_set[i]+1]-no[off_set[i-1]+1])):length(TotalFillTimeHours),1:length(tab)];
> tab<-as.data.frame(c(tab_tmp, tab_tmp1));
> attach(tab);
>
> In these 2 case it didn't succeed, by the lack of comprehension that i
have in R programming ...(it isn't R fault :).
>
> thks all
> guillaume.
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!