How can I remove NA data in R language?

In R language, you can use the function na.omit() to remove NA values from the data. This function will return a new data frame or vector without any NA values.

Here is an example:

# 创建一个包含NA值的向量
x <- c(1, 2, NA, 4, 5)

# 去除NA值
x <- na.omit(x)

# 打印结果
print(x)

Output result:

[1] 1 2 4 5

In this example, the na.omit() function removes NA values from vector x and returns a new vector x without any NA values.

bannerAds