Split from Double loop to create a dataframe
I have a problem that i thought that i could solve myself, but it doesn't work
I have on my folder, several .txt and i want to analyse the distance between each document.
For example :
/desktop/folder/
I have " 1.txt ", " 2.txt ", " 3.txt"
For each document, i have for every line a word, like " ok, good, funny "
What i want is to studie the distance between two documents with jaccard distance and have a result like :
doc 1 / doc 2 / result
1.txt 1.txt 1,0
1.txt 2.txt 0,3
1.txt 3.txt 0,2
2.txt 1.txt 1,0
2.txt 2.txt 0,3
3.txt 3.txt 0,2
3.txt 1.txt 1,0
3.txt 2.txt 0,3
3.txt 3.txt 0,2
In order to that, here is the full code
folder <- "/desktop/folder/ " # path to folder that holds multiple .csv files
files_names3 <- list.files(path="/Users/sylvain/desktop/folder/", pattern="*.txt")
create several data frame for each document
for (i in 1:length(files_names3)){
assign(files_names3[i],
read.delim(files_names3[i])
)}
Then, i tried this to create the whole, but it doesn't work, any ideas why ?
all <- ''
for (i in 1:nrow(files_names3)){
for(i in 1:nrow(files_names3)) {
all[((i-1)*length(files_names3)+j),] <- c(files_names3[i], files_names3[j], textrank_jaccard(read.delim(paste(folder,top$cat1[i], sep='')),read.delim(paste(folder,top$cat2[i], sep=''))))
}
}