Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in cor(x, snp.gen) : 'x' must be numeric (Loop) #2

Open
KatherinOtalora opened this issue Nov 9, 2022 · 0 comments
Open

Error in cor(x, snp.gen) : 'x' must be numeric (Loop) #2

KatherinOtalora opened this issue Nov 9, 2022 · 0 comments

Comments

@KatherinOtalora
Copy link

Hello everyone,

I have a simple problem with this loop in the section (Correlations of each candidate SNP with the environmental predictors):

foo <- matrix(nrow=(ncand), ncol=4) # 4 columns for 4 predictors
colnames(foo) <- c("ID","POP","SURFACE","ALTITUDE")

for (i in 1:length(cand$snp)) {
nam <- cand[i,2]
snp.gen <- gen.imp[,nam]
foo[i,] <- apply(pred,2,function(x) cor(x,snp.gen))
}

#Error in cor(x, snp.gen) : 'x' must be numeric

I understand that cor is a correlation, but in the x section what kind of input should I add to the loop in this case?

Thank you very much for your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant