Skip to content
Prev 337094 / 398528 Next

Basic question for subset of dataframe

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 identical to leadership[,1:2]
identical(leadership[1:2],leadership[,1:2])
[1] TRUE

If you want all rows where "US" is present in "country", then you did it 
fine using leadership[leadership$country == "US", ]

HTH,
Ivan

--
Ivan Calandra, ATER
Universit? de Franche-Comt?
UFR STGI - UMR 6249 Chrono-Environnement
4 Place Tharradin - BP 71427
25211 Montb?liard Cedex, FRANCE
ivan.calandra at univ-fcomte.fr
http://biogeosciences.u-bourgogne.fr/calandra

Le 27/02/14 16:00, Kapil Shukla a ?crit :