[R] (no subject)

Uwe Ligges ligges at statistik.uni-dortmund.de
Wed Aug 6 13:07:41 CEST 2003


Nolwenn Le Meur wrote:

> Hi everybody,
> 
> Hope your are not all on holyday because I've got a problem that is going to
> drive me crazy...

No comment on that sentence, but please use the subject line ....

> I would like to remove some rows from a dataframe. The rows correspond to
> some
> specific indexes which I can get by looking at the name in the first column
> of my dataset. But I manage to get only the opposite of what I really want
> (function #1)
> 
> #Function#1:
> remove.func<-function(data){
> Name<-as.character(data[,1])
> indexZZ<-grep("ZZ",Name,value=FALSE)
> data<-data[indexZZ,] # give me what I don't want
> print(slide)
> }
> 
> #Function#2:
> remove.func<-function(data,Name){
> Name<-as.character(data[,1])
> indexZZ<-grep("ZZ",Name,value=FALSE)
> data<-data[!indexZZ,] #doesn't work, give an empty dataframe

Please read the manuals and learn how to index:

  data <- data[-indexZZ,]

Uwe Ligges


> print(slide)
> }
> 
> Thanks :|
> 
> Nolwenn Le Meur
> 
> ********************************************
> Nolwenn Le Meur
> INSERM U533
> Faculté de médecine
> 1, rue Gaston Veil
> 44035 Nantes Cedex 1
> France
> 
> Tel: (+33)-2-40-41-29-86 (office)
>      (+33)-2-40-41-28-44 (secretary)
> Fax: (+33)-2-40-41-29-50
> mail: nolwenn.lemeur at nantes.inserm.fr
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help




More information about the R-help mailing list