# what is wrong with my code.

#### Marwah Soliman

##### New Member
Hello,

there is a variable named quad take values from 1 to 9 ( 400 points)
I'm trying to simulate a z variable as follows:
fo for example if I have 30 points of quad=1 , i simulate 30 Z values with mean =0
the if I have 15 points of quad=2,I simulate 15 Z value with mean = 2
....

and so on

is the below code is correct??

Code:
for(j in 1:9)
{
if (mydata$quad[j]==j){ for(i in 1:length(mydata$quad)){

mydata$z[i]=rnorm(n=length(mydata$quad),mean=c(0,2,1,3,7,9,10,11,2),1)
}
}
}

Last edited:

#### trinker

##### ggplot2orBust
HEre's the problem when I run it mydata isn't defined:

Code:
Error in mydata : object 'mydata' not found

You just need to define an object called mydata that has a quad column

#### trinker

##### ggplot2orBust
Any luck in building a mydata object?