Re: [R] A function which is a sum of other functions...

2013-12-20 Thread Onur Uncu
Makes sense. Simple and works. Thank you Greg. Sent from my iPhone > On 20 Dec 2013, at 16:15, Greg Snow <538...@gmail.com> wrote: > > My first thought was to use Reduce, but I think for this case that is > a bit of overkill. You can have a vector or list of functions and > just use sapply/lapp

Re: [R] A function which is a sum of other functions...

2013-12-20 Thread Greg Snow
My first thought was to use Reduce, but I think for this case that is a bit of overkill. You can have a vector or list of functions and just use sapply/lapply on the list of functions then sum the result. A quick example: > funs <- c(sin,cos,tan) > sapply( funs, function(f) f(pi/6) ) [1] 0.50

Re: [R] A function which is a sum of other functions...

2013-12-19 Thread William Dunlap
Onur Uncu [mailto:onuru...@gmail.com] > Sent: Thursday, December 19, 2013 11:43 AM > To: William Dunlap > Subject: Re: [R] A function which is a sum of other functions... > > Thanks William. May I please ask why we needed to use lapply inside Reduce? > It sounds > like we took a

Re: [R] A function which is a sum of other functions...

2013-12-19 Thread William Dunlap
ct.org [mailto:r-help-boun...@r-project.org] On > Behalf > Of Onur Uncu > Sent: Thursday, December 19, 2013 11:05 AM > To: r-help@r-project.org > Subject: [R] A function which is a sum of other functions... > > > Dear R Users > > I have a list of functions. Each funct

Re: [R] A function which is a sum of other functions...

2013-12-19 Thread David Winsemius
On Dec 19, 2013, at 11:05 AM, Onur Uncu wrote: > > Dear R Users > > I have a list of functions. Each function in the list is a function of single > variable. I would like to create a function (of one variable) which > represents the sum of all the functions in the list. So, if the functions i

[R] A function which is a sum of other functions...

2013-12-19 Thread Onur Uncu
Dear R Users I have a list of functions. Each function in the list is a function of single variable. I would like to create a function (of one variable) which represents the sum of all the functions in the list. So, if the functions in my list are f1(x),..,f5(x) then I would like a new functio

Re: [R] A function taken out of its original environment performs more slowly.

2013-08-19 Thread Duncan Murdoch
On 13-08-17 7:05 PM, Xiao He wrote: Hi dear R-users, I encountered an interesting pattern. Take for example the function combn(), I copied and pasted the function definition and saved it as a new function named combn2() (see the end of this email). As it turned out, combn2() seems to be substant

Re: [R] A function taken out of its original environment performs more slowly.

2013-08-17 Thread Uwe Ligges
On 18.08.2013 01:05, Xiao He wrote: Hi dear R-users, I encountered an interesting pattern. Take for example the function combn(), I copied and pasted the function definition and saved it as a new function named combn2() (see the end of this email). As it turned out, combn2() seems to be substa

[R] A function taken out of its original environment performs more slowly.

2013-08-17 Thread Xiao He
Hi dear R-users, I encountered an interesting pattern. Take for example the function combn(), I copied and pasted the function definition and saved it as a new function named combn2() (see the end of this email). As it turned out, combn2() seems to be substantially slower than the original functio

Re: [R] A function that can modify an object? Or at least shows principles how to modify an object?

2013-05-17 Thread Adams, Jean
To make it easier for R-help readers to help you, please you provide the before UUU[2] data using the dput() function. dput(UUU[2]) Jean On Thu, May 16, 2013 at 11:12 AM, Aldi wrote: > Hi, If I have an R object UUU, where the second element is U2, based on > "g" column of my.table > > my.tab

[R] A function that can modify an object? Or at least shows principles how to modify an object?

2013-05-16 Thread Aldi
Hi, If I have an R object UUU, where the second element is U2, based on "g" column of my.table my.table of UUU is: mmm ggg gindex map Info aaa123 U1 1 1 1 aaa124 U1 1 2 1 bbb1378 U2 2 1

Re: [R] A function that can modify an object? Or at least shows principles how to modify an object?

2013-05-16 Thread Rui Barradas
Hello, Sorry, there's an error in fun2. Corrected: fun2 <- function(x, what, map, value){ y <- x[[what]] i1 <- seq_len(map - 1) i2 <- seq_len(nrow(y))[-i1] x[[what]] <- rbind(y[i1, ], value, y[i2, ]) x } Rui Barradas Em 16-05-2013 17:54, Rui Barradas esc

Re: [R] A function that can modify an object? Or at least shows principles how to modify an object?

2013-05-16 Thread Rui Barradas
Hello, If I understood it correctly, the following should do it. fun1 <- function(x, what, map, value){ y <- x[[what]] i1 <- seq_len(map - 1) i2 <- seq_along(y)[-i1] x[[what]] <- c(y[i1], value, y[i2]) x } fun2 <- function(x, what, map, value){ y

[R] A function that can modify an object? Or at least shows principles how to modify an object?

2013-05-16 Thread Aldi
Hi, If I have an R object UUU, where the second element is U2, based on "g" column of my.table my.table of UUU is: mmm ggg gindex map Info aaa123 U1 1 1 1 aaa124 U1 1 2 1 bbb1378U2 2 1

Re: [R] a function more appropriate than 'sapply'?

2013-01-26 Thread arun
emorway Cc: r-help@r-project.org Sent: Saturday, January 26, 2013 2:46 PM Subject: Re: [R] a function more appropriate than 'sapply'? On 26-01-2013, at 19:43, emorway wrote: > I'm wondering if I need to use a function other than sapply as the following > line of code runs

Re: [R] a function more appropriate than 'sapply'?

2013-01-26 Thread arun
ssage - From: emorway To: r-help@r-project.org Cc: Sent: Saturday, January 26, 2013 1:43 PM Subject: [R] a function more appropriate than 'sapply'? I'm wondering if I need to use a function other than sapply as the following line of code runs indefinitely (or > 30 min so f

Re: [R] a function more appropriate than 'sapply'?

2013-01-26 Thread Uwe Ligges
On 26.01.2013 21:23, Berend Hasselman wrote: On 26-01-2013, at 21:09, Uwe Ligges wrote: On 26.01.2013 20:46, Berend Hasselman wrote: On 26-01-2013, at 19:43, emorway wrote: I'm wondering if I need to use a function other than sapply as the following line of code runs indefinitely (or

Re: [R] a function more appropriate than 'sapply'?

2013-01-26 Thread Berend Hasselman
On 26-01-2013, at 21:09, Uwe Ligges wrote: > > > On 26.01.2013 20:46, Berend Hasselman wrote: >> >> On 26-01-2013, at 19:43, emorway wrote: >> >>> I'm wondering if I need to use a function other than sapply as the following >>> line of code runs indefinitely (or > 30 min so far) and uses up

Re: [R] a function more appropriate than 'sapply'?

2013-01-26 Thread Uwe Ligges
On 26.01.2013 20:46, Berend Hasselman wrote: On 26-01-2013, at 19:43, emorway wrote: I'm wondering if I need to use a function other than sapply as the following line of code runs indefinitely (or > 30 min so far) and uses up all 16Gb of memory on my machine for what seems like a very small

Re: [R] a function more appropriate than 'sapply'?

2013-01-26 Thread Berend Hasselman
On 26-01-2013, at 19:43, emorway wrote: > I'm wondering if I need to use a function other than sapply as the following > line of code runs indefinitely (or > 30 min so far) and uses up all 16Gb of > memory on my machine for what seems like a very small dataset (data attached > in a txt file wel

[R] a function more appropriate than 'sapply'?

2013-01-26 Thread emorway
I'm wondering if I need to use a function other than sapply as the following line of code runs indefinitely (or > 30 min so far) and uses up all 16Gb of memory on my machine for what seems like a very small dataset (data attached in a txt file wells.txt

Re: [R] A function like sum but with functions other than '+'

2012-04-02 Thread Julio Sergio
Michael Sumner gmail.com> writes: > > Try ?Reduce > Thanks Michael! --Sergio. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide

Re: [R] A function like sum but with functions other than '+'

2012-04-01 Thread Joshua Wiley
Hi Sergio, Look at ?Reduce Cheers, Josh On Sun, Apr 1, 2012 at 3:25 PM, Julio Sergio wrote: > Because I didn't find in R any functions similar to the function 'reduce' from > Python, I'm writing a function "freduce" as follows: > > freduce <- function(f, vec, ValIni=NULL, StopIn=NULL) { >  # f

Re: [R] A function like sum but with functions other than '+'

2012-04-01 Thread Michael Sumner
Try ?Reduce On Monday, April 2, 2012, Julio Sergio wrote: > Because I didn't find in R any functions similar to the function 'reduce' > from > Python, I'm writing a function "freduce" as follows: > > freduce <- function(f, vec, ValIni=NULL, StopIn=NULL) { > # f: is any function that takes two ar

[R] A function like sum but with functions other than '+'

2012-04-01 Thread Julio Sergio
Because I didn't find in R any functions similar to the function 'reduce' from Python, I'm writing a function "freduce" as follows: freduce <- function(f, vec, ValIni=NULL, StopIn=NULL) { # f: is any function that takes two arguments of the same type # vec: is a vector of n values accepted by

Re: [R] a function

2010-02-05 Thread David Winsemius
On Feb 5, 2010, at 3:33 PM, li li wrote: Dear all, I need to write the following function in R. Can anyone give me some hint? Thank you! Please see the attachment for the function. Hannah __ A three argument function with two instances of sap

[R] a function

2010-02-05 Thread li li
Dear all, I need to write the following function in R. Can anyone give me some hint? Thank you! Please see the attachment for the function. Hannah question to R-heip.pdf Description: Adobe PDF document __ R-help@r-project.org mailing list https

Re: [R] A function for plotting a boxplot with added dot and bars (formean and SE) - please help improve my code

2009-08-12 Thread ONKELINX, Thierry
not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey Van: Tal Galili [mailto:tal.gal...@gmail.com] Verzonden: woensdag 12 augustus 2009 12:48 Aan: ONKELINX, Thierry CC: r-help@r-project.org Onderwerp: Re: [R] A fun

Re: [R] A function for plotting a boxplot with added dot and bars (formean and SE) - please help improve my code

2009-08-12 Thread Tal Galili
given body of > data. > ~ John Tukey > > -Oorspronkelijk bericht- > Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > Namens Tal Galili > Verzonden: woensdag 12 augustus 2009 11:48 > Aan: r-help@r-project.org > Onderwerp: [R] A function for plotting

Re: [R] A function for plotting a boxplot with added dot and bars (formean and SE) - please help improve my code

2009-08-12 Thread ONKELINX, Thierry
g] Namens Tal Galili Verzonden: woensdag 12 augustus 2009 11:48 Aan: r-help@r-project.org Onderwerp: [R] A function for plotting a boxplot with added dot and bars (formean and SE) - please help improve my code Hello people, A while back I wanted to plot boxplots with interactions that will have a

[R] A function for plotting a boxplot with added dot and bars (for mean and SE) - please help improve my code

2009-08-12 Thread Tal Galili
Hello people, A while back I wanted to plot boxplots with interactions that will have a dot for the mean of the sample + bars for the SE. After searching for some code, I found something that did it for one level, but couldn't find something that will allow for interactions the way the original bo

Re: [R] Is there in R a function equivalent to the mround, as found in most spreadsheets?

2008-05-11 Thread Alberto Santini
andard. The test cases are: mround(10, 3) # 9 mround(-10, -3) # -9 mround(1.3, 0.2) # 1.4 mround(5, -2) # error mround(1.7, 0.2) # 1.8 mround(321.123, 0.12) # 321.12 mround(1803.02, 50) # 1800 mround(193.51, 5) # 195 mround(3.47, 1) # 3 Regards, Alberto -- View this message in context: http

Re: [R] Is there in R a function equivalent to the mround, as found in most spreadsheets?

2008-05-09 Thread Ottorino-Luca Pantani
Charilaos Skiadas ha scritto: On May 9, 2008, at 5:39 AM, Dieter Menne wrote: If I understand the OP's question properly, the first value is to be a multiple of 50, the second a multiple of 5, and the third a multiple of 1. This can be done with this slight variation on the above theme: a <-

Re: [R] Is there in R a function equivalent to the mround, as found in most spreadsheets?

2008-05-09 Thread Charilaos Skiadas
On May 9, 2008, at 5:39 AM, Dieter Menne wrote: Dr. Ottorino-Luca Pantani unifi.it> writes: Imagine that for a particular cuvette (I have 112 different cuvettes !!) you have to mix the following volumes of solution A, B, and C respectively. c(1803.02, 193.51, 3.47) Each solution is to

Re: [R] Is there in R a function equivalent to the mround, as found in most spreadsheets?

2008-05-09 Thread Dieter Menne
Dr. Ottorino-Luca Pantani unifi.it> writes: > > In a lab experiment I have to mix three solutions to get different > concentrations of various molecules in a cuvette > > I've used R to calculate the necessary µliters for each of the level of > the experiment and I must confess that it is more

[R] Is there in R a function equivalent to the mround, as found in most spreadsheets?

2008-05-09 Thread Dr. Ottorino-Luca Pantani
Dear R-users, I have the following problem In a lab experiment I have to mix three solutions to get different concentrations of various molecules in a cuvette I've used R to calculate the necessary µliters for each of the level of the experiment and I must confess that it is more useful and

Re: [R] Is there in R a function equivalent to the mround, as found in most spreadsheets?

2008-05-06 Thread hadley wickham
> > I believe this function matches the description in OOO: > > mround <- function(number, multiple) multiple * round(number/multiple) I've implemented a slightly more general form in the reshape package: round_any <- function (x, accuracy, f = round) { f(x/accuracy) * accuracy } Hadley -

Re: [R] Is there in R a function equivalent to the mround, as found in most spreadsheets?

2008-05-06 Thread Yasir Kaheil
ng-guide.html > and provide commented, minimal, self-contained, reproducible code. > > - Yasir H. Kaheil, Ph.D. Catchment Research Facility The University of Western Ontario -- View this message in context: http://www.nabble.com/Is-there-in-R-a-function-equivalent-to-the-mround%2C-as

Re: [R] Is there in R a function equivalent to the mround, as found in most spreadsheets?

2008-05-06 Thread Duncan Murdoch
On 5/6/2008 12:07 PM, Dr. Ottorino-Luca Pantani wrote: Dear R-users, I have the following problem In a lab experiment I have to mix three solutions to get different concentrations of various molecules in a cuvette I've used R to calculate the necessary µliters for each of the level of the ex

[R] Is there in R a function equivalent to the mround, as found in most spreadsheets?

2008-05-06 Thread Dr. Ottorino-Luca Pantani
Dear R-users, I have the following problem In a lab experiment I have to mix three solutions to get different concentrations of various molecules in a cuvette I've used R to calculate the necessary µliters for each of the level of the experiment and I must confess that it is more useful and e

Re: [R] A function for random test based on longest run (UNCLASSIFIED)

2007-12-31 Thread Dirk Eddelbuettel
Brian, On 29 December 2007 at 17:03, Prof Brian Ripley wrote: | On Thu, 27 Dec 2007, Dirk Eddelbuettel wrote: | | > | > On 27 December 2007 at 12:08, bogdan romocea wrote: | > | > require(tseries) | > | > ?runs.test | > | Also, take a look at dieharder, it implements a large number of | >

Re: [R] A function for random test based on longest run (UNCLASSIFIED)

2007-12-29 Thread Prof Brian Ripley
On Thu, 27 Dec 2007, Dirk Eddelbuettel wrote: > > On 27 December 2007 at 12:08, bogdan romocea wrote: > | > require(tseries) > | > ?runs.test > | Also, take a look at dieharder, it implements a large number of > | randomness tests: > | http://www.phy.duke.edu/~rgb/General/dieharder.php > > Als

Re: [R] A function for random test based on longest run(UNCLASSI FIED)

2007-12-27 Thread Greg Snow
n(out1 >= out1[1]) There may be a better option, but this works and is fairly straight forward. Hope it helps, From: [EMAIL PROTECTED] on behalf of Park, Kyong H Mr ECBC Sent: Thu 12/27/2007 11:47 AM To: 'bogdan romocea' Cc: [EMAIL PROTECTED] Subje

Re: [R] A function for random test based on longest run (UNCLASSIFIED)

2007-12-27 Thread Dirk Eddelbuettel
On 27 December 2007 at 12:08, bogdan romocea wrote: | > require(tseries) | > ?runs.test | Also, take a look at dieharder, it implements a large number of | randomness tests: | http://www.phy.duke.edu/~rgb/General/dieharder.php Also note that CRAN has an RDieHarder package that provides access

Re: [R] A function for random test based on longest run (UNCLASSI FIED)

2007-12-27 Thread Park, Kyong H Mr ECBC
> [mailto:[EMAIL PROTECTED] On Behalf Of Park, Kyong H Mr > ECBC > Sent: Thursday, December 27, 2007 11:05 AM > To: 'r-help@r-project.org' > Subject: [R] A function for random test based on longest run > (UNCLASSIFIED) > > Classification: UNCLASSIFIED > Cavea

Re: [R] A function for random test based on longest run (UNCLASSIFIED)

2007-12-27 Thread bogdan romocea
g H Mr ECBC > Sent: Thursday, December 27, 2007 11:05 AM > To: 'r-help@r-project.org' > Subject: [R] A function for random test based on longest run > (UNCLASSIFIED) > > Classification: UNCLASSIFIED > Caveats: NONE > > Hello, R users, > > Has anyb

[R] A function for random test based on longest run of same events (U NCLASSIFIED)

2007-12-27 Thread Park, Kyong H Mr ECBC
Classification: UNCLASSIFIED Caveats: NONE Hello, R users, Has anybody written a function for random test based on the length of longest run of same events. I really appreciate your help. Kyong Park Classification: UNCLASSIFIED Caveats: NONE [[alternative HTML version deleted]] __

[R] A function for random test based on longest run (UNCLASSIFIED)

2007-12-27 Thread Park, Kyong H Mr ECBC
Classification: UNCLASSIFIED Caveats: NONE Hello, R users, Has anybody written a function for random test based on the length of longest run of same events. I really appreciate your help. Kyong Park Classification: UNCLASSIFIED Caveats: NONE [[alternative HTML version deleted]] __

Re: [R] a function to compute the cumulative distribution function (cdf) of the gamma

2007-10-08 Thread Ben Bolker
elodie gillain wrote: > > Dear Forum, > > I would need to write a function to calculate the cumulative distribution > function (cdf) of the gamma random variable. I am allowed to use the > following precoded functions: rgamma, pgamma, and dgamma. I am a little > overwhelmed by this project, I

[R] a function to compute the cumulative distribution function (cdf) of the gamma

2007-10-06 Thread elodie gillain
Dear Forum, I would need to write a function to calculate the cumulative distribution function (cdf) of the gamma random variable. I am allowed to use the following precoded functions: rgamma, pgamma, and dgamma. I am a little overwhelmed by this project, I am wondering how I should start. Shoul