Here is some sample data:
df = data.frame("names" = c("A", "B", "B"),
"area1" = c(2, 3, 8),
"area2" = c(2, 4, 7),
"area3" = c(5, 7, 1))
How can I extract certain rows of data from the data frame into a new column of data so that the result would look like:
result = data.frame("B" = c(3,8))
In other words, how do I extract the values in “area1” based on the “B” value in the “names” column?
When you compare Arun’s and my answers you will see that your question was ambiguous. Your verbal description fits with Arun’s and your code description fits with mine. His is an atomic vector; mine is a dataframe.