Alex Gebben Work 8110df7d97 Created slides
2025-09-03 16:19:34 -06:00

41 lines
1.4 KiB
R

####Load libraries
library(tidyverse) #tidyverse is used to organize the data with read_csv()
library(fixest) #Fixest is load so a fixed effect model can be used.
#Creating directories to store the raw data set,
# so the results can reproduced more easily if the data changes.
dir.create("Data",showWarnings = FALSE)
dir.create("Data/Orig_Data",showWarnings = FALSE)
#Check if direjctory exits
dir.exists("Data/Orig_Data")
# Help --------------------------------------------------------------------
#List all files in the working directory
list.files()
#List all files in the working directory that end in png
list.files("./",pattern="*.png")
#list all files in the Data folder staring from the working directory
list.files("Data/")
#write a csv file to the directory
write_csv(diamonds, "Data/diamonds.csv")
#write a tab separated file to the directory (tsv)
write_tsv(diamonds, "Data/diamonds.tsv")
#list all files in the Data directory. Save in a variable.
FILE_LIST <- list.files("Data/")
print(FILE_LIST)
#Check if a file exists in the Data directory
file.exists("Data/DIAMOND.csv")
#Check if the file in the list exists
file.exists(FILE_LIST[1])
#Check if the file in the list exists
FILE_LOC <- paste0("./Data/",FILE_LIST[1])
print(FILE_LOC)
file.exists(FILE_LOC)
ggplot(diamonds, aes(x = carat, y = price)) +
geom_hex()
ggsave("diamonds.png")
dir.create("./data")