Error when merging data bases


I have an issue with my database.
I have 50 csv files which contain: date, price
I used : sp500_monthly <- list.files("my directory") to merge all the 50 files in one. But it does not seems to work since when I try to do, for exemple: mean(sp500_monthly$price), I have the following error : "Error in sp500_monthly$price : $ operator is invalid for atomic vectors".

My question is: how can I do to display, mean, standard deviation, etcetera?

Thank you very much!

You have not merged any files. You have only gathered up the many filenames into a list.

You will need to use functions for reading CSV. Is that something you have experience with ?

Ah! thank you for your answer.
I could use xxx <- read.csv(file = "xxx.csv”, header = TRUE) ? Would it work ?


file_list <- list.files("mydirectory")
sp500_monthly <- map_dfr(file_list ,~read_csv(file.path("mydirectory",.)))

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.