Error in fun(x[[i]], …) : only defined on a data frame with all numeric-alike variables

Error:

error in fun(x[[i]], …): only defined on a data frame with all numeric-alike variables

Explanation:

This error message is related to a function called ‘fun’ which expects a data frame as its argument. The error occurs when the data frame passed to the function does not consist of all numeric or numerical variables.

Example:

Let’s consider an example to better understand this error. Suppose we have a data frame called ‘df’ with three variables: ‘age’, ‘name’, and ‘salary’. ‘age’ is a numeric variable representing the age of a person, ‘name’ is a character variable containing the person’s name, and ‘salary’ is a numeric variable representing their salary. Now, if we try to apply the function ‘fun’ on this data frame, the error will be triggered because the ‘name’ variable is not numeric.


# Example data frame
df <- data.frame(age = c(25, 30, 35),
                 name = c("John", "Jane", "Michael"),
                 salary = c(50000, 60000, 70000))

# Applying the function with the data frame
result <- fun(df)
# Error: only defined on a data frame with all numeric-alike variables
        

Similar post

Leave a comment