Попробуйте прочитать все строки по отдельности, а затем разделить текст и целевые столбцы.
Попробуйте:
df= read.delim('TrainingData.csv',
quote = "",
row.names = NULL,
stringsAsFactors = FALSE,
header = F, as.is = F,
colClasses = "character",
blank.lines.skip = T,
sep = "\n")
df$target = regmatches(df$V1, regexpr(pattern = "[^,]*$", text = df$V1))
df$V1 = sub(pattern = ",[^,]*$", replacement = "", x = df$V1)
, где df
означает dataset_original
Пример:
С файлом, содержащим:
hello,0
world,1
not,right,1
this,one,is,even,worse,0
Этот метод возвращает:
> df
V1 target
1 hello 0
2 world 1
3 not,right 1
4 this,one,is,even,worse 0