-2

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.

2 Answers2

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