Error when using `curve()` to plot

,

Hi, I'm trying to plot the original date with the predictions of the best models using curve() because I'm working with polynomial models, but I keep getting this error:

Error in curve(predict(best_models[[i]]$best_model, newdata = data.frame(get(normalized_columns[i]))), :
'expr' must be a function, or a call or an expression containing 'x'

This is the part of the code that it is generating the error:

# Plot the real data vs. the best model for each combination par(mfrow = c(2, 3)) # Arrange plots in a 2x3 grid for (i in 1:6) { curve(predict(best_models[[i]]$best_model, newdata = data.frame(get(normalized_columns[i]))), from = min(filtered_resp_data[[normalized_columns[i]]]), to = max(filtered_resp_data[[normalized_columns[i]]]), col = "blue", lwd = 2, xlab = normalized_columns[i], ylab = "xxx", main = paste("Real Data vs. Best Model (Degree", best_models[[i]]$best_degree, ")"))

Hi,
Since you have not provided any minimal reproduceable example,
the only help I can offer is to focus you on the problem:

newdata = data.frame(get(normalized_columns[i]))

why do you use get() here?
If normalized_columns is a list of dataframes then you don't need get.

This is saying that the first argument you should supply to curve() should be a function, whereas you supplied data instead. Could I ask what led you to use curve()?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.