changed 3 years ago
Linked with GitHub

R Workshop Q & A

Use this to ask code-related questions for the workshop. Feel free to try and answer them for other people also!

Start a question with two hashes (##), this will create a break under which people can discuss the question & answer. Use three hashes (###) to title your answer.

How do I make make create a vector of values?

I want to create a vector with a bunch of strings in it, but I forgot how!

Using c()

Create a vector with the c() function!

my_vector <- c("horse", "cat", "dog")

Can I repeat a value without having to type it out multiple times?

I don't want to waste time typing out the same value over and over again, and I might make a mistake!

Use rep() function!

rep() will repeat what it is given, the number of times that you specify!

rep("horse", 5) # is the same as c("horse", "horse", "horse", "horse", "horse")
Select a repo