Hello I'm new for R and can help me.
error massage "Error in head(T[rowss, (i + 1)]) - head(T[rowss, i]) : non-numeric argument to binary operator"
code bellow here
library("xlsx") #import library
T <- read_excel("D:/Education/UOR Lecture/Project/4/NEW.xlsx") #read xlsx file
View(T)
fun <- function(T,rowss) {
rows <- nrow(T)
columns <- ncol(T)
t <- 3
H <- 15.8
last <- 0
for (i in 3:columns-1){
k <- (head(T[rowss,(i+1)])-head(T[rowss,i]))/(head(T[rowss,(i+1)])*t*(H-head(T[rowss,(i+1)])))
last <- k+last
}
fun <- last/columns
return(fun)
}
T is a table read from excel sheet
and i also using class function for make sure all are numeric and all are numeric expect T and using class function for T show class(T) [1] "tbl_df" "tbl" "data.frame"
please Help
dput(head(name_of_data_frame))
and edit your question with the output?name_of_data_frame
should be whatever you store the result forread_excel
...I would recommend avoid usingT
(used forTRUE
) and call it something else...and how are you intending to call your functionfun
? – Ben