0

how do i re-write this to get it to run ignoring the NAs?

I am expecting a correlation value between the variables and I am getting NA.

cor(vehicle_year,speed)

cor(subject_age,speed)

cor(posted_speed,speed)

R help
  • 1
  • 1
  • 1
    Please do not post (only) an image of code/data/errors: it breaks screen-readers and it cannot be copied or searched (ref: https://meta.stackoverflow.com/a/285557 and https://xkcd.com/2116/). Please include the code, console output, or data (e.g., `data.frame(...)` or the output from `dput(head(x))`) directly. – r2evans Dec 09 '22 at 01:23
  • 1
    Welcome to SO, R help! Questions on SO (especially in R) do much better if they are reproducible and self-contained. By that I mean including attempted code (please be explicit about non-base packages), sample representative data (perhaps via `dput(head(x))` or building data programmatically (e.g., `data.frame(...)`), possibly stochastically), perhaps actual output (with verbatim errors/warnings) versus intended output. Refs: https://stackoverflow.com/q/5963269, [mcve], and https://stackoverflow.com/tags/r/info. – r2evans Dec 09 '22 at 01:24
  • 1
    @r2evans-GONAVYBEATARMY well, `cor` doesn't take a `na.rm` argument, but `use = "pairwise.complete.obs"` should work well. – Gregor Thomas Dec 09 '22 at 02:45

0 Answers0