Re: [R] need help in customising function in stat_summary function ggplot2

2016-10-21 Thread Indhira, Anusha
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

Re: [R] need help in customising function in stat_summary function ggplot2

2016-10-20 Thread Mark Sharp
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

Re: [R] need help in customising function in stat_summary function ggplot2

2016-10-20 Thread William Dunlap via R-help
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] >

Re: [R] need help in customising function in stat_summary function ggplot2

2016-10-20 Thread David L Carlson
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

[R] need help in customising function in stat_summary function ggplot2

2016-10-20 Thread Indhira, Anusha
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