search for: tmp_df

Displaying 9 results from an estimated 9 matches for "tmp_df".

Did you mean: tmp_d
2006 Feb 24
1
(Newbie) Aggregate for NA values
...means causing some sort of bias. So I want the summary stat for the NA's also. Here is a simple example session (edited to remove the typos I made, comments added later): > tmp_a <- 1:10 > tmp_b <- rep(1:5,2) > tmp_c <- rep(1:2,5) > tmp_d <- c(1,1,1,2,2,2,3,3,3,4) > tmp_df <- data.frame(tmp_a,tmp_b,tmp_c,tmp_d); > tmp_df$tmp_c[9:10] <- NA ; > tmp_df tmp_a tmp_b tmp_c tmp_d 1 1 1 1 1 2 2 2 2 1 3 3 3 1 1 4 4 4 2 2 5 5 5 1 2 6 6 1 2 2 7 7 2 1...
2024 Jul 25
1
please help generate a square correlation matrix
...ibrary(tidyverse) dat %>% names() %>% expand.grid(., .) %>% apply(1L, \(x) { tmp <- dat[rowSums(dat[x]) > 0, ] tmp2 <- cor.test(tmp[[ x[1L] ]], tmp[[ x[2L] ]]) c(tmp2$estimate, P = tmp2$p.value) }) %>% t() %>% as.data.frame() %>% cbind(tmp_df, .) %>% na.omit() The second is, in my opinion the one that makes more sense. If you see the results, cor is symmetric (as it should) so the calculations are repeated. If you only run the cor.tests on the combinations of names(dat) by groups of 2, it will save a lot of work. But the outp...
2024 Jul 26
1
please help generate a square correlation matrix
...;% > expand.grid(., .) %>% > apply(1L, \(x) { > tmp <- dat[rowSums(dat[x]) > 0, ] > tmp2 <- cor.test(tmp[[ x[1L] ]], tmp[[ x[2L] ]]) > c(tmp2$estimate, P = tmp2$p.value) > }) %>% > t() %>% > as.data.frame() %>% > cbind(tmp_df, .) %>% > na.omit() > > > The second is, in my opinion the one that makes more sense. If you see > the results, cor is symmetric (as it should) so the calculations are > repeated. If you only run the cor.tests on the combinations of > names(dat) by groups of 2, it will sa...
2024 Jul 27
1
please help generate a square correlation matrix
...> apply(1L, \(x) { > > tmp <- dat[rowSums(dat[x]) > 0, ] > > tmp2 <- cor.test(tmp[[ x[1L] ]], tmp[[ x[2L] ]]) > > c(tmp2$estimate, P = tmp2$p.value) > > }) %>% > > t() %>% > > as.data.frame() %>% > > cbind(tmp_df, .) %>% > > na.omit() > > > > > > The second is, in my opinion the one that makes more sense. If you see > > the results, cor is symmetric (as it should) so the calculations are > > repeated. If you only run the cor.tests on the combinations of > > na...
2024 Jul 27
1
please help generate a square correlation matrix
...> tmp <- dat[rowSums(dat[x]) > 0, ] > > > tmp2 <- cor.test(tmp[[ x[1L] ]], tmp[[ x[2L] ]]) > > > c(tmp2$estimate, P = tmp2$p.value) > > > }) %>% > > > t() %>% > > > as.data.frame() %>% > > > cbind(tmp_df, .) %>% > > > na.omit() > > > > > > > > > The second is, in my opinion the one that makes more sense. If you see > > > the results, cor is symmetric (as it should) so the calculations are > > > repeated. If you only run the cor.tests on th...
2024 Jul 25
1
please help generate a square correlation matrix
Hi Rui, You are always very helpful!! Thank you, I just modified your R codes to remove a row with zero values in both column pair as below for my real data. Ding dat<-gene22mut.coded r <- P <- matrix(NA, nrow = 22L, ncol = 22L, dimnames = list(names(dat), names(dat))) for(i in 1:22) { #i=1 x <- dat[[i]] for(j in (1:22)) { #j=2 if(i == j) { #
2024 Jul 27
1
please help generate a square correlation matrix
...tmp <- dat[rowSums(dat[x]) > 0, ] > > > tmp2 <- cor.test(tmp[[ x[1L] ]], tmp[[ x[2L] ]]) > > > c(tmp2$estimate, P = tmp2$p.value) > > > }) %>% > > > t() %>% > > > as.data.frame() %>% > > > cbind(tmp_df, .) %>% > > > na.omit() > > > > > > > > > The second is, in my opinion the one that makes more sense. If you see > > > the results, cor is symmetric (as it should) so the calculations are > > > repeated. If you only run the cor.tests...
2024 Jul 27
1
please help generate a square correlation matrix
...> > > tmp2 <- cor.test(tmp[[ x[1L] ]], tmp[[ x[2L] ]]) > > > > > c(tmp2$estimate, P = tmp2$p.value) > > > > > }) %>% > > > > > t() %>% > > > > > as.data.frame() %>% > > > > > cbind(tmp_df, .) %>% > > > > > na.omit() > > > > > > > > > > > > > > > The second is, in my opinion the one that makes more sense. If you see > > > > > the results, cor is symmetric (as it should) so the calculations are > >...
2024 Jul 28
1
please help generate a square correlation matrix
...> tmp2 <- cor.test(tmp[[ x[1L] ]], tmp[[ x[2L] ]]) > > > > > c(tmp2$estimate, P = tmp2$p.value) > > > > > }) %>% > > > > > t() %>% > > > > > as.data.frame() %>% > > > > > cbind(tmp_df, .) %>% > > > > > na.omit() > > > > > > > > > > > > > > > The second is, in my opinion the one that makes more sense. If you see > > > > > the results, cor is symmetric (as it should) so the calculations are...