2

I have a function that retrieves game data from ESPN. It takes one argument. Need a way to create a list of game ids that the function can loop over. We will call the name of the function "get_data".

The function works for a single game

get_data(1000001) 

But if I have multiple games stored in a list... how can I loop over them in one call?

game_ids <- c("1000001", "1000002", "1000003") get_data(game_ids) 

1 Answer 1

2

If it is not vectorized, Vectorize it and apply on a vector of 'ids' with length >= 1

Vectorize(get_data)(game_ids) 

Or another option is to loop over the vector and apply the function individually

lst1 <- lapply(game_ids, function(x) get_data(x)) 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.