Lee Drown
Lee Drown

Reputation: 45

Attempt to apply non-function when creating column in R

I am trying to take a column called "F1" and create a new column called "F1.erb" by applying a formula the value in the F1 column. I have tried the following code:

data$F1.erb <- data$F1(21.4*log10((4.37/1000)+1))

Where "data" is the name of my data frame.

I received the following error message:

Error: attempt to apply non-function

What am I doing incorrectly?

Upvotes: 1

Views: 39

Answers (1)

akrun
akrun

Reputation: 886938

We need [ instead of (. The ( is used mainly as a function or to get codes in a block. Here, it seems to be interpreted as data$F1 is some kind of function which it is not. If we want to multiply then

data$F1 *(21.4*log10((4.37/1000)+1))

Upvotes: 1

Related Questions