Reputation: 215
I have been stumbled in a part of a question.
id <-1:6
age <- c(18,20,19,23,26,24)
gender <- c("M","M","F","F","M","F")
gpa <- c(3.2,2.5,2.7,3.7,4.1,3.6)
score <- c(570,530,550,650,690,640)
data <- data.frame(id=id,gender=gender,gpa=gpa,ceescore=score)
data$class <- with(data,ifelse(gpa>3.5,"First Class",
ifelse(gpa>=2.5 & gpa<=3.5,"Second class",
ifelse(gpa<2.5,"Third class",NA))))
data$final_score <- with(data,ifelse(gpa>3,ceescore*gpa,ceescore*gpa*0.8))
data$success <- with(data,ifelse(final_score>2000,1,0))
Now i have to count the number of female(in gender F for female) who are successful(success==1)
I couldn't able to manage it.
Thank's in advance.
Upvotes: 0
Views: 171
Reputation: 81693
with(data, sum(gender == "F" & success))
will do the trick.
Upvotes: 1