+ Reply to Thread
Results 1 to 3 of 3

Thread: what is wrong with my code.

  1. #1
    Points: 1,078, Level: 17
    Level completed: 78%, Points required for next Level: 22

    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    what is wrong with my code.




    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 by Marwah Soliman; 11-03-2017 at 12:30 AM.

  2. #2
    ggplot2orBust
    Points: 72,900, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Awards:
    User with most referrers
    trinker's Avatar
    Location
    Buffalo, NY
    Posts
    4,424
    Thanks
    1,815
    Thanked 931 Times in 812 Posts

    Re: what is wrong with my code.

    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
    "If you torture the data long enough it will eventually confess."
    -Ronald Harry Coase -

  3. #3
    ggplot2orBust
    Points: 72,900, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Awards:
    User with most referrers
    trinker's Avatar
    Location
    Buffalo, NY
    Posts
    4,424
    Thanks
    1,815
    Thanked 931 Times in 812 Posts

    Re: what is wrong with my code.


    Any luck in building a mydata object?
    "If you torture the data long enough it will eventually confess."
    -Ronald Harry Coase -

+ Reply to Thread

           




Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts






Advertise on Talk Stats