i need your help again. How can i adapt my code to get only ONE final dataframe (jointdataset) after every file in path
was merged to the intial dataframe knime.in
. I know lapply
will in this case return a list of dataframes but i am not able to change the syntax with apply
ect. without errors. If i try this i get this error message: "match.fun(FUN) : argument "FUN" is missing with no default"
library("dplyr")
library("stringr")
path ="C:/.../"
path2 ="C:/..."
files <- list.files(path, full.names=T)
knime.in <- read.csv(file=path2, header=TRUE, sep = ";")
dfList <- lapply(files, function(i) {
df <- read.csv(i, header=TRUE, col.names=c("Column.0", "Column.1"), sep = ";",row.names=NULL)
name =substr(i,sapply(str_locate_all(pattern = "/", i), tail, 1)[1]+1,nchar(i)-4)
jointdataset <-merge(knime.in, df_2, by.x=name, by.y ='Column.0',all = TRUE)
jointdataset <- jointdataset[ , ! names(jointdataset) %in% c(name)]
names(jointdataset)[names(jointdataset)=="Column.1"] <- name
print(name)
return(jointdataset)
})
Hope you can help me out with this again. Thank you!!!