# Đồ chơi trẻ em bé na chơi play

37

This article illustrates how to handle the “Error in do_one(nmeth) : NA/NaN/Inf in foreign function điện thoại tư vấn (arg 1)” in the R programming language.

Bạn đang xem: Đồ chơi trẻ em bé na chơi play

Let’s dive right in:

## Constructing Example Data

The following data is used as basement for this R programming tutorial.

set.seed(56389) # Create numeric example vectorx c(NA, rnorm(100))head(x) # Head of example vector# <1> na -1.72955699 1.57449671 -1.52165311 0.48225317 0.09359781
The previous output of the RStudio console shows the structure of our example data – It is a random numeric vector that contains one mãng cầu value at the first index position.

## Example 1: Reproduce the Error in do_one(nmeth) : NA/NaN/Inf in foreign function gọi (arg 1)

The following R programming syntax shows how to replicate the error message “NA/NaN/Inf in foreign function gọi (arg 1)” when using the kmeans function in R.

Let’s assume that we want khổng lồ apply the kmeans function to group our example vector into three clusters. Then, we may try khổng lồ use the following R code:

kmeans(x, 3) # Trying to lớn apply kmeans function# Error in do_one(nmeth) : NA/NaN/Inf in foreign function điện thoại tư vấn (arg 1)
Unfortunately, the RStudio console returns the “Error in do_one(nmeth) : NA/NaN/Inf in foreign function điện thoại tư vấn (arg 1)”.

The reason for this is that our input vector contains an mãng cầu value and the kmeans function cannot handle missing data.

Note that we have reproduced this error message based on a vector containing mãng cầu values. However, the same error message occurs when our đầu vào data contains non-numeric values that are not properly formatted as numbers.

So how can we solve this problem in R?

## Example 2: Fix the Error in do_one(nmeth) : NA/NaN/Inf in foreign function điện thoại tư vấn (arg 1)

This example illustrates how khổng lồ debug the “Error in do_one(nmeth) : NA/NaN/Inf in foreign function call (arg 1)”.

For this, we have to remove all na values from our vector using the is.na function:

As you can see, the previous R code produced a valid đầu ra without any error or warning messages.

## Video & Further Resources

Do you want to lớn learn more about errors in R? Then you may want lớn watch the following clip of my YouTube channel. In the video, I’m explaining the examples of this tutorial: