'Trying to create a function to make a correlation plot where I correlate one of the variables, with some of the rest of the variables
So I found corr_var, and now I'm trying to create a function so I can use corr_var but not on ALL of my other variables, but on a specific set each time. I basically have this dataset where the first 28 are statistics from a school survey, and 29:127 are stats on health. and I want to correlate the 127 columns, but I don't want the first 28 to correlate to each other, or the 29:127 to correlate with each other, cuz I know those data points will correlate to almost .9 or more each time. I wanted to use corr_var, but I would need to create a new data frame that only includes 29:127 and the one I want to correlate it with, so I'm trying to create a function that does it for me instead. I need some help seeing what's wrong, as I'm not yet too familiar with all the coding stuff.
another way I wanted to go about this is create a ggpairs type of thing but I only relate the first 28 to the 29:127, and I'm not sure how to get there either. would appreciate hte helps. thanks:)
corr_varsexedtest <- function(data=df, variablenum = variablenum, variablename){ data %>% select(variablenum, 29:127) -> data1 corr_var(data1, # name of dataset variablename , # name of variable to focus on top = 5 # display top 5 correlations )}
corr_varsexedtest(sexedtest, 1, TBR2005)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
