Closed fabern closed 5 years ago
Good point Fabian!
I'll fix that when I'm back Thanks,
Marc
Le lun. 6 août 2018 à 15:06, Fabian Bernhard notifications@github.com a écrit :
Dear Marc,
If only one group is simulated with simulx(), "id.out = TRUE" results in id and group not being factors.
I suggest modification of lines 105-116 of "convertmlx.R" to get more consistent behavior of simulx() for simulation of a single vs simulation of multiple groups. Simply set id/group to factor(1) instead of 1.
if (id.out==TRUE){ if (is.null(dk$id)){ dk$id <- factor(1) nk <- ncol(dk) dk <- dk[,c(nk,(1:(nk-1)))] } if (is.null(dk$group)){ dk$group <- factor(1) nk <- ncol(dk) dk <- dk[,c(1,nk,(2:(nk-1)))] } }
Furthermore use of ncol() instead of length() on a data.frame might be more explicit.
Hope the intent is clear. Best, Fabian
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/MarcLavielle/mlxR/issues/17, or mute the thread https://github.com/notifications/unsubscribe-auth/AJ3yuoaNEigWWWg9542WS-LhZkAsIHXBks5uN_j_gaJpZM4Vv7u_ .
A more concise solution for appending a column at the beginning would be:
if (id.out==TRUE){
if (is.null(dk$id)){
dk <- data.frame(id=factor(1), dk)
}
if (is.null(dk$group)){
dk <- data.frame(group=factor(1), dk)
}
}
This would also correspond to the coding style applied in lines 88-102.
Dear Marc,
If only one group is simulated with simulx(), "id.out = TRUE" results in id and group not being factors.
I suggest modification of lines 105-116 of "convertmlx.R" to get more consistent behavior of simulx() for simulation of a single vs simulation of multiple groups. Simply set id/group to factor(1) instead of 1.
Furthermore use of ncol() instead of length() on a data.frame might be more explicit.
Hope the intent is clear. Best, Fabian