Need advice on a function to make a table of certain data, has a little problem with the result

so i'm doing an assignment for my r programming course

  filelist<- list.files(path= directory, pattern="csv", full.name=TRUE)
  bid <- numeric()
  nobs<-numeric()
  
  for(i in id) {
    data <- read.csv(filelist[i])
    b = complete.cases(data)
    g =data.frame(data[b,])
    
    nobs = c(nobs,length(g[,1]))
    id = c(bid,g[1,4])
    
  }
  data.frame(id,nobs)
}

the output show

when I input complete("specdata", c(2, 4, 8, 10, 12))
id nobs
1 12 1041
2 12 474
3 12 192
4 12 148
5 12 96

the id showed 12 instead of the id of the files data taken
anybody can help me with my code ?

I think you need reconsider the line I quoted above.

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