remove_NA2: Remove NAs from Two Data Sets

View source: R/remove_NA2.R

remove_NA2R Documentation

Remove NAs from Two Data Sets

Description

This function allows you to remove the NAs found in two lists you are working with so you can calculate the correlation, for example.

Usage

remove_NA2()

Examples

> 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

jrpriceUPS/Math160UPS documentation built on April 28, 2024, 12:41 p.m.