Displaying 1 result from an estimated 1 matches for "pricechange".
2011 Jul 11
1
Ifelse statement
...eprice in the ifelse, I need it to be defined
pieceprice<-cbind()
#Now I define a function with an ifelse statement. So if the binomial
deviation returns one, I add a 'new' price() to the pieceprice vector else I
repeat the last element of the pieceprice vector and add it to pieceprice.
pricechange<-function()
{ifelse(rbinom(1,1,2/3)==1,
pieceprice<-cbind(pieceprice,price()),
pieceprice<-cbind(pieceprice,pieceprice[1,length(pieceprice)]))}
#But now if I try this (Even with rbinom(1,1,1), pieceprice remains NULL
pricechange()
pieceprice
> pricechange()
[1] 79.20426
> piecepri...