Error in `$<`(`*tmp*`, "subject", value = "") : replacement has 1 row, data has 0

sorry guys. so far I have opened some topics to be able to solve some problem of the entire code, but I always have problems.

now I put you all the function I wrote and the error that is returned to me.

it is a very big data set (millions of instances) .. when I open some files in small portions, there are no problems, when I run R, there is always some problem that comes out a little at a time, because to read the whole file , it takes a few hours of software work.


fold_name <- "../Tests/"
f_name <- c("340535")

elenco_file<-list.files("../Tests/",recursive = T, 
                         pattern = "340535\\.txt$",full.names = TRUE) 

testfail <- grep ("Fail",elenco_file) # return lines that should not be read

x <- NA
for(i in 2 :length(elenco_file)) {

   f_name <- elenco_file[i]
#  I add columns with data that interest me
  subject <- strsplit(elenco_file[i], "/")[[1]][3:3]  
  act     <- strsplit(elenco_file[i], "/")[[1]][6.6]  
  test    <- strsplit(elenco_file[i], "/")[[1]][7:7]  
  sensor  <- strsplit(elenco_file[i], "/")[[1]][8:8]  
# skip the not correct file 
 if( has_element(testfail,i))
  if( {
    x <- read.table(paste(fold_name,f_name, sep=""), fill = T,header = T,
                                                                   skip= 4)
    x$subject <- subject 
    x$act     <- act
    x$test    <- test
    x$sensor  <- sensor
  else {
    y <- read.table(paste(fold_name,f_name, sep=""), fill = T, header = T, 
                                                                   skip = 4)
    y$subject <- subject
    y$act     <- act
    y$test    <- test
    y$sensor  <- sensor
    x <- rbind(x,y)



Error in `$<`(`*tmp*`, "subject", value = "") : 
  replacement has 1 row, data has 0

In addition: There were 50 or more warnings (use warnings() to see the first 50)

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.