I am working from two Excel sheets. This is my code:
# Read the first dataset
df1 <- read.csv("ATLweather.csv")
# Read the second dataset
df2 <- read.csv("electricityprices.csv")
# Merge the datasets
library("dplyr")
merged_df <- left_join(df1, df2, by = "Timestamp")
head(merged_df)
library(writexl)
# Save the merged data frame as an Excel file
write_xlsx(merged_df, path = "C:/Users/Nathaniel/Documents/newfile.xlsx")
This successfully merges the data sets, but replaces all the data in my "cost" column with "NA" (pictured below in my environment).
This is my first time doing any coding, so I'm at a loss as to how to fix this. What am I doing wrong?

As @Claudio pointed out, the
Timestampvectors are character vectors that are formatted differently (you can tell they are characters by the "chr" in your screenshot). R doesn't know that characters should be interpreted as dates. You can change them both to date objects and merge them that way, but a simple way would be to convert one format to the other and leave them as characters (sometimes playing with dates in R is more work than it is worth, but see the packagelubridateif you want to play with them as dates).Here is a quick fix:
Then just change
Timestamphere todf2$Timestampfor your purposes.