Dear Group
I have to populate a column in a R dataframe containing say 99 rows, where 
for every 3 row one row (randomly determined) of the column should take 
the value 1 and the other 2 row of that column should take the value 0.
I used the command
dataframe$new<-rep(sample(c(0,1,0),3,replace=FALSE),99)
This command repeats the same patter of response across the entire 
column..
I would rather want the response be randomly populated in every set of 3 
rows..
Eg. if the first row of that column has 0 and the second row of that 
column takes a value of 1 and third row of that column takes 0 again,
for the next 3 rows of that column i would want this order differently say 
1,0,0 and so on..
Can anybody help how i can acheive this.
Thanks.
Regards
Vijayan Padmanabhan

Can you avoid printing this?
Think of the environment before printing the email.
-------------------------------------------------------------------------------
Please visit us at www.itcportal.com
******************************************************************************
This Communication is for the exclusive use of the intended recipient (s) and 
shall
not attach any liability on the originator or ITC Ltd./its Subsidiaries/its 
Group 
Companies. If you are the addressee, the contents of this email are intended 
for your 
use only and it shall not be forwarded to any third party, without first 
obtaining 
written authorisation from the originator or ITC Ltd./its Subsidiaries/its 
Group 
Companies. It may contain information which is confidential and legally 
privileged
and the same shall not be used or dealt with by any third party in any manner 
whatsoever without the specific consent of ITC Ltd./its Subsidiaries/its Group 
Companies.
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to