Thanks mark for pointing out my mistake and suggestion.I can get desired
output now
-Original Message-
From: Mark Sharp [mailto:msh...@txbiomed.org]
Sent: 20 October 2016 17:21
To: Indhira, Anusha
Cc: r-help@r-project.org
Subject: Re: [R] need help in customising function
Indhira,
You have to assign cnt and new value in the loop if you want it to update in
the loop. However, to count the number of values of x > median(x), there are
multiple options. You are using a loop where none is needed in R, which has
many implicit vector functions that run with relational
Your code,
cnt = 0
for(i in 1:length(x)){
ifelse(x[i] > median(x),cnt+1,cnt)
}
sets cnt to zero and never sets it to anything else. Hence it is zero
at the end of the loop. if you set cnt to the value of your call to ifelse
you should get the desired result
cnt <- ifelse(x[i] >
ent: Thursday, October 20, 2016 3:26 AM
To: r-help@r-project.org
Subject: [R] need help in customising function in stat_summary function ggplot2
Hi,
I would like to print percentage of points in a group which are greater than
median value in boxplot. I have tried below code but it always prints
Hi,
I would like to print percentage of points in a group which are greater than
median value in boxplot. I have tried below code but it always prints zero in
the graph. Can you let me know, how to modify code to get desired result?
perc.greaterthan.median <- function(x){
cnt = 0
for(i in
5 matches
Mail list logo