whatpercent <- function(x) {
i<-1
for(i in length(x)) {
if(x[i]<= mean(x)+sd(x)) {
vec <- c(vec,x[i])
}
else{
next
}
}
percent <- length(vec)/length(x)
percent <- percent * 100
return(percent)
}
Okay I seem to get the same thing when I use
whatpercent(mydata,1) whatpercent(mydata,2) whatpercent(mydata,3) ...
What could be the problem?