I saw a question similar to this previously, but I didn't fully understand the answer. Here is my original function:
fxn_import_data <- function(file_path, filen)
{work <-setwd(file_path)
yelp <- stream_in(file(filen)) #creating a data fram called yelp using stream_in function}
#head(yelp, 10)
yelp_flat<- flatten(yelp) #helps turn JSON files with multiple df's into tabular format
#str(yelp_flat) #displays abbreviated content (not needed for this data set)
scoop <- as_data_frame(yelp_flat)
}
The purpose of this function is to open the file source of my data and unpack it, which it does. I need this data to run my next function, which is shown below:
fxn_create_meta<- function(fxn_import_data, scoop) {return(scoop)
fxn_import_data <- function(file_path, filen)
scoop <- as_data_frame(yelp_flat)
scoop$homePlayers <- NULL #eliminates homePlayers column
scoop$awayPlayers <- NULL
pop <- scoop %>% separate(ball, c("ball_x", "ball_y", "ball_z"), sep = ",")
#separates one column into multiple
l <- pop %>% separate(ball_x, c("throw","ball_x"), sep = "c")
gh <- l %>% separate(ball_z, c("ball_z", "tra"), sep = "\\)")
Meta <- gh %>% separate(ball_x, c("kol", "ball_x"), sep = "\\(")
Meta$tra <- NULL
Meta$kol <- NULL
Meta$throw <- NULL
return(Meta)
}
However, when I try to run the second function, it tells me that the object "scoop" is undefined. How do I fix this?