0

I am working with R and I have a table that look like this...

A
B
C
D
E
F

And I need the table to look like this...

A
A
A
A
A
B
B
B
B
B
C
C
C
C
C
D
D
D
D
D
E
E
E
E
E
F
F
F
F
F

So,I need the same values 5 times in order to match them with another column.

Any help would greatly appreciated.

Thanks!

Ajrhjnd
  • 330
  • 1
  • 9

1 Answers1

0

Not sure if the table has associated data that also has to be duplicated. Looking at a vector or single data.frame column can use rep

data <- LETTERS[1:6]
rep(data, each = 5)  # will repeat each position 5 times prior to going to next position
rep(data, times = 5)  # will repeat entire array 5 times
manotheshark
  • 4,297
  • 17
  • 30
  • Hello again, I have been trying to apply the rep function, but the output that it gives me it is 5 lists with the content of the data frame. In other words I get .. $data A B C D E F $data A B C D E F etc... I know that it is related to the type of data, but really don't know how to fix it. Maybe I should have said that I am working with a tibble. – Ajrhjnd Oct 22 '20 at 08:52
  • It is ok. I already found a solution. I used the as.vector(dataName$dataColumn). Then apply the rep function as you wrote it and the converted it back to a tibble. – Ajrhjnd Oct 22 '20 at 09:36