0

Below is a sample of my dataset (current data). I am trying to restructure the dataset to obtain "my goal data". Thanks. Nader

My current data:

structure(list(County = c("Adams", "Adams", "Adams", "Adams", "Allen", "Allen", "Allen", "Allen", "Ohio","Ohio","Ohio","Ohio"), Year = c(1999, 2000, 2001, 2002, 1999, 2000, 2001, 2002, 1999, 2000, 2001, 2002)), class = "data.frame", row.names = c(NA, -12L))

My Goal:

structure(list(County = c("Adams", "Adams", "Adams", "Adams", "Ohio","Ohio","Ohio","Ohio", "Allen", "Allen", "Allen", "Allen", "Ohio","Ohio","Ohio","Ohio"), 
           Year = c(1999, 2000, 2001, 2002, 1999, 2000, 2001, 2002, 1999, 2000, 2001, 2002, 1999, 2000, 2001, 2002), 
           County_2 = c("Adams", "Adams", "Adams", "Adams", "Adams", "Adams", "Adams", "Adams","Allen", "Allen", "Allen", "Allen", "Allen", "Allen", "Allen", "Allen")),
         class = "data.frame", row.names = c(NA, -16L))
Nader Mehri
  • 514
  • 1
  • 5
  • 21
  • 2
    Hi Nader, Can you add a description of the rule that you want to use and what you have tried? That will help people answer your question. – jessi Feb 24 '20 at 18:25
  • 2
    so... you want to copy the column `County`? But only for some rows? And replcae the value for others???? Please read the info about [how to ask a good question](https://stackoverflow.com/help/how-to-ask) and how to give a [minimale reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610#5963610). That way you can help others to help you! – dario Feb 24 '20 at 18:37
  • Thanks! Here is a reproducible code for my problem. I need to restructure my data for the purpose of my shiny app. – Nader Mehri Feb 24 '20 at 19:46
  • @NaderMehri - see above comments. If you can edit your question to explain more about the logic or rules involved that would help a lot. – Ben Feb 25 '20 at 00:38

0 Answers0