0

I have a data frame with 'Age' column and its values are as below:

Age 12 15 16 20 23 24 20 15 16 20 26 20

I want to create a variable and store in it the count of 20 i.e number of people with age as 20.

Can someone please tell me how to do this in R?

1
  • 1
    See table(myDatat$Age) function Commented Sep 26, 2015 at 18:13

1 Answer 1

2

If you have a data frame called data with a column age, you can do this:

count <- sum(data$age == 20)
Sign up to request clarification or add additional context in comments.

1 Comment

zx8754's answer table(myDatat$Age) is probably better as it gives you data about all ages, but this is better if you want to return a number rather than a table.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.