Open maxheld83 opened 9 years ago
... depending on the input to qmethod.
qmethod
Check this out:
str(lipset[[1]]) str(invisible(qmethod(dataset = lipset[[1]], nfactors = 3, forced = TRUE))$dataset) str(as.matrix(lipset[[1]])) str(invisible(qmethod(dataset = as.matrix(lipset[[1]]), nfactors = 3, forced = TRUE))$dataset)
yields:
> str(lipset[[1]]) 'data.frame': 33 obs. of 9 variables: $ US1: int -1 0 -2 0 -2 1 0 -1 0 -1 ... $ US2: int -1 0 -1 -3 2 3 1 1 -4 0 ... $ US3: int 2 -2 -2 4 -1 0 -4 -3 1 -4 ... $ US4: int 3 1 -3 -1 -1 3 -3 -2 0 -4 ... $ JP5: int -4 -1 3 -1 1 1 4 2 -4 4 ... $ CA6: int 1 -3 0 3 3 4 -2 0 -2 -2 ... $ UK7: int 2 0 -2 1 0 1 -1 -3 0 -1 ... $ US8: int -2 2 0 -3 -4 4 0 -1 -1 -1 ... $ FR9: int 3 1 0 1 -4 -3 2 2 -2 0 ... > str(invisible(qmethod(dataset = lipset[[1]], nfactors = 3, forced = TRUE))$dataset) Q-method analysis. Finished on: Fri Aug 21 19:32:14 2015 Original data: 33 statements, 9 Q-sorts Forced distribution: TRUE Number of factors: 3 Rotation: varimax Flagging: automatic Correlation coefficient: pearson 'data.frame': 33 obs. of 9 variables: $ US1: int -1 0 -2 0 -2 1 0 -1 0 -1 ... $ US2: int -1 0 -1 -3 2 3 1 1 -4 0 ... $ US3: int 2 -2 -2 4 -1 0 -4 -3 1 -4 ... $ US4: int 3 1 -3 -1 -1 3 -3 -2 0 -4 ... $ JP5: int -4 -1 3 -1 1 1 4 2 -4 4 ... $ CA6: int 1 -3 0 3 3 4 -2 0 -2 -2 ... $ UK7: int 2 0 -2 1 0 1 -1 -3 0 -1 ... $ US8: int -2 2 0 -3 -4 4 0 -1 -1 -1 ... $ FR9: int 3 1 0 1 -4 -3 2 2 -2 0 ... > str(as.matrix(lipset[[1]])) int [1:33, 1:9] -1 0 -2 0 -2 1 0 -1 0 -1 ... - attr(*, "dimnames")=List of 2 ..$ : chr [1:33] "sta_1" "sta_2" "sta_3" "sta_4" ... ..$ : chr [1:9] "US1" "US2" "US3" "US4" ... > str(invisible(qmethod(dataset = as.matrix(lipset[[1]]), nfactors = 3, forced = TRUE))$dataset) Q-method analysis. Finished on: Fri Aug 21 19:32:14 2015 Original data: 33 statements, 9 Q-sorts Forced distribution: TRUE Number of factors: 3 Rotation: varimax Flagging: automatic Correlation coefficient: pearson int [1:33, 1:9] -1 0 -2 0 -2 1 0 -1 0 -1 ... - attr(*, "dimnames")=List of 2 ..$ : chr [1:33] "sta_1" "sta_2" "sta_3" "sta_4" ... ..$ : chr [1:9] "US1" "US2" "US3" "US4" ...
This can cause unexpected problems (it was the root cause of kernel panic in #236).
Maybe we want to streamline this at some point, so that results$dataset is always either a data.frame or a matrix.
results$dataset
I'm in favor of the matrix, because all the cells are, in fact, of the same data type (integers).
This depends on whether the initial (raw) data is a matrix or a data.frame. I agree that we can just add a code line at the beginning of qmethod() to transform whatever comes into a matrix.
qmethod()
... depending on the input to
qmethod
.Check this out:
yields:
This can cause unexpected problems (it was the root cause of kernel panic in #236).
Maybe we want to streamline this at some point, so that
results$dataset
is always either a data.frame or a matrix.I'm in favor of the matrix, because all the cells are, in fact, of the same data type (integers).