Re: [R] function help?

2010-09-16 Thread Duke
Hi Duncan, On 9/16/10 3:47 PM, Duncan Murdoch wrote: On 16/09/2010 3:40 PM, Duke wrote: Hi all, I am writing a function (fun.R), but I dont know how to code the function so that the Help Text will be shown up when one types ?fun (of course, after he loads it up). Anyone has any advice

Re: [R] function help?

2010-09-16 Thread Rolf Turner
On 17/09/2010, at 8:51 AM, Duke wrote: Hi Duncan, On 9/16/10 3:47 PM, Duncan Murdoch wrote: On 16/09/2010 3:40 PM, Duke wrote: Hi all, I am writing a function (fun.R), but I dont know how to code the function so that the Help Text will be shown up when one types ?fun (of course,

Re: [R] function help?

2010-09-16 Thread Duncan Murdoch
On 16/09/2010 5:00 PM, Rolf Turner wrote: On 17/09/2010, at 8:51 AM, Duke wrote: Hi Duncan, On 9/16/10 3:47 PM, Duncan Murdoch wrote: On 16/09/2010 3:40 PM, Duke wrote: Hi all, I am writing a function (fun.R), but I dont know how to code the function so that the Help Text will be shown

Re: [R] Function try and Results of a program

2010-09-05 Thread Evgenia
David, your example clarify me the use of sink. I really appreciate your help Evgenia -- View this message in context: http://r.789695.n4.nabble.com/Function-try-and-Results-of-a-program-tp2526621p2527227.html Sent from the R help mailing list archive at Nabble.com.

[R] Function try and Results of a program

2010-09-04 Thread Evgenia
Hello, users. Dear users, ***I have a function f to simulate data from a model (example below used only to show my problems) f-function(n,mean1){ a-matrix(rnorm(n, mean1 , sd = 1),ncol=5) b-matrix(runif(n),ncol=5) data-rbind(a,b) out-data out} *I want to simulate 1000 datasets

Re: [R] Function try and Results of a program

2010-09-04 Thread David Winsemius
On Sep 4, 2010, at 6:10 AM, Evgenia wrote: Hello, users. Dear users, ***I have a function f to simulate data from a model (example below used only to show my problems) f-function(n,mean1){ a-matrix(rnorm(n, mean1 , sd = 1),ncol=5) b-matrix(runif(n),ncol=5) data-rbind(a,b) out-data

Re: [R] Function try and Results of a program

2010-09-04 Thread Evgenia
David, your suggestion about try works perfect for me. I still have a problem with sink. Could you explain me better your suggestion? Thanks alot Evgenia -- View this message in context: http://r.789695.n4.nabble.com/Function-try-and-Results-of-a-program-tp2526621p2526822.html Sent from

Re: [R] Function try and Results of a program

2010-09-04 Thread David Winsemius
On Sep 4, 2010, at 12:41 PM, Evgenia wrote: David, your suggestion about try works perfect for me. I still have a problem with sink. Could you explain me better your suggestion? When you sink to a file, you will continue sending console output to that file until you issue sink(). And

Re: [R] Function Gini or Ineq

2010-09-04 Thread Karen Kotschy
Hi Marcio You might like to look at some equivalents from the field of ecology, for which there are existing functions. Have a look at the function diversity in the package vegan. This provides the Simpson diversity index, which is the complement of the Gini coefficient (Gini = 1 - Simpson).

[R] function to compare numbers

2010-09-03 Thread Hyunchul Kim
Hi, all is there a built-in function to compare two numbers? something like following function cmp - function(x, y){ value - 0 if (x y){ value - 1 }else if (x == y){ value - 0 }else { value - -1 } return(value) } Thanks in advance, Hyunchul

Re: [R] function to compare numbers

2010-09-03 Thread Ivan Calandra
Hi! Maybe something like this: x - 2 y - 3 #since FALSE will be converted to 0 and TRUE to 1 you can do as.numeric(xy) as.numeric(xy) HTH Ivan Le 9/3/2010 15:33, Hyunchul Kim a écrit : Hi, all is there a built-in function to compare two numbers? something like following function cmp-

Re: [R] function to compare numbers

2010-09-03 Thread jim holtman
x - 2 y - 3 ifelse(x y, 1, ifelse(x y, -1, 0)) [1] -1 On Fri, Sep 3, 2010 at 9:33 AM, Hyunchul Kim hyunchul.kim@gmail.com wrote: Hi, all is there a built-in function to compare two numbers? something like following function cmp - function(x, y){    value - 0    if (x y){      

Re: [R] function to compare numbers

2010-09-03 Thread Sarah Goslee
You could potentially use sign() sign(3 - 5) [1] -1 sign(5 - 3) [1] 1 sign(5 - 5) [1] 0 But... this could fail when you think two numbers are equal and the computer doesn't, due to floating point precision. (Your version could fail in exactly the same way.) x - .3 - .2 x [1] 0.1 sign(x -

Re: [R] function to compare numbers

2010-09-03 Thread David Winsemius
On Sep 3, 2010, at 9:33 AM, Hyunchul Kim wrote: Hi, all is there a built-in function to compare two numbers? something like following function cmp - function(x, y){ value - 0 if (x y){ value - 1 }else if (x == y){ value - 0 }else { value - -1 }

[R] Function Gini or Ineq

2010-09-03 Thread Mestat
Hi listers, Does it necessary to install any package in order to use the GINI or INEQ functions. If I use the following command the R tells me that didn't find the GINI function. x-c(541, 1463, 2445, 3438, 4437, 5401, 6392, 8304, 11904, 22261) G-gini(x) Thanks in advance, Marcio -- View this

Re: [R] Function Gini or Ineq

2010-09-03 Thread Dimitris Rizopoulos
for the Gini coefficient you can use this function: gini - function(x, unbiased = TRUE, na.rm = FALSE){ if (!is.numeric(x)) { warning('x' is not numeric; returning NA) return(as.numeric(NA)) } if (any(na.ind - is.na(x))) { if (!na.rm) stop('x'

Re: [R] Function Gini or Ineq

2010-09-03 Thread Mestat
Hi Dimitris, I have already seen your code in another post. But, I would like to weight my data. So, I wish I could use the following command: gini(x, weights=rep(1,length=length(x))) Thanks anyway and I am trying to understand your gini function in order to apply a weigth. Marcio -- View

Re: [R] Function Gini or Ineq

2010-09-03 Thread Peng, C
you need install and load package {reldist} before you call function gini(). HTH. -- View this message in context: http://r.789695.n4.nabble.com/Function-Gini-or-Ineq-tp2525852p2525966.html Sent from the R help mailing list archive at Nabble.com. __

Re: [R] Function Gini or Ineq

2010-09-03 Thread Mestat
Hi Peng, I did that i installed the package RELDIST, but nothing happened. R does not recognize this function. Still looking for the solution. Thanks, Marcio -- View this message in context: http://r.789695.n4.nabble.com/Function-Gini-or-Ineq-tp2525852p2525981.html Sent from the R help mailing

Re: [R] Function Gini or Ineq

2010-09-03 Thread John Kane
) --- On Fri, 9/3/10, Mestat mes...@pop.com.br wrote: From: Mestat mes...@pop.com.br Subject: Re: [R] Function Gini or Ineq To: r-help@r-project.org Received: Friday, September 3, 2010, 1:07 PM Hi Peng, I did that i installed the package RELDIST, but nothing happened. R does

Re: [R] Function to Define a Function

2010-08-10 Thread Derek Ogle
Gabor ... that worked perfectly. Thank you. -Original Message- From: Gabor Grothendieck [mailto:ggrothendi...@gmail.com] Sent: Monday, August 09, 2010 10:20 PM To: Derek Ogle Cc: R (r-help@R-project.org) Subject: Re: [R] Function to Define a Function On Mon, Aug 9, 2010 at 9:31

Re: [R] Function to Define a Function

2010-08-10 Thread Greg Snow
Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Derek Ogle Sent: Monday, August 09, 2010 7:31 PM To: R (r-help@R-project.org) Subject: [R] Function

Re: [R] Function to Define a Function

2010-08-10 Thread Thomas Lumley
On Mon, 9 Aug 2010, Derek Ogle wrote: I am trying to define a general R function that has a function as the output that depends on the user's input arguments (this may make more sense by looking at the toy example below). My real use for this type of code is to allow a user to choose from

Re: [R] Function to Define a Function

2010-08-10 Thread Martin Maechler
Gabor Grothendieck ggrothendi...@gmail.com on Mon, 9 Aug 2010 23:20:18 -0400 writes: On Mon, Aug 9, 2010 at 9:31 PM, Derek Ogle do...@northland.edu wrote: I am trying to define a general R function that has a function as the output that depends on the user's input

Re: [R] Function to Define a Function

2010-08-10 Thread S Ellison
Neat. But why assign the functions to separate variables at all? mdlChooser - function(type=c(one,two)) { type - match.arg(type) m - switch(type, one=function(x,N0,r) N0*exp(x*r) , two=function(x,N0,r,K) (N0*K)/(N0+(K-N0)*exp(-x*r)) ) m } also works without appearing to assign

[R] Function to Define a Function

2010-08-09 Thread Derek Ogle
I am trying to define a general R function that has a function as the output that depends on the user's input arguments (this may make more sense by looking at the toy example below). My real use for this type of code is to allow a user to choose from many parameterizations of the same general

Re: [R] Function to Define a Function

2010-08-09 Thread Gabor Grothendieck
On Mon, Aug 9, 2010 at 9:31 PM, Derek Ogle do...@northland.edu wrote: I am trying to define a general R function that has a function as the output that depends on the user's input arguments (this may make more sense by looking at the toy example below).  My real use for this type of code

Re: [R] Function to return variable name

2010-07-29 Thread Allan Engelhardt
On 29/07/10 04:21, Jeremy Miles wrote: I'd like a function that returns the variable name. As in: MyData$Var1 Would return: Var1 Not quite sure what you mean, but does this get you started? nn - function(x) deparse(substitute(x)) str( z - nn(airquality$Month) ) # chr airquality$Month

[R] Function to return variable name

2010-07-28 Thread Jeremy Miles
I'd like a function that returns the variable name. As in: MyData$Var1 Would return: Var1 There should be a straightforward way to do this, but I can't see it. Thanks, Jeremy -- Jeremy Miles Psychology Research Methods Wiki: www.researchmethodsinpsychology.com

[R] function return

2010-07-22 Thread Daniel Hocking
I am sorry if this question is vague or uninformed. I am just learning R and struggling. I am using the book Hierarchical Modeling and Inference in Ecology and they provide examples of R code. I have the following code from the book but when I run it I don't get any output. I cannot

Re: [R] function return

2010-07-22 Thread David Winsemius
On Jul 22, 2010, at 5:27 PM, Daniel Hocking wrote: I am sorry if this question is vague or uninformed. I am just learning R and struggling. I am using the book Hierarchical Modeling and Inference in Ecology and they provide examples of R code. I have the following code from the book but

Re: [R] function return

2010-07-22 Thread David Winsemius
On Jul 22, 2010, at 5:34 PM, David Winsemius wrote: On Jul 22, 2010, at 5:27 PM, Daniel Hocking wrote: I am sorry if this question is vague or uninformed. I am just learning R and struggling. I am using the book Hierarchical Modeling and Inference in Ecology and they provide examples of R

Re: [R] function return

2010-07-22 Thread Daniel Hocking
Thank you so much! I think I had tried those two pieces separately and obviously had no success. I also typed panel3pt1.fn in the console without the () following it. On Jul 22, 2010, at 5:57 PM, David Winsemius wrote: On Jul 22, 2010, at 5:34 PM, David Winsemius wrote: On Jul 22,

[R] function of an integral

2010-07-20 Thread Nathalie Gimenes
Hi All, I have a problem to create a variable that is a function of an integral of another function. The problem is the following: I have a variable called cip. I have to create another variable called bip that is a function of the former variable cip and also the cumulative distribution

Re: [R] function of an integral

2010-07-20 Thread Wu Gong
Hi, I'm trying to replicate your program. It may be not the same as yours, hope it helps. ## Create a vector of numbers cip - seq(1.0,2.5,by=0.1) ## Create ecdf function Fn - ecdf(cip) ## Create f function f - function(x){(1-Fn(x))^4} ## Create integrate function ## Because the integrate

Re: [R] SAS Proc summary/means as a R function

2010-07-13 Thread Roger Deangelis
( ) -- View this message in context: http://r.789695.n4.nabble.com/SAS-Proc-summary-means-as-a-R-function-tp2286888p2287350.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman

Re: [R] SAS Proc summary/means as a R function

2010-07-13 Thread Duncan Murdoch
On 13/07/2010 8:39 AM, Roger Deangelis wrote: Thanks Richard and Erik, I hate to buy the book and not find the solution to the following: proc.means - function() { deparse(match.call()[-1]) } proc.means(this is a sentence) unexpected symbol in proc means(this is) One possible

Re: [R] SAS Proc summary/means as a R function

2010-07-13 Thread schuster
Hello, are you trying to pase SAS code (or lightly modified SAS code) and run it in R? Then you are right: the hard part is parsing the code. I don't believe that's possible without a custom parser, and even then it's really hard to parse all the SAS sub languages right: data step, macro

Re: [R] SAS Proc summary/means as a R function

2010-07-13 Thread Frank E Harrell Jr
What is the original intent? The bandwidth:productivity ratio is not looking encouraging for this problem. Frank On 07/13/2010 12:38 PM, schuster wrote: Hello, are you trying to pase SAS code (or lightly modified SAS code) and run it in R? Then you are right: the hard part is parsing the

[R] SAS Proc summary/means as a R function

2010-07-12 Thread Roger Deangelis
Hi, I am new to R. I am trying to create an R function to do a SAS proc means/summary proc.means ( data=bsebal; class team year; var ab h; output out=BseBalAvg mean=; run;) I have a solution if I quote

Re: [R] SAS Proc summary/means as a R function

2010-07-12 Thread Erik Iverson
On 07/12/2010 07:16 PM, Roger Deangelis wrote: Hi, I am new to R. I am trying to create an R function to do a SAS proc means/summary proc.means ( data=bsebal; class team year; var ab h; output out=BseBalAvg mean

Re: [R] SAS Proc summary/means as a R function

2010-07-12 Thread RICHARD M. HEIBERGER
Please get a copy of R for SAS and SPSS Users *by* *Muenchen*, Robert A. http://www.springer.com/statistics/computanional+statistics/book/978-0-387-09417-5 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list

Re: [R] Loading .Rdata within an R function

2010-07-09 Thread Giles Crane
environment. However, I would like to load the data into the function environment, so that the data goes away when the function terminates. Cordially, Giles Crane -- View this message in context: http://r.789695.n4.nabble.com/Loading-Rdata-within-an-R-function-tp2282751p2283051.html Sent from the R

Re: [R] Loading .Rdata within an R function

2010-07-09 Thread Duncan Murdoch
Giles Crane wrote: Thank you for your consideration of this question. I have tried both your suggestions. However, the data is not loaded within the function. When I specify load(mydata.Rdata,.globalEnv), the data is loaded into the top level environment, and the function does access the data

[R] Function on columns of a dataframe

2010-07-09 Thread LogLord
Hi, I would like to assign the largest value of a column to a specific category and repeat this for each column (v1 - v4). x=c(1:12) cat=c(cat1,cat5,cat2,cat2,cat1,cat5,cat3,cat4,cat5,cat2,cat3,cat6) v1=rnorm(12,0.5,0.1) v2=rnorm(12,0.3,0.2) v3=rnorm(12,0.4,0.1) v4=rnorm(12,0.6,0.3)

Re: [R] Function on columns of a dataframe

2010-07-09 Thread Eik Vettorazzi
Hi Nils, have a look at ?tapply hth. Am 09.07.2010 15:37, schrieb LogLord: Hi, I would like to assign the largest value of a column to a specific category and repeat this for each column (v1 - v4). x=c(1:12) cat=c(cat1,cat5,cat2,cat2,cat1,cat5,cat3,cat4,cat5,cat2,cat3,cat6)

Re: [R] Function on columns of a dataframe

2010-07-09 Thread David Winsemius
On Jul 9, 2010, at 9:46 AM, Eik Vettorazzi wrote: Hi Nils, have a look at ?tapply hth. Perhaps this will be part way there (I couldn't really figure out the desired structure of the final object): lapply( bla[, -(1:2)], function(x) tapply(x, bla$cat, max) ) $v1 cat1 cat2

Re: [R] Function on columns of a dataframe

2010-07-09 Thread Eik Vettorazzi
you are right. But maybe aggregate is close to the desired result? aggregate(bla, list(bla$cat), max) Am 09.07.2010 16:01, schrieb David Winsemius: On Jul 9, 2010, at 9:46 AM, Eik Vettorazzi wrote: Hi Nils, have a look at ?tapply hth. Perhaps this will be part way there (I couldn't

Re: [R] Function on columns of a dataframe

2010-07-09 Thread David Winsemius
On Jul 9, 2010, at 10:26 AM, Eik Vettorazzi wrote: you are right. But maybe aggregate is close to the desired result? aggregate(bla, list(bla$cat), max) Right. I couldn't get it to work until I removed the first two columns: aggregate(bla[,-(1:2)], list(bla$cat), max) Then I got pretty

Re: [R] Function on columns of a dataframe

2010-07-09 Thread Eik Vettorazzi
just to satisfy my curiousity, aggregate(bla, list(bla$cat), max) works for me and resulted in Group.1 x catv1v2v3v4 1cat1 5 cat1 0.6337076 0.2887081 0.3629962 0.5328683 2cat2 10 cat2 0.5519426 0.6076447 0.4593770 0.9632341 3cat3 11 cat3 0.6094089

[R] Function similar to combine.levels in Hmisc package

2010-07-09 Thread Saeed Abu Nimeh
Is there a function similar to combine.levels ( in the Hmisc package) that combines the levels of factors, but not based on their frequency. Alternatively, I am looking into using the significance of the dummy variables of factors based on their Pr(|t|) value using the linear model, then deleting

Re: [R] Function similar to combine.levels in Hmisc package

2010-07-09 Thread Frank E Harrell Jr
On 07/09/2010 05:33 PM, Saeed Abu Nimeh wrote: Is there a function similar to combine.levels ( in the Hmisc package) that combines the levels of factors, but not based on their frequency. Alternatively, I am looking into using the significance of the dummy variables of factors based on their

Re: [R] Function for gruping similar variables?

2010-07-08 Thread Timo W
Does anyone have an idea on this? On 6 Lip, 11:32, Timo W esuomi...@gmail.com wrote: Hi, I have a matrix of results of multiple 2x2 chi^2 tests, non- significant tests are marked as TRUE. Is there a function for grouping those variables in a similar way LSD.test from agricolae library does?

[R] Loading .Rdata within an R function

2010-07-08 Thread Giles Crane
. } I wish to load mydata.Rdata only within the function f1. Perhaps I have misunderstood the capabilities of load(), or the environment concepts. Thank you for any help you may give. Cordially, Giles Crane -- View this message in context: http://r.789695.n4.nabble.com/Loading-Rdata-within-an-R

Re: [R] Loading .Rdata within an R function

2010-07-08 Thread David Winsemius
On Jul 8, 2010, at 3:21 PM, Giles Crane wrote: Colleagues: I am having trouble loading data from within .Rdata file within the environment of a function. That is, the following always loads to the global environment: f1 - function(){ load(mydata.Rdata) # compute

Re: [R] Loading .Rdata within an R function

2010-07-08 Thread Duncan Murdoch
On 08/07/2010 3:21 PM, Giles Crane wrote: Colleagues: I am having trouble loading data from within .Rdata file within the environment of a function. That is, the following always loads to the global environment: f1 - function(){ load(mydata.Rdata) # compute

Re: [R] Loading .Rdata within an R function

2010-07-08 Thread Duncan Murdoch
On 08/07/2010 6:21 PM, Duncan Murdoch wrote: On 08/07/2010 3:21 PM, Giles Crane wrote: Colleagues: I am having trouble loading data from within .Rdata file within the environment of a function. That is, the following always loads to the global environment: f1 - function(){

Re: [R] Function to compute the multinomial beta function?

2010-07-06 Thread Robin Hankin
, Robert A LaBudde wrote: At 05:10 PM 7/5/2010, Gregory Gentlemen wrote: Dear R-users, Is there an R function to compute the multinomial beta function? That is, the normalizing constant that arises in a Dirichlet distribution. For example, with three parameters the beta function is Beta(n1,n2,n2

[R] Function for gruping similar variables?

2010-07-06 Thread Timo W
Hi, I have a matrix of results of multiple 2x2 chi^2 tests, non- significant tests are marked as TRUE. Is there a function for grouping those variables in a similar way LSD.test from agricolae library does? I reviewed LSD.test's source but it's not helpful for me. This is my matrix: [,1]

[R] Function to compute the multinomial beta function?

2010-07-05 Thread Gregory Gentlemen
Dear R-users, Is there an R function to compute the multinomial beta function? That is, the normalizing constant that arises in a Dirichlet distribution. For example, with three parameters the beta function is Beta(n1,n2,n2) = Gamma(n1)*Gamma(n2)*Gamma(n3)/Gamma(n1+n2+n3) Thanks in advance

Re: [R] Function to compute the multinomial beta function?

2010-07-05 Thread Matt Shotwell
How about this? mbeta - function(...) { exp(sum(lgamma(c(...)))-lgamma(sum(c(... } gamma(5)*gamma(6)*gamma(7)/gamma(18) [1] 5.829838e-09 mbeta(5,6,7) [1] 5.829838e-09 On Mon, 2010-07-05 at 17:10 -0400, Gregory Gentlemen wrote: Dear R-users, Is there an R function to compute

Re: [R] Function to compute the multinomial beta function?

2010-07-05 Thread Robert A LaBudde
At 05:10 PM 7/5/2010, Gregory Gentlemen wrote: Dear R-users, Is there an R function to compute the multinomial beta function? That is, the normalizing constant that arises in a Dirichlet distribution. For example, with three parameters the beta function is Beta(n1,n2,n2) = Gamma(n1)*Gamma(n2

Re: [R] Is there a similar R function like stpower in STATA

2010-06-21 Thread Peter Ehlers
On 2010-06-20 23:33, zhu yao wrote: Dear R users: In stat, there is a stpower function for power analysis and sample-size determination in survival models. Is there a counterpart in R? library(sos) findFn(power) -Peter Ehlers Thanks Yao Zhu Department of Urology Fudan University

[R] Is there a similar R function like stpower in STATA

2010-06-20 Thread zhu yao
Dear R users: In stat, there is a stpower function for power analysis and sample-size determination in survival models. Is there a counterpart in R? Thanks Yao Zhu Department of Urology Fudan University Shanghai Cancer Center Shanghai, China [[alternative HTML version deleted]]

Re: [R] Function argument as string

2010-06-17 Thread Vishwanath Sindagi
Perfect. Thanks Erik. On Thu, Jun 17, 2010 at 1:07 AM, Erik Iverson er...@ccbr.umn.edu wrote: Vishwanath Sindagi wrote: Hi, Suppose a write a function a_fn-function(arg1) {    return(table(arg1)); } I have a column called AGE. Now I call the function c = a_fn(AGE); When a_fn is

[R] Function argument as string

2010-06-16 Thread Vishwanath Sindagi
Hi, Suppose a write a function a_fn-function(arg1) { return(table(arg1)); } I have a column called AGE. Now I call the function c = a_fn(AGE); When a_fn is called, AGE is received in arg1. My question is, how do I access the actual name of the argument arg1? i.e, inside the function, i

Re: [R] Function argument as string

2010-06-16 Thread Erik Iverson
Vishwanath Sindagi wrote: Hi, Suppose a write a function a_fn-function(arg1) { return(table(arg1)); } I have a column called AGE. Now I call the function c = a_fn(AGE); When a_fn is called, AGE is received in arg1. My question is, how do I access the actual name of the argument arg1?

Re: [R] Function argument as string

2010-06-16 Thread Jorge Ivan Velez
Try # data AGE - rpois(25, 30) # option 1 foo - function(string) table(get(deparse(substitute(string foo(AGE)# no quotes # option 2 foo2 - function(string) table(get(string)) foo2('AGE') # note the quotes here HTH, Jorge On Wed, Jun 16, 2010 at 11:30 AM, Vishwanath Sindagi wrote:

[R] function

2010-06-03 Thread n.via...@libero.it
Dear list, I would like to ask you a question. I'm trying to build the time series' production with the Divisia index. The final step would require to do the following calculations: a)PROD(2006)=PROD(2007)/1+[DELTA_PROD(2007)] b)PROD(2005)=PROD(2006)+[1+DELTA_PROD(2006)]

Re: [R] function

2010-06-03 Thread Joris Meys
This is what you asked for. Prod2007 - 1:10 Prod2006 - Prod2007/1+c(0,diff(Prod2007)) Prod2005 - Prod2006+(1+c(0,diff(Prod2006))) Prod2004 - Prod2005+(1+c(0,diff(Prod2005))) Prod2006 [1] 1 3 4 5 6 7 8 9 10 11 Prod2005 [1] 2 6 6 7 8 9 10 11 12 13 Prod2004 [1] 3 11 7

[R] function

2010-06-03 Thread n.via...@libero.it
Dear list, I would like to ask you a question. I'm trying to build the time series' production with the Divisia index. The final step would require to do the following calculations: a)PROD(2006)=PROD(2007)/[1+DELTA_PROD(2007)/100] b)PROD(2005)=PROD(2006)/[1+DELTA_PROD(2006)/100]

Re: [R] function

2010-06-03 Thread Joris Meys
-project.org Ogg: Re: [R] function This is what you asked for. Prod2007 - 1:10 Prod2006 - Prod2007/1+c(0,diff(Prod2007)) Prod2005 - Prod2006+(1+c(0,diff(Prod2006))) Prod2004 - Prod2005+(1+c(0,diff(Prod2005))) Prod2006 [1] 1 3 4 5 6 7 8 9 10 11 Prod2005 [1] 2 6 6 7 8 9 10

[R] Function that is giving me a headache- any help appreciated (automatic read )

2010-05-18 Thread stephen sefick
note: whole function is below- I am sure I am doing something silly. when I use it like USGS(input=precipitation) it is choking on the precip.1 - subset(DF, precipitation!=NA) b - ddply(precip.1$precipitation, .(precip.1$gauge_name), cumsum) DF.precip - precip.1 DF.precip$precipitation -

Re: [R] Function that is giving me a headache- any help appreciated (automatic read )

2010-05-18 Thread John Kane
I don't think you can do this precipitation!=NA) have a look at ?is.na --- On Tue, 5/18/10, stephen sefick ssef...@gmail.com wrote: From: stephen sefick ssef...@gmail.com Subject: [R] Function that is giving me a headache- any help appreciated (automatic read ) To: r-help@r-project.org

Re: [R] Function that is giving me a headache- any help appreciated (automatic read )

2010-05-18 Thread Peter Ehlers
: From: stephen sefickssef...@gmail.com Subject: [R] Function that is giving me a headache- any help appreciated (automatic read ) To: r-help@r-project.org Received: Tuesday, May 18, 2010, 12:38 PM note: whole function is below- I am sure I am doing something silly. when I use it like USGS(input

Re: [R] Function that is giving me a headache- any help appreciated (automatic read )

2010-05-18 Thread Hadley Wickham
precip.1 - subset(DF, precipitation!=NA) b - ddply(precip.1$precipitation, .(precip.1$gauge_name), cumsum) DF.precip - precip.1 DF.precip$precipitation - b$.data I suspect what you want here is ddply(precip.1, gauge_name, transform, precipitation = cumsum(precipitation)) Hadley --

[R] function density (stats): parameter n

2010-05-16 Thread Paulo Barata
Dear R-list members, About the parameter n of the function density() (Kernel Density Estimation, package stats): The R HTML documentation says about the parameter n: the number of equally spaced points at which the density is to be estimated. When n 512, it is rounded up to the next power of

[R] function

2010-05-12 Thread n.via...@libero.it
Dear list, I'm trying to implement the following function, but what I get is an error message and I don't understand where is the error: #outliers'identification: iqr=lapply(bb,function(){ inner_fencesl=quantile(x,0.25)-1.5*IQR(x) inner_fencesh=quantile(x,0.75)+1.5*IQR(x)

Re: [R] function

2010-05-12 Thread Daniel Malter
There is too little information to answer your question definitively. However, an obvious reason is that you want to apply the function over columns of a data.frame, which is done with apply(), but you try to apply the function over elements of a list using lapply(). A list is not a data.frame

Re: [R] function

2010-05-12 Thread Sarah Goslee
I missed the original query, but here am replying to the respondent. On Wed, May 12, 2010 at 1:28 PM, Daniel Malter dan...@umd.edu wrote: There is too little information to answer your question definitively. However, an obvious reason is that you want to apply the function over columns of a

Re: [R] function

2010-05-12 Thread David Winsemius
On May 12, 2010, at 1:28 PM, Daniel Malter wrote: There is too little information to answer your question definitively. However, an obvious reason is that you want to apply the function over columns of a data.frame, which is done with apply(), but you try to apply the function over

Re: [R] function

2010-05-12 Thread William Dunlap
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of David Winsemius Sent: Wednesday, May 12, 2010 10:41 AM To: Daniel Malter Cc: r-help@r-project.org Subject: Re: [R] function On May 12, 2010, at 1:28 PM, Daniel Malter wrote

Re: [R] function

2010-05-12 Thread Daniel Malter
Fair enough, my mistake. However, I am quite fascinated how that focuses everybody else on picking on the intitial answer and diverts everybody away from anwering the actual question. All the more it points to the second paragraph of my reply, namely that all modular components of the function

Re: [R] function

2010-05-12 Thread Henrique Dallazuanna
Try this: lapply(bb, function(x)quantile(x, c(0.25, 0.75)) - matrix(IQR(x) * c(1.5, 3), nrow = 2) %*% c(-1, 1)) On Wed, May 12, 2010 at 1:44 PM, n.via...@libero.it n.via...@libero.itwrote: Dear list, I'm trying to implement the following function, but what I get is an error message and I

Re: [R] function

2010-05-12 Thread David Winsemius
On May 12, 2010, at 2:50 PM, Daniel Malter wrote: Fair enough, my mistake. However, I am quite fascinated how that focuses everybody else on picking on the intitial answer and diverts everybody away from anwering the actual question. All the more it points to the second paragraph of my

[R] R function doing multivariate local linear regression

2010-05-06 Thread Bo Li
Hi, I am looking for a established R function or package which does the multivariate local linear regression. I mean the predictor x is multi-dimensional. locpoly() is the univariate version. I am wondering if there is a multivariate version besides the function loess(). Thank you

Re: [R] R function doing multivariate local linear regression

2010-05-06 Thread David Winsemius
On May 6, 2010, at 11:44 AM, Bo Li wrote: Hi, I am looking for a established R function or package which does the multivariate local linear regression. I mean the predictor x is multi-dimensional. locpoly() is the univariate version. I am wondering if there is a multivariate version

Re: [R] Text dependent on a variable in a R function

2010-05-03 Thread Jim Lemon
On 05/02/2010 10:00 PM, Duncan Murdoch wrote: ... I've seen this description a couple of times lately, and I think it's worth pointing out that it's misleading. The deparse(substitute(x)) trick returns the *expression* that was passed to the argument x. Sometimes that's the name of a variable,

Re: [R] Text dependent on a variable in a R function

2010-05-03 Thread Duncan Murdoch
Jim Lemon wrote: On 05/02/2010 10:00 PM, Duncan Murdoch wrote: ... I've seen this description a couple of times lately, and I think it's worth pointing out that it's misleading. The deparse(substitute(x)) trick returns the *expression* that was passed to the argument x. Sometimes that's the

Re: [R] Text dependent on a variable in a R function

2010-05-02 Thread Jim Lemon
On 05/02/2010 11:56 AM, R K wrote: Hello, I was wondering if someone could tell me how I can make text dependent on a variable in a R function I have created. The function will create plots, thus I would like each plot to have a unique title based on the inputted variable as well

Re: [R] Text dependent on a variable in a R function

2010-05-02 Thread Duncan Murdoch
On 02/05/2010 4:07 AM, Jim Lemon wrote: On 05/02/2010 11:56 AM, R K wrote: Hello, I was wondering if someone could tell me how I can make text dependent on a variable in a R function I have created. The function will create plots, thus I would like each plot to have a unique title based

Re: [R] Text dependent on a variable in a R function

2010-05-02 Thread Nikhil Kaza
say x is the variable. plot(..., title=paste(x, whatever else), ...) should work as well. same should work with file names as well. Nikhil On May 1, 2010, at 9:56 PM, R K wrote: Hello, I was wondering if someone could tell me how I can make text dependent on a variable in a R function

Re: [R] Text dependent on a variable in a R function

2010-05-02 Thread David Winsemius
, 0.5, 0.75, 1) plot(x, main=paste(x, whatever)) -- David Nikhil On May 1, 2010, at 9:56 PM, R K wrote: Hello, I was wondering if someone could tell me how I can make text dependent on a variable in a R function I have created. The function will create plots, thus I would like each

Re: [R] Text dependent on a variable in a R function

2010-05-02 Thread nikhil kaza
Nikhil On May 1, 2010, at 9:56 PM, R K wrote: Hello, I was wondering if someone could tell me how I can make text dependent on a variable in a R function I have created. The function will create plots, thus I would like each plot to have a unique title based on the inputted variable

[R] Text dependent on a variable in a R function

2010-05-01 Thread R K
Hello, I was wondering if someone could tell me how I can make text dependent on a variable in a R function I have created. The function will create plots, thus I would like each plot to have a unique title based on the inputted variable as well as a unique file name when saved using

Re: [R] Text dependent on a variable in a R function

2010-05-01 Thread Charles C. Berry
On Sun, 2 May 2010, R K wrote: Hello, I was wondering if someone could tell me how I can make text dependent on a variable in a R function I have created. example( deparse ) HTH, Chuck The function will create plots, thus I would like each plot to have a unique title based

Re: [R] function which saves an image of a dgtMatrix as png

2010-04-29 Thread Gildas Mazo
Thanks so much Douglas Bates a écrit : image applied to a sparseMatrix object uses lattice functions to create the image. As described in R FAQ 7.22 you must use print(image(x)) or show(image(x)) or even plot(image(x)) when a lattice function is called from within another

[R] function which saves an image of a dgtMatrix as png

2010-04-28 Thread Gildas Mazo
Hi, I'm getting crazy: This does work: library(Matrix) a1-b1-c(1,2) c1-rnorm(2) aDgt-spMatrix(ncol=3,nrow=3,i=a1,j=b1,x=c1) png(myImage.png) image(aDgt) dev.off() But this doesn't !!! f-function(x){ png(myImage.png) image(x) dev.off() } f(aDgt) My image is saved as a text file and contains

Re: [R] function which saves an image of a dgtMatrix as png

2010-04-28 Thread Douglas Bates
image applied to a sparseMatrix object uses lattice functions to create the image. As described in R FAQ 7.22 you must use print(image(x)) or show(image(x)) or even plot(image(x)) when a lattice function is called from within another function. On Wed, Apr 28, 2010 at 1:20 PM, Gildas Mazo

Re: [R] function pointer question

2010-04-26 Thread Jan van der Laan
Giovanni, You can use the '...' for that, as in: loocv - function(data, fnc, ...) { n - length(data.x) score - 0 for (i in 1:n) { x_i - data.x[-i] y_i - data.y[-i] yhat - fnc(x=x_i,y=y_i, ...) score - score + (y_i - yhat)^2 } score - score/n return(score) } scoreks -

<    4   5   6   7   8   9   10   11   12   13   >