0

This is my data set

Question is how do I calculate the proportion of males over the height of 150 are in the dataset?

Vishesh Shrivastav
  • 2,079
  • 2
  • 16
  • 34
Mighty Joe
  • 75
  • 6
  • 2
    Please post data sets as text instead of screenshots. So others who want to offer an answer do not have to enter the data manually. See https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – U. Windl Feb 24 '19 at 01:31

1 Answers1

0

You can use subset to filter data based on a condition and then compute ratio of lengths of the two dataframes (original and filtered).

weight <- c(76,69,64,62,62,57,55,62,60,55)
height <- c(167,167,168,168,168,168,168,168,149,140)
data.foo <- cbind(weight, height) # Example dataset with only height and weight columns

over.150 <- subset(data.foo, height > 150) # filtered data
proportion <- nrow(over.150)/nrow(data.foo)

proportion

[1] 0.8

Vishesh Shrivastav
  • 2,079
  • 2
  • 16
  • 34