I am a beginner in R coding. I have experience with c and c#. I want to check two tables against each other and create new columns with data from the other table. My dataframes are really big and nested for-loops are taking too much time in R. What can I do instead of the following?
f = as.data.frame(dataset)
setwd("C:\\Folder\\")
fnew = read.csv("file.csv", header=TRUE, sep=",")
f[, 13] <- NA
f[, 14] <- NA
f[, 15] <- NA
f[, 16] <- NA
for (i in 1:nrow(f))
{
for (j in 1:nrow(fnew))
{
if (as.character(f[i, 1]) == as.character(fnew[j, 2]))
{f[i, 13] = fnew[j, 4]
f[i, 14] = fnew[j, 5]
f[i, 15] = fnew[j, 6]
f[i, 16] = fnew[j, 7]}
}
}