diff --git a/R/server.R b/R/server.R index f9af2f6..d24f63e 100644 --- a/R/server.R +++ b/R/server.R @@ -38,12 +38,16 @@ server <- function(input, output, session) { data2 <- readData(file2) } - numData1Cols <- length(data1) - numData2Cols <- length(data2) - - corrData <- Hmisc::rcorr(as.matrix(data1), as.matrix(data2)) - pValuesMatrix$p_values <- corrData$P[1:numData1Cols, 1:numData2Cols] - correlationMatrix$corr_matrix <- corrData$r[1:numData1Cols, 1:numData2Cols] + lastData1ColIndex <- length(data1) + firstData2ColIndex <- length(data1) + 1 + corrResult <- Hmisc::rcorr(as.matrix(data1), as.matrix(data2)) + print(corrResult) + # this bc Hmisc::rcorr cbinds the two data.tables and runs the correlation + # so we need to extract only the relevant values + pValuesMatrix$p_values <- corrResult$P[1:lastData1ColIndex, firstData2ColIndex:length(colnames(corrResult$P))] + print(pValuesMatrix$p_values) + correlationMatrix$corr_matrix <- corrResult$r[1:lastData1ColIndex, firstData2ColIndex:length(colnames(corrResult$r))] + print(correlationMatrix$corr_matrix) }, error = function(e) { shiny::showNotification(paste('Error:', e$message), type = 'error') })