I need my for loop to output a vector instead of just a series of answers. Here is my code:
mean=211
sd=sqrt(558)
x=rnorm(100,mean,sd)
cost=40
for(i in c(1:100))
{
if(x[i]<=200)
{
profit=x[i]-cost
}
else
{
profit=200-cost
}
print(profit)
}
How do I get it to print the different profits as one vector?
Aucun commentaire:
Enregistrer un commentaire