Skip to content
Back to formatted view

Raw Message

Message-ID: <OF6B632647.260FE063-ONC12578AB.003EC36A-C12578AB.003EF774@precheza.cz>
Date: 2011-06-10T11:27:10Z
From: PIKAL Petr
Subject: Odp:  How to subset based on column name that is a number ?
In-Reply-To: <935758.86734.qm@web130108.mail.mud.yahoo.com>

Hi
> [R] How to subset based on column name that is a number ?
> 
> Hi,
> 
> I have a data frame with column names "1", "2", "3", ... and I'd like to 
extract 
> a subset based on the values in the first column.  None of the methods I 
tried 
> worked (below).
> 
> 
> x <- subset(dframe, 1 = = "My Text")
> x <- subset(dframe, "1" = = "My Text")
> x <- subset(dframe, names(dframe)[1] = = "My Text")
> Q <- dframe[1 = = "FY11_Q4",]
> Q <- dframe['1'=="FY11_Q4",]
> Q <- dframe[names(dframe)[1]=="FY11_Q4",]
> 

Did you try

dframe[dframe[,"1"]=="My Text",]

Regards
Petr


> 
> Might anyone have a suggestion?
> 
> Many thanks,
> Mauricio
> 
>    [[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.