Re: [R] Problem with apply list to function: numerical expression has 4 elements: only the first used

2015-05-24 Thread David Winsemius
> On May 24, 2015, at 6:35 AM, Narua wrote: > > Dear kd, > thanks for your fast reply > hm, I thougth, F is normally the abbrevation, but in R FALSE represents > "false"? > Anyway, your function works and I got the idea to work with "apply" > > I had actually a little more complicate function

Re: [R] Problem with apply list to function: numerical expression has 4 elements: only the first used

2015-05-24 Thread Narua
Dear kd, thanks for your fast reply :-D hm, I thougth, F is normally the abbrevation, but in R FALSE represents "false"? Anyway, your function works. I had actually a little more complicate functions (put I posted in the forum first an easier example): f<-function(a,b)((1/(sum(sqrt(1:a*sqrt(b)

Re: [R] Problem with apply list to function: numerical expression has 4 elements: only the first used

2015-05-24 Thread Narua
Dear kd, thanks for your fast reply hm, I thougth, F is normally the abbrevation, but in R FALSE represents "false"? Anyway, your function works and I got the idea to work with "apply" I had actually a little more complicate functions (put I posted in the forum first an easier example): f<-funct

Re: [R] Problem with apply list to function: numerical expression has 4 elements: only the first used

2015-05-24 Thread Kehl Dániel
i))) x <- 1:4 sapply(x, ff, m=4) sapply(x, FF, m=4) Keep up with using R! :) Best, kd Feladó: R-help [r-help-boun...@r-project.org] ; meghatalmazó: Narua [maria@gmx.de] Küldve: 2015. május 24. 0:21 To: r-help@r-project.org Tárgy: [R] Problem with a

[R] Problem with apply list to function: numerical expression has 4 elements: only the first used

2015-05-23 Thread Narua
Hello , I want to try R for statistics. Therefore, I defined a function f with parameters m and k, which calculates a to sqrt(x) proportional density function: f <- function(m,k)((1/(sum(sqrt(1:m*sqrt(k)) A function F sums the results in order to get a distribution function: F <- function(

Re: [R] problem with "APPLY"

2009-05-20 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Peter Dalgaard > Sent: Wednesday, May 20, 2009 8:16 AM > To: De France Henri > Cc: r-help@r-project.org > Subject: Re: [R] problem with "APPLY&q

Re: [R] problem with "APPLY"

2009-05-20 Thread Peter Dalgaard
De France Henri wrote: Hello, The "apply" function seems to behave oddly with my code below NB : H1 is a data frame. (data in the attached file.) # the first lines are: 1 02/01/2008 0.00 0 0 0.00 0 2 03/01/2008 0.00 0 0 0.00 0 3 04/01/2008 0.00 0 0 0.00 0

[R] problem with "APPLY"

2009-05-20 Thread De France Henri
Hello,   The "apply" function seems to behave oddly with my code below   NB : H1 is a data frame. (data in the attached file.) # the first lines are: 1 02/01/2008 0.00  0  0 0.00   0 2 03/01/2008 0.00  0  0 0.00   0 3 04/01/2008 0.00  0  0 0.00   0 4 07/01/2008 0.00  0 

Re: [R] Problem with "apply"

2009-04-22 Thread Tobias Verbeke
Marc Schwartz wrote: The cut() function will do what you want in a vectorized fashion. See ?cut However, that being said, I would strongly advise that you read Frank's page on the categorizing of continuous variables: http://biostat.mc.vanderbilt.edu/twiki/bin/view/Main/CatContinuous befo

Re: [R] Problem with "apply"

2009-04-22 Thread Marc Schwartz
The cut() function will do what you want in a vectorized fashion. See ? cut However, that being said, I would strongly advise that you read Frank's page on the categorizing of continuous variables: http://biostat.mc.vanderbilt.edu/twiki/bin/view/Main/CatContinuous before you proceed. HTH

Re: [R] Problem with "apply"

2009-04-22 Thread Jorge Ivan Velez
Hi Alan, You can avoid the if() else() you're using in your function by replacing it with the recode() function in the car package. I'm pretty sure it will speed up your function. See ?recode after loading the car package: require(car) ?recode HTH, Jorge On Wed, Apr 22, 2009 at 2:56 PM, Alan

Re: [R] Problem with "apply"

2009-04-22 Thread Erik Iverson
I'm not sure, but I think that using the "cut" function would solve your problem? ?cut On Wed, 22 Apr 2009 14:56:10 -0400, "Alan Cohen" wrote: > Hi R users, > > I am trying to assign ages to age classes for a large data set (123,000 > records), and using a for-loop was too slow, so I wrote a fu

[R] Problem with "apply"

2009-04-22 Thread Alan Cohen
Hi R users, I am trying to assign ages to age classes for a large data set (123,000 records), and using a for-loop was too slow, so I wrote a function and used apply. However, the function does not properly assign the first two classes (the rest are fine). It appears that when age is one digi

Re: [R] problem with apply(m, 1, min, na.rm=T)

2009-01-20 Thread Marc Schwartz
on 01/20/2009 05:26 PM Czerminski, Ryszard wrote: > Passing extra arguments to FUN=mean or median in apply > seems fine, but when FUN=min warnings are generated? > See below. > > Any ideas why? > > Best regards, > Ryszard > > Ryszard Czerminski > AstraZeneca Pharmaceuticals LP > >> m > [,

Re: [R] problem with apply(m, 1, min, na.rm=T)

2009-01-20 Thread Rolf Turner
On 21/01/2009, at 12:26 PM, Czerminski, Ryszard wrote: Passing extra arguments to FUN=mean or median in apply seems fine, but when FUN=min warnings are generated? See below. Any ideas why? Best regards, Ryszard Ryszard Czerminski AstraZeneca Pharmaceuticals LP m [,1] [,2] [1,]1

[R] problem with apply(m, 1, min, na.rm=T)

2009-01-20 Thread Czerminski, Ryszard
Passing extra arguments to FUN=mean or median in apply seems fine, but when FUN=min warnings are generated? See below. Any ideas why? Best regards, Ryszard Ryszard Czerminski AstraZeneca Pharmaceuticals LP > m [,1] [,2] [1,]12 [2,]3 NA [3,] NA NA > apply(m, 1, median, na