[R] truncate/overwrite a data frame

P Ehlers ehlers at math.ucalgary.ca
Thu Dec 8 11:54:17 CET 2005


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! http://www.R-project.org/posting-guide.html




More information about the R-help mailing list