I had imported my data from excel, containing 64 rows and 15 columns, into R in order to calculate the autocorrelation using the acf(). I've been to other similar threads and the only workable code I could find was:
structure(list(V1 = c(24.1, 6.3, 39.1, 11.97, 23.47), V2 = c(5.63, 9.91, 19.98, 16.14, 15.76), V3 = c(21.08, 5.82, 23.5, 27.71, 3.54)), class = "data.frame", row.names = c(NA, -5L))
for(i in 1:3) {acf(data[ ,i], lag.max = 1, type = "correlation", plot = TRUE , na.action = na.exclude)}
Using this loop, I was able to obtain the autocorrelation plots but there were no mathematical values generated for the autocorrelation coefficient. I tried assigning a variable name to this loop but after the run, it only returned as NULL.
I also used the following code in place of the for loop:
lapply(split(A,col(A)), function(ts) acf(ts, lag.max=1))
where, A is a matrix with 64 rows and 15 columns. But it doesn't work either because when I convert my imported data into a matrix and run this code, it shows the error "A is not numeric" and also, I think ts stands for time series but when I insert the data in place of ts, there is an error.