I am running this code from readr to import data and it functions perfectly"
df <- read_csv("Dataset.csv", col_names = TRUE, col_types = cols_only(VAR1, VAR2, VAR3)
I want to make it into a function so I can run it on multiple inputs, so I wrote this code:
extract_function <- function(x) {
df <- read_csv(x, col_names = TRUE, col_types = cols_only(VAR1, VAR2, VAR3)}
The function is created but when I execute the function it chunks through everything (looks like its working) but never creates the new data frame. Heres how I have been executing the function:
extract_function ("Dataset.csv")
- Why isn't it creating my new data frame once I put it into the function?
- How can I name the new data frame based on the input from csv? (would like the new dataframe to have the same name as the csv it extracted from)