Reputation: 37
id | name |
---|---|
101 | A |
102 | B |
103 | C |
So I have a data frame (see above) with an id for each competition. I want to use these ids to form a string that I then can use for an API request. The request requires for the ids to be in the following form:
101%2C102%2C103
Any ideas of how I might achieve this would be very welcome.
Upvotes: 0
Views: 188
Reputation: 872
The paste0 function with the collapse parameter returns a character object from the vector (102, 102, 103...) with each item separated by the supplied string.
df <- data.frame(id = c(101, 102, 103))
paste0(df$id, collapse="%2C")
[1] "101%2C102%2C103"
Upvotes: 1