Mohammad Tanvir Ahamed
2011-Apr-18 15:04 UTC
[R] Reorder a data frame according a column randomly reordered.
Hello all , I have a data frame like this X1X2X3 11815 22916 331017 441118 551219 661320 771421 now i want to randomly reorder the variable X2 but the row element should be same as for example X1X2X3 12916 251219 331017 471421 561320 61815 741118 how can i do that ?? Hint : this could be helpful : if X2 is only a vector like this X2<-c(8,9,10,11,12,13,14) so i can easily reorder it by using sample commend sample (X2 , size=length(X2), replace=FALSE) may be i have to use lapply commend with sample commend . /.......Tanvir Ahamed [[alternative HTML version deleted]]
Uwe Ligges
2011-Apr-18 16:20 UTC
[R] Reorder a data frame according a column randomly reordered.
On 18.04.2011 17:04, Mohammad Tanvir Ahamed wrote:> Hello all , > I have a data frame like this > > X1X2X3 > 11815 > 22916 > 331017 > 441118 > 551219 > 661320 > 771421 > > now i want to randomly reorder the variable X2 but the row element should be same > as for example > > X1X2X3 > 12916 > 251219 > 331017 > 471421 > 561320 > 61815 > 741118 > > how can i do that ?? > > Hint : > this could be helpful : > > if X2 is only a vector like this > X2<-c(8,9,10,11,12,13,14) > > so i can easily reorder it by using sample commend > sample (X2 , size=length(X2), replace=FALSE) >Yes, and then replace X2 with your reordered X2. Uwe Ligges> may be i have to use lapply commend with sample commend . > > > /.......Tanvir Ahamed > > [[alternative HTML version deleted]] > > > > > ______________________________________________ > R-help at 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.
Reasonably Related Threads
- Feeding decoder with reordered packets
- [LLVMdev] Prevent a intrinsic to be reordered?
- [LLVMdev] Debugging information problem: code being reordered / debug point jumping around
- [LLVMdev] Debugging information problem: code being reordered / debug point jumping around
- Builtin reordered