I have a block of R code looks like this:
replicates <- list()
data_path <- "D:/data"
file_list <- list.files(data_path, pattern = "\\.rds$", full.names = TRUE)
for (file_path in file_list) {
loaded_data <- readRDS(file_path)
extracted_list <- loaded_data[[1]]$my_data
# Append the extracted list to the combined_list
replicates <- c(replicates, list(extracted_list))
}
however when I try to copy this block to Notion, the format becomes so weird with only one line code, like this:
replicates <- list()data_path <- "D:/data" file_list <- list.files(data_path, pattern = "\\.rds$", full.names = TRUE) #here comes the rest of the original code, still in this line, I delete them
It works well on Windows, but not the Mac that I am using now. I have no idea how to fix it. I hope someone can help me out there, thanks!