[R] Filtering on a dataframe- newbie question

Rolf Turner r.turner at auckland.ac.nz
Mon Oct 19 05:38:52 CEST 2009


On 19/10/2009, at 4:23 PM, milton ruser wrote:

> Hi there,
>
> Try ?subset

	No. Don't.

	Just do:

	X <- dataframe[dataframe$Name=='T44',]

	Note the comma in the penultimate position.

	Read up on array indexing; see ?"[" and An Introduction to R,
	section 5.2 for starters.

	A data frame is two dimensional; you were basically trying to
	treat it as one dimensional.

	And don't call your data frame ``dataframe''.  Would you
	call your dog ``dog''?  (Pace Barry Rowlingson! :-) )

		cheers,

			Rolf Turner

> ?str may also be useful..

	str is indeed useful --- but not here.

			R. T.
>
> bests
>
> milton
>
> On Sun, Oct 18, 2009 at 11:10 PM, ANJAN PURKAYASTHA <
> anjan.purkayastha at gmail.com> wrote:
>
>> Hi,
>> newbie question. I have a data-frame with 3 named columns: Name,  
>> Obs1,
>> Obs2.
>> The Name column members are made of alphanumeric characters: T1,  
>> T2, T3
>> etc.
>> I would like to acess only that subset of the data-frame with Name  
>> == T44.
>> X <- dataframe[dataframe$Name=='T44'] does not work.
>> Any ideas on how to do this?
>> I'm sure I'm missing a simple concept here.
>>
>> Thanks,
>> Anjan
>>
>>
>> --
>> =============================
>> anjan purkayastha, phd
>> bioinformatics analyst
>> whitehead institute for biomedical research
>> nine cambridge center
>> cambridge, ma 02142
>>
>> purkayas [at] wi [dot] mit [dot] edu
>> 703.740.6939
>>
>>        [[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<http://www.r- 
>> project.org/posting-guide.html>
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> 	[[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.


######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}




More information about the R-help mailing list