[R] replicate rows
catalin roibu
c@t@linroibu @ending from gm@il@com
Sun Jul 8 10:44:54 CEST 2018
Dear R users,
I want to replicate sampled rows in data frame. The sampling results must
be in this form:
a b Rep
[1,] 3 4.0 R1
[2,] 6 8.0 R1
[3,] 1 0.1 R2
[4,] 6 8.0 R2
[5,] 1 0.1 R3
[6,] 5 7.0 R3
I have a code but I didn't succeed to insert to rep column.
This is my code:
a<-c(1,2,3,4,5,6)
b<-c(0.1, 0.2, 4, 6, 7, 8)
ab<-cbind(a, b)
x<-replicate(3, sample(1:nrow(ab), 2))
aa<-ab[x, ]
Please help me to solve that problem!
Thank you very much!
Best regards!
Catalin
--
-
-
Catalin-Constantin ROIBU
Lecturer PhD, Forestry engineer
Forestry Faculty of Suceava
Str. Universitatii no. 13, Suceava, 720229, Romania
office phone +4 0230 52 29 78, ext. 531
mobile phone +4 0745 53 18 01
FAX: +4 0230 52 16 64
silvic.usv.ro <http://www.usv.ro/>
[[alternative HTML version deleted]]
More information about the R-help
mailing list