Re: [R] Basic question for subset of dataframe

2014-02-27 Thread David Carlson
--- David L Carlson Department of Anthropology Texas A&M University College Station, TX 77840-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Ivan Calandra Sent: Thursday, February 27, 2014 9:46 AM To: r-help@r-pro

Re: [R] Basic question for subset of dataframe

2014-02-27 Thread MacQueen, Don
Try a simpler example: > ick <- data.frame(x=1:5, a=letters[1:5], c=month.abb[1:5], y=11:15) > ick x a c y 1 1 a Jan 11 2 2 b Feb 12 3 3 c Mar 13 4 4 d Apr 14 5 5 e May 15 > ick[2] a 1 a 2 b 3 c 4 d 5 e > > ick[3] c 1 Jan 2 Feb 3 Mar 4 Apr 5 May If you use [] without a comma, it retur

Re: [R] Basic question for subset of dataframe

2014-02-27 Thread Ivan Calandra
Hi, Thanks for the example! I cannot really tell you why you get what you get when you type leadership[leadership$country == "US"] But what I know (or think I know) is that when you don't write the comma, R will take it as a condition for the columns. It means that leadership[1:2] is identi