0
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.

1 Answer 1

1

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"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.