Help with Function()

#1

I want to make a function that gives me the share of missing values in a variable. I am very new to r, and I am not sure that I am doing this correctly. At this point I am really confused. The function I have so far is this:

na_prop <- function(x) {
prop_na <- mean(is.na(x))
return(prop_na)
}

It is not giving me the result I want when I use it later, what am I doing wrong? Is there a better way to make this function?

0 Likes

#2

How do you know that it doesn't do what you want? Can you show how you use it later? It would help if you put this in reprex (more info FAQ: What's a reproducible example (`reprex`) and how do I do one? and FAQ: How to do a minimal reproducible example ( reprex ) for beginners)

0 Likes

closed #3

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

0 Likes