I’m having a perplexing error for an R Snippet node. The error I’m getting is:
Execute failed: class org.knime.filehandling.core.data.location.cell.SimpleFSLocationCell cannot be cast to class org.knime.core.data.StringValue (org.knime.filehandling.core.data.location.cell.SimpleFSLocationCell is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @689187df; org.knime.core.data.StringValue is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @615e83ac)
The code is:
library(tidyverse)
library(dplyr)
library(tidyr)
library(janitor)
library(data.table)
data_date ← c(‘2024-01-17’,‘2024-01-24’,‘2024-01-31’,‘2024-02-07’,‘2024-02-14’,‘2024-02-21’,‘2024-02-26’,‘2024-03-06’,‘2024-03-13’,‘2024-03-20’)
lst_folder ← paste0(“C:\Docs\Data Science\Refresh_”,data_date)
fil_locat<- lst_folder[10] #“C:\Docs\Data Science\Refresh_2024-03-06”
files_load ← list.files(path = fil_locat, pattern = “*.csv”, full.names = TRUE)
comb_file ← files_load %>% map_df(~read_csv(.,col_names=TRUE,id=‘path’ )) %>% bind_rows() %>% clean_names() %>% subset(select = -c(path))
knime.out ← comb_file %>% data.table()
I’ve executed line by line with no issues. The default data structure formed was a “tbl_df” for comb_file and I know knime.out requires either a data frame, a table, a list or a matrix.
comb_file is a data table as I verified it with an additional line casting it to data.table() and assigning it back to comb_fil and looking at it within the snippet workspace it looks fine and says it’s a data.table.
I’ve tried casting comb_file as a data.frame as well with the same error.
Quite confused if the workspace shows the variable is a data.table and knime.out accepts a data table, why it’s not sending the variable to the output.