Or maybe that function should look more like vol.exp<-function(x) { V<-((coefficient1*(x)^exponent1)+(coefficient2*(x)^exponent2)+constant) V }
? *Ben * On Sat, Jul 30, 2011 at 10:06 AM, Benjamin Caldwell <btcaldw...@berkeley.edu > wrote: > Hello, > > I'm just trying to wrap my head around the syntax for creating loops, > functions in R. I have an array of values from a .csv. Looks something like > > header<-c(species,coefficient1, exponent1, coefficient2, exponent2, > constant) > > with a species name for the first column, and values for coefficient1, > exponent1, coefficient2, exponent2, constant for each species. > > The values are parameters for an equation > > V<-((coefficient1*(x)^exponent1)+(coefficient2*(x)^exponent2)+constant) > > x<1:100 > > I'd like to run the equation using the parameters for each species and the > vector x to simulate what V would be for the range of values x, and then > plot a graph of for each species. > > Would the way to do this be some sort of apply nested within a for loop? > Code so far looks like > > vol<-read.csv("frame.csv") > > vol.exp<-function(coefficient1, exponent1, coefficient2, exponent2, > constant,x) { > V<-((coefficient1*(x)^exponent1)+(coefficient2*(x)^exponent2)+constant) > V > } > x<1:100 > > Thanks > > *Ben * > > [[alternative HTML version deleted]] ______________________________________________ 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.