I’m trying to write a function that will add items to two vectors, and then to create a third vector that is of the form 1, 2, 3, …, length of one of the newly modified vectors.  My problem is that what I’ve written doesn’t seem to return any of those modifications.  How can I get the new values to be returned? Here’s the function below.  I want to add a value, stp, to the end of the stpos vector, a value mcp to the end of the mcpos vector, and the to create that days vector.  When I call this function with numerical values for stp and mcp, and then ask to see stpos, mcpos, and days, nothing has been changed.  How can I fix this?

Here’s the function:
> addday <- function(stp,mcp,stpos,mcpos){stpos<-c(stpos,stp)
+ mcpos<-c(mcpos,mcp)
+ days<-c(1:length(stpos))}

David

______________________________________________
R-help@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.

Reply via email to