Error:attempt to apply non-function

I'm trying to run the following code in R, but I'm getting an error.

I'm not sure what part of the formula is incorrect. Any help would be greatly appreciated.

> censusdata_20$AGB93 = WD * exp(-1.239 + 1.980 * log (DIAM93) + 0.207 (log(DIAM93))^2 - 0.0281 (log(DIAM93))^3) Error: attempt to apply non-function 
3

2 Answers

You're missing *s in the last two terms of your expression, so R is interpreting (e.g.) 0.207 (log(DIAM93))^2 as an attempt to call a function named 0.207 ...

For example:

> 1 + 2*(3) [1] 7 > 1 + 2 (3) 

Error: attempt to apply non-function

Your (unreproducible) expression should read:

censusdata_20$AGB93 = WD * exp(-1.239 + 1.980 * log (DIAM93) + 0.207* (log(DIAM93))^2 - 0.0281*(log(DIAM93))^3) 

Mathematica is the only computer system I know of that allows juxtaposition to be used for multiplication ...

3

I got the error because of a clumsy typo:

This errors:

knitr::opts_chunk$seet(echo = FALSE) 

Error: attempt to apply non-function

After correcting the typo, it works:

knitr::opts_chunk$set(echo = FALSE) 

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like