Hey everyone,
I'm in kind of a data frame conundrum here. Essentially I have two experimental tasks (i.e., Task 1 and Task 2), where I want to run a simple correlation on the entire data frame but , as you can probably see, the NAs won't allow me to find a correlation between tasks. And I can't drop or impute them either.
I tried several different manuvers and a pairwise deletion but I'm still getting NAs like in the output below.
Does anyone have a solution to this? I need the correlation between Task_1 and Task_2. I honestly stumped. The code below can replicate the screenshots and would be best to work a solution with. Than
library(tidyverse)
set.seed(123)
data <- data.frame(
Task_1A = rnorm(10),
Task_1B = rnorm(10),
Task_2A = rnorm(10),
Task_2B = rnorm(10),
Col5 = rnorm(10),
Col6 = rnorm(10),
Col7 = rnorm(10),
Col8 = rnorm(10)
)
data$Task_1A[c(1, 2, 3, 4, 5)] <- NA
data$Task_1B[c(1, 2, 3, 4, 5)] <- NA
data$Task_2A[c(6, 7, 8, 9, 10)] <- NA
data$Task_2B[c(6, 7, 8, 9, 10)] <- NA
Corr <- cor(data, use = "pairwise.complete.obs")
Thanks