[R] Function help

2015-10-26 Thread alexander . thomas . 1
Hello, I'm following an example in the book, analyzing baseball data with R, but it's not working for me. The example is: compute.hr <- function(pid){d <- subset(Batting.60, playerID==pid) sum(d$HR)} Every time I try this, it says there's an unexpected symbol. Any idea on what the unexpected

Re: [R] Function help

2015-10-26 Thread Duncan Murdoch
On 25/10/2015 10:20 PM, alexander.thoma...@louisville.edu wrote: > Hello, > > I'm following an example in the book, analyzing baseball data with R, but > it's not working for me. The example is: We don't know what "the book" is. If this is the textbook for your class, you should ask your

Re: [R] Function help

2015-10-26 Thread Jim Lemon
Hi Alexander, I suspect that when you write "try" you mean that you try to run the function with some value for "pid". The "unexpected symbol" error message usually includes the offending symbol and that will probably identify the problem. Jim On Mon, Oct 26, 2015 at 1:20 PM,

Re: [R] R function help!

2013-02-18 Thread Pete Brecknock
? ticket.ns-c(1,1,1,1,2,5,5,10,10,10) draw=NULL for (i in 1:25){ draw[i] - sum(sample(ticket.ns,40,replace=TRUE)) } print(draw) HTH Pete -- View this message in context: http://r.789695.n4.nabble.com/R-function-help-tp4658998p4659001.html Sent from the R help mailing list archive at Nabble.com

Re: [R] R function help!

2013-02-18 Thread Rolf Turner
Pete: Please don't do people's homework for them! At most, give them a ***hint*** only. cheers, Rolf Turner On 02/19/2013 12:01 PM, Pete Brecknock wrote: simonj16 wrote Consider an urn that contains 10 tickets, labelled: 1,1,1,1,2,5,5,10,10,10 I want to draw with replacement

Re: [R] function help?

2010-09-21 Thread Cormac Long
Hi there Petr, Apologies for only replying to your post now - I hope the code included below helps you out. An alternative function documentation approach would be the one I took when faced with a similar problem - I wrote some functions to allow me to embed a retrievable function specification

Re: [R] function help?

2010-09-20 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 17.09.2010 17:02:29: On 9/16/10 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),

Re: [R] function help?

2010-09-17 Thread Duke
On 9/16/10 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 help?

2010-09-17 Thread Jeff Newmiller
If having the definition of the function appear when you enter the name of the function elicits a hate response, then perhaps you should not be using R. That characteristic of R is fundamental and unlikely to change: in R everything is an object, and the result of evaluating an expression is

Re: [R] function help?

2010-09-17 Thread Duke
On 9/17/10 12:46 PM, Jeff Newmiller wrote: If having the definition of the function appear when you enter the name of the function elicits a hate response, then perhaps you should not be using R. That characteristic of R is fundamental and unlikely to change: in R everything is an object,

[R] function help?

2010-09-16 Thread Duke
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 for me how to do that? Thanks, D. __

Re: [R] function help?

2010-09-16 Thread Duncan Murdoch
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 for me how to do that? The help text is separate from

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

[R] Function Help

2009-10-11 Thread jimdare
Hi there, I have created the function below: pirate-function(x){ a-x-1; b-a/5; c-a-b; d-c-1; e-d/5; f-d-e; g-f-1; h-g/5; i-g-h; j-i-1; k-j/5; l-j-k; m-l-1; n-m/5; o-m-n; final-o/5; final } I want to run this function until the output ('final') is an exact integer (e.g. 893.0 rather than

Re: [R] Function Help

2009-10-11 Thread cls59
jimdare wrote: Hi there, I have created the function below: pirate-function(x){ a-x-1; b-a/5; c-a-b; d-c-1; e-d/5; f-d-e; g-f-1; h-g/5; i-g-h; j-i-1; k-j/5; l-j-k; m-l-1; n-m/5; o-m-n; final-o/5; final } I want to run this function until the output ('final') is an exact

Re: [R] Function Help

2009-10-11 Thread Ben Bolker
cls59 wrote: jimdare wrote: Hi there, I have created the function below: pirate-function(x){ a-x-1; b-a/5; c-a-b; d-c-1; e-d/5; f-d-e; g-f-1; h-g/5; i-g-h; j-i-1; k-j/5; l-j-k; m-l-1; n-m/5; o-m-n; final-o/5; final } I want to run this function until the output

Re: [R] function help

2008-10-17 Thread Dimitris Rizopoulos
take a look at ?mapply(); for instance, you can use something like this (untested): dat - Sample(...) mapply(Power, dat$Gmean, dat$Gsd, MoreArgs = list(alfa = 0.05, m1 = 57, s1 = 33, n1 = 200, n2 = 100)) I hope it helps. Best, Dimitris Alex99 wrote: Hi everyone, I have dataset which I

Re: [R] function help

2008-10-17 Thread Jorge Ivan Velez
Dear Alex, Try this: # Data name=read.table(textConnection( X8 X9 X10 X102 X110 X177 X283 X284 X286 X292 X297 X306 X308 X314 0 1 000100000000 0 0 001000000010 0 1 0000000

Re: [R] function help

2008-10-17 Thread Jorge Ivan Velez
Dear Alex, Just a _minor_ change in the function powers: # powers # n is the number of samples # DATA is the ORIGINAL data set powers=function(n,m2,n2,s2,DATA){ outp=Sample(DATA,n) # DATA was 'name' before, which doesn't make sense mymeans=outp$Gmean mysds=outp$Gsd