please help with saving data added during counting

hi! community i have the problem of saving missing data which i added by this code:

#install.packages("tidyverse")
#install.packages("rlist")

library(tidyverse)
library(rlist)
library(rowr)

getwd()
setwd("C:/R/")

T <- read.table("A.csv", header = TRUE, sep = ";", dec = ".")
k <- 1
i <- 1
count=0
dat <- length(T[1][[1]]) - 1

ei <- 8
for (k in 1:dat) {
  r <- T[[1]][k + 1] - T[[1]][k];
  b <- r>8;
  my_list <- list(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
  if (r < 7 | r > 8) {print(paste("difference is bigger than 8 or less than 7 in rows", T[[1]][k + 1], T[[1]][k]));
    if (b==TRUE){
      n <- r%/%ei
      print(n)
      count=count+1
           for  (i in 1:n) {
        a<- insertRows(data.frame(T)+i,data.frame(my_list),k+1)
       
        view(a)
       
        if (i>=i:n)
          write.table(a,file = "a1.csv", sep=";", dec=".", row.names=FALSE, col.names = TRUE)
        
      }
    }
  }
  else 
    print("right")
  print(count)
 }

it is saving only the last missing data. Can you help me with it?
this is my table, the program works on the first column.
Thanks


this is how it looks when I add data, but the problem that program adds data only in the last place where the distance between rows bigger than eight.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.