In R, I want to subset from a column all the ones that have Brazil, Country is the variable, and all the rows associated with Brazil. I want more than just the column of Brazil, but I want Brazil to be what draws out what will be in my subset.
            Asked
            
        
        
            Active
            
        
            Viewed 117 times
        
    -2
            
            
        - 
                    1Please read about [how to make a great R reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – Rich Scriven Aug 05 '15 at 23:34
- 
                    1Please show what you have tried – adao7000 Aug 05 '15 at 23:36
- 
                    Or with `dplyr`: `df %>% filter(Cuntry == "Brazil")` – SabDeM Aug 06 '15 at 01:19
2 Answers
0
            
            
        Assuming that Country is a column in your dataframe and some_df is your dataframe
some_df[some_df$Country == 'Brazil,]
 
    
    
        Michal
        
- 1,863
- 7
- 30
- 50
0
            
            
        Assuming your data is in a R dataframe called DF.
subset(DF, Country == "Brazil")
does the trick. For future questions, read the guidelines how to write a question, you will get much more answers that way.
If you want to subset by more than one value for Country, use:
subset(DF, Country %in% c("Brazil", "Sweden", "Swaziland"))
type of construct.
 
    
    
        user3274289
        
- 2,426
- 3
- 16
- 14
