Gong, thanks!! but your syntax did work out as I would expect. here following
are the reasons:
each row from my original data frame represents data from one subject. when
the one type I number and the
two type II numbers are drawn from the original data frame, both type I
number and type II numb
here is my original data frame
a b c A B C
[1,] 1 2 3 4 5 6
[2,] 7 8 9 10 11 12
[3,] 13 14 15 16 17 18
a, b, c are type I variables
A, B, C are type II variables
how can I create a new data frame in which:
1) in each row, there are one random number from type I var
Hi,
I would try to sample by row index and column index. Hope it helps.
df <- data.frame(matrix(1:18,nrow=3,ncol=6,byrow=TRUE))
colnames(df) <- c(letters[1:3],LETTERS[1:3])
## Generate a new data frame with 10 rows
one <- two <- three <- numeric(10)
for (i in 1:10) {
## Sample from type I
col
3 matches
Mail list logo