> -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of > [EMAIL PROTECTED] > Sent: Thursday, August 28, 2008 11:36 AM > To: r-help@r-project.org > Subject: [R] Function not returning a vector? > > Why does: > > (shape/scale) * (1:365/scale)^(shape - 1) > > return a vector of numbers but calling a function > > hasard(1:365,shape,scale) > > defined like: > > hazard <- function(x,shape,scale) > { > return (shape/scale) * (x/scale)^(shape - 1) > } > > Only return a single value? It is like x becomes a single > value passed as an argument. > > Thank you. > > Kevin >
Change your function definition to one of the following (I don't know which is "better"). hazard <- function(x,shape,scale) { return( (shape/scale) * (x/scale)^(shape - 1) ) } hazard <- function(x,shape,scale) { (shape/scale) * (x/scale)^(shape - 1) } Hope this is helpful, Dan Daniel J. Nordlund Washington State Department of Social and Health Services Planning, Performance, and Accountability Research and Data Analysis Division Olympia, WA 98504-5204 ______________________________________________ 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 commented, minimal, self-contained, reproducible code.