So I'm new to R, and I am trying to make a simple for loop to find the average of the row 'kJ/mol' for rows 1 and 2, 2 and 3, 3 and 4, and so on. I have the answer already through excel, but am trying to replicate through R. I have some broken code kind of on the right track but not sure where to go from here. Any advice would be helpful. Code below.

library(tidyverse)

data.frame(assign2)

data <- data.frame(assign2)

for i >= 1, data

i <- ('kJ/mol')

average <- ((i +(i+1))/2)

print(average)

Error message:

for i >= 1, data

Error: unexpected symbol in "for i"

i <- ('kJ/mol')

average <- ((i +(i+1))/2)

Error in i + 1 : non-numeric argument to binary operator

print(average)

Error in print(average) : object 'average' not found