[R] remove columns having a partial match name

Henrique Dallazuanna wwwhsd at gmail.com
Wed Jul 18 13:58:46 CEST 2007


Hi,

 DATA_OK <- DATA[,-match("Start", names(DATA))]

-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O


On 18/07/07, João Fadista <Joao.Fadista at agrsci.dk> wrote:
> Dear all,
>
> I would like to know how can I retrieve a data.frame without the columns that have a partial match name. Let´s say that I have a data.frame with 200 columns and 100 of them have the name "StartX", with X being the unique part for each column name. I want to delete all columns that have the name starting with "Start". I´ve tried to do this but it doesn´t work:
>
> > DATA_OK <- DATA[,-match(("Start*"),names(DATA))]
> > dim(DATA_OK)
> NULL
>
>
> Thanks in advance.
> Best regards
>
> João Fadista
> Ph.d. student
>
>
>
>          UNIVERSITY OF AARHUS
> Faculty of Agricultural Sciences
> Dept. of Genetics and Biotechnology
> Blichers Allé 20, P.O. BOX 50
> DK-8830 Tjele
>
> Phone:   +45 8999 1900
> Direct:  +45 8999 1900
> E-mail:  Joao.Fadista at agrsci.dk <mailto:Joao.Fadista at agrsci.dk>
> Web:     www.agrsci.org <http://www.agrsci.org/>
> ________________________________
>
> News and news media <http://www.agrsci.org/navigation/nyheder_og_presse> .
>
> This email may contain information that is confidential. Any use or publication of this email without written permission from Faculty of Agricultural Sciences is not allowed. If you are not the intended recipient, please notify Faculty of Agricultural Sciences immediately and delete this email.
>
>
>         [[alternative HTML version deleted]]
>
>
> ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.
>
>



More information about the R-help mailing list