Hello! I am trying to calculate percentage change of Real GDP per capita in R. However, I get Error: non-numeric argument to binary operator. By the way, this is the first question I ever submit, so please excuse me if I mess up the information needed.
The data set contains GDP and HCIP for the EU, Norway, Sweden, and Denmark from 1995 - 2020.
library(readxl) data <- read_excel("dataEUNORD.xlsx") # Real GDP EURY <- 100*data$`YP - Euro area*`/data$`HCIP - Euro area*` NORY <- 100*data$`YP - Norway`/data$`HCIP - Norway` DKRY <- 100*data$`YP - Denmark`/data$`HCIP - Denmark` SERY <- 100*data$`YP - Sweden`/data$`HCIP - Sweden` # Making a set of all 4 real GDPs (include the year) RY <- cbind(data[,1], EURY, NORY, DKRY, SERY) # Taking the log differences as percentage change growth <- 100*diff(log(RY))
Error in r[i1] - r[-length(r):-(length(r) - lag + 1L)] :
non-numeric argument to binary operator
Trying to solve it, i have usind these codes, however, I am still not able to produce a growth rate:
RY2 = as.data.frame(sapply(RY, as.numeric)) RY3 = as.numeric(RY) growth <- 100*diff(as.numeric(log(RY))) growth <- 100*diff(log(RY2)) growth <- 100*diff(log(RY3))
Error: 'list' object cannot be coerced to type 'double'
I hope this is enough information so you'll be able to help. In any case, thank you very much in advance!