Reputation: 99
Info:
Goal:
Issue with code:
cor_v1_v2 = function(v1, v2 = state.x77[,"Life Exp"], method = "pearson"){
cor(v1,v2,method = "pearson")
}
I have tried several variants such as:
cor_v1_v2 = function(v1, v2 = state.x77[,"Life Exp"], method = "input"){
cor(v1,v2,method = "input")
}
and:
cor_v1_v2 = function(v1, v2 = state.x77[,"Life Exp"], method = "pearson"){
cor(v1,v2,method)
}
I get return use errors for each. I know it's just my syntax and my thinking but I'm still stuck.
Upvotes: 0
Views: 43
Reputation: 173803
I think you just want
cor_v1_v2 = function(v1, v2 = state.x77[,"Life Exp"], method = "pearson"){
cor(v1, v2, method = method)
}
This will default to "pearson" but is changeable to whatever you want.
Upvotes: 2