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 symbol is or how to fix it? Thanks.
On 25/10/2015 10:20 PM, alexander.thomas.1 at 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 instructor for help.> > compute.hr <- function(pid){d <- subset(Batting.60, playerID==pid) > sum(d$HR)}That works for me. Duncan Murdoch> > Every time I try this, it says there's an unexpected symbol. Any idea on what the unexpected symbol is or how to fix it? Thanks. > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
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, <alexander.thomas.1 at 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: > > 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 symbol is or how to fix it? Thanks. > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]