remove_NA2 | R Documentation |
This function allows you to remove the NAs found in two lists you are working with so you can calculate the correlation, for example.
remove_NA2()
> x = c(1, 2, 3, NA, 4, 5, NA)
> y = c(NA, 1, 1, NA, NA, 3, 5)
> newvars = remove_NA2()
Remember! remove_NA2() needs to know what you want the new lists to be stored in!
Make sure you typed *your new double list name here* = remove_NA2(). If not, press Esc to cancel.
What is the name of the first list with your data? x
What is the name of the second list with your data? y
Removed 4 NAs!
Both lists are stored in the variable you indicated at the beginning. You can save the two new lists by typing:
*new list 1 name* = *name of output*[[1]]
*new list 2 name* = *name of output*[[2]]
You can also do this whole process yourself by typing:
*new list 1 name* = x[!is.na(x) & !is.na(y)]
and
*new list 2 name* = y[!is.na(y) & !is.na(y)]
> new_x = newvars[[1]]
> new_y = newvars[[2]]
> new_x
[1] 2 3 5
> new_y
[1] 1 1 3
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.