Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 205372

Is there any R code to repeat a same value for multiple rows?

$
0
0

My df looks like this now.

A B C
1 3 .
1 6 .
1 9 .
2 1 .
2 2 . 
2 5 .
3 9 .
3 3 .
3 2 .

Below is the ideal dataframe I am try to create:

  • Variable A refers to individuals (user-id). Each individual has three rows.
  • Each individual has different values for variable B...
  • whereas they need to have a same value of variable C.

I need to repeat a same value of variable C for each individual. I was wondering how I can give each participant the same value of variable C so that variable C is repeated three times for each participant.

A B C
1 3 1
1 6 1
1 9 1
2 1 3
2 2 3 
2 5 3
3 9 8
3 3 8
3 2 8

Viewing all articles
Browse latest Browse all 205372

Trending Articles



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