Quantcast
Channel: StackExchange Replication Questions
Viewing all articles
Browse latest Browse all 17268

Replicate entries in DataFrame in R

$
0
0

I have a dataframe of company names: (names)

               names
 1               3M CO
 2 ABBOTT LABORATORIES
 3          ABBVIE INC
 4       ACCENTURE PLC
 5             ACE LTD
 6         ACTAVIS PLC

I want to replicate each entry 5 times so I have:

               names
 1               3M CO
 1               3M CO
 1               3M CO
 1               3M CO
 1               3M CO
 2 ABBOTT LABORATORIES
 2 ABBOTT LABORATORIES
 2 ABBOTT LABORATORIES
 2 ABBOTT LABORATORIES
 2 ABBOTT LABORATORIES
 3          ABBVIE INC
 3          ABBVIE INC
 3          ABBVIE INC
 3          ABBVIE INC
 3          ABBVIE INC
  ......

I have tried append, and rep but think I may need a for loop?


Viewing all articles
Browse latest Browse all 17268

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>