Get Started →
Type & Coercion Errors

Argument not numeric or logical

Matches: argument is not numeric or logical

WHAT THIS ERROR MEANS

A function that expects numbers (like mean, sum, sd) received non-numeric data such as character strings.

HOW TO FIX IT

1. Check the column type with class(your_data$column).

2. Convert to numeric: as.numeric(your_data$column).

3. Make sure you're referencing the correct column.

CODE EXAMPLES

BAD — THIS CAUSES THE ERROR
mean(c("1", "2", "3"))  # character vector
GOOD — CORRECT APPROACH
mean(as.numeric(c("1", "2", "3")))

Still stuck?

Paste your code in RChat and the AI will fix this error in context.

Try RChat Free →

RELATED TYPE & COERCION ERRORS