Re: [R] Stuck trying to modify a function

2012-11-28 Thread Benjamin Ward (ENV)
ker. Best Wishes, Ben W. UEA (ENV) and The Sainsbury Laboratory. From: Jean V Adams [jvad...@usgs.gov] Sent: 27 November 2012 22:01 To: Benjamin Ward (ENV) Cc: r-help@r-project.org Subject: Re: [R] Stuck trying to modify a function Ben, You can use the

Re: [R] Stuck trying to modify a function

2012-11-27 Thread Jean V Adams
Ben, You can use the sample() function to randomly add -1, 0, or 1 to each observation, and control for the probability of mutation at the same time. Then you can use the match() function to make sure that any mutations in X are carried through to Y in the same way. I wrote the function to do

Re: [R] Stuck trying to modify a function

2012-11-27 Thread Milan Bouchet-Valat
Le mardi 27 novembre 2012 à 16:45 +, Benjamin Ward (ENV) a écrit : > Hi, > > I have the following data: > > Path_Number <- 5 > ID.Path <- c(1:Path_Number) # Make vector of ID's. > No_of_X <- sample(50:550, length(ID.Path), replace=TRUE) # > X <- split(sample(1:1, sum(No_of_X), replace=TRU

[R] Stuck trying to modify a function

2012-11-27 Thread Benjamin Ward (ENV)
Hi, I have the following data: Path_Number <- 5 ID.Path <- c(1:Path_Number) # Make vector of ID's. No_of_X <- sample(50:550, length(ID.Path), replace=TRUE) # X <- split(sample(1:1, sum(No_of_X), replace=TRUE), rep(ID.Path, No_of_X)) Y <- lapply(X,function(x) sample(x, round(runif(1, min=10, m