I have two data sets, I want to match the postIDs and then concatenate the strings. newfile contains 40,500 rows and df2 contains 226,000 rows
library(pracma)
for(i in 1:nrow(newfile))
{
for(j in 1:nrow(df2))
{
if(newfile[i,1]==df2[j,6])
{
newfile[i,3]= strcat(newfile[i,3], df2[j,4], collapse = " ")
}
}
}
newfile[i,1]
is postid for newfile and df2[j,6]
is postid for df2 matrix.
newfile[i,3]
is text for newfile and df2[j,4]
is text for df2.
I wish to concatenate the two strings if post id matches. The problem is the amount of rows in df2 and newfile makes the R go unresponsive.
Looking for any suggestion on string concatenation in R. I am also open to suggestions if I need to change from matrix to some other data type. Already tried data frame and it failed.