This error post really needs to be renamed. When you view this, walk with your formulas about the place of the error message. Ninety ripe percent of the moment you’re looking in ~ a straightforward syntax worry with exactly how you room laying out your calculations in her code.
You are watching: R attempt to apply non-function
One of your calculations, most likely one which offers brackets to rest up your order the operations, is absent an operator somewhere in the code. Over there is a significant difference in how R handle the complying with two statements, identical other than for a single character.
profit = units * (unit_price – unit_cost)profit = units (unit_price – unit_cost)In the an initial example, R will fix for the calculation within the brackets (price – cost) and also multiply that by the value in the variable units. Basic math.In the second example, since there is no * to determine what operation to pursue, R interprets the totality thing as a role call. Settle for the difference in between price and cost and also apply the role that is named units to change the result.Except that course, there is no duty named units. But there is things named units. For this reason what the heck, lets use THAT come the value in question. Therefore a really confused variable (units) which is most certainly NOT an R role (not even close!) is unexpectedly “applied” (Dr. Evil air quotes) to the value we fed it.
At which suggest the routine realizes it is trying to do totally unnatural things to an innocent small variable and also throws one error: attempt to use non-function.
SIGH. And this is why we can’t have actually nice things.
See more: 5419 W Sunset Blvd Los Angeles Ca 90027, 5419 West Sunset Blvd, Los Angeles, Ca
How To fix “Attempt to use non-function”Joking aside, this one is right forward. Look at her calculations with a fine toothed comb, paying close attention to any situation where you use brackets. Make certain you different those bracketed items indigenous other aspects of the calculation through an proper operator (+, -, %, *, other operators).R requirements to chilled on this error message. This is usually a syntax error.
report this ad
Resources to help you leveling data repertoire and evaluation using R. Automate all the things!
report this ad