[R] lineplot.CI in "sciplot": option "ci.fun" can't be changed?

Tao Shi shitao at hotmail.com
Fri Apr 2 23:21:18 CEST 2010


Thanks, Manuel!

----------------------------------------
> Subject: Re: lineplot.CI in "sciplot": option "ci.fun" can't be changed?
> From: Manuel.A.Morales at williams.edu
> To: shitao at hotmail.com
> CC: r-help at r-project.org; mmorales at williams.edu
> Date: Fri, 2 Apr 2010 14:22:33 -0400
>
> For now, just change fun(x) to median(x) (or whatever) in your ci.fun()
> below.
>
> E.g.
> lineplot.CI(x.factor = dose, response = len, data = ToothGrowth, ci.fun=
> function(x) c(mean(x)-2*se(x), mean(x)+2*se(x)))
>
> Otherwise, maybe the list members could help with a solution. An example
> that illustrates the problem:
>
> ex.fn <- function(x,
> fun = mean,
> fun2 = function(x) fun(x)+sd(x)) {
>
> list(fun=fun(x), fun2=fun2(x))
> }
>
> data <- rnorm(10)
>
> ex.fn(data) #works
> ex.fn(data, fun=median) #works
> ex.fn(data, fun2=function(x) fun(x)+3) #error with fun(x) not found
>
>
> On Fri, 2010-04-02 at 17:36 +0000, Tao Shi wrote:
>> hi List and Manuel,
>>
>> I have encounter the following problem with the function "lineplot.CI". I'm running R 2.10.1, sciplot 1.0-7 on Win XP. It seems like it's a scoping issue, but I couldn't figure it out.
>>
>> Thanks!
>>
>> ...Tao
>>
>>
>>
>>> lineplot.CI(x.factor = dose, response = len, data = ToothGrowth) ## fine
>>> lineplot.CI(x.factor = dose, response = len, data = ToothGrowth, fun=median) ## fine
>>> lineplot.CI(x.factor = dose, response = len, data = ToothGrowth, fun=mean) ## fine
>>> lineplot.CI(x.factor = dose, response = len, data = ToothGrow[[elided Hotmail spam]]
>> Error in FUN(X[[1L]], ...) : could not find function "fun"
>>
>>> debug(lineplot.CI)
>>> lineplot.CI(x.factor = dose, response = len, data = ToothGrowth, ci.fun= function(x) c(fun(x)-2*se(x), fun(x)+2*se(x)))
>> ....
>> ....
>> ....
>> ....
>> Browse[2]>
>> debug: mn.data <- tapply(response, groups, fun)
>> Browse[2]>
>> debug: CI.data <- tapply(response, groups, ci.fun)
>> Browse[2]> fun
>> function (x)
>> mean(x, na.rm = TRUE)
>> 
>> Browse[2]> ci.fun
>> function(x) c(fun(x)-2*se(x), fun(x)+2*se(x))
>> Browse[2]> debug(ci.fun)
>> Browse[2]> fun
>> function (x)
>> mean(x, na.rm = TRUE)
>> 
>> Browse[2]>
>> debugging in: FUN(X[[1L]], ...)
>> debug: c(fun(x) - 2 * se(x), fun(x) + 2 * se(x))
>> Browse[3]>
>> Error in FUN(X[[1L]], ...) : could not find function "fun"
>>> undebug(lineplot.CI)
>>> lineplot.CI(x.factor = dose, response = len, data = ToothGrowth, ci.fun= function(x) c(fun(x)-se(x), fun(x)+se(x)))
>> Error in FUN(X[[1L]], ...) : could not find function "fun"
>>> lineplot.CI(x.factor = dose, response = len, data = ToothGrowth, fun = function(x) mean(x, na.rm=TRUE),ci.fun= function(x) c(fun(x)-se(x), fun(x)+se(x)))
>> Error in FUN(X[[1L]], ...) : could not find function "fun"
>>> lineplot.CI(x.factor = dose, response = len, data = ToothGrowth, fun = function(x) median(x, na.rm=TRUE),ci.fun= function(x) c(fun(x)-se(x), fun(x)+se(x)))
>> Error in FUN(X[[1L]], ...) : could not find function "fun"
>>
>>
>>
>>
>>
>>
>> _________________________________________________________________
>> Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox.
>> http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_1
>
> --
> http://mutualism.williams.edu
>
 		 	   		  
_________________________________________________________________
The New Busy is not the too busy. Combine all your e-mail accounts with Hotmail.

ID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_4


More information about the R-help mailing list