1

How can I transform my datatable from image 1 to image 2 using data.table function? mydatatable image 1 newdatatable image 2

Sorry, I couldn't write datatable with accurate codes.

Community
  • 1
  • 1
econes
  • 33
  • 3
  • 2
    Have you searched this site? There must be dozens of questions on melting data.tables. – Edward Apr 01 '20 at 13:16
  • Yes, I did. But I couldn't find like my case. I'm new in R programming so I am not be able to write code easily. – econes Apr 01 '20 at 13:22
  • The FAQ on transforming data from wide to long shows many methods. If you need more help than that, please both (a) give us some sample data to test on---we can't demonstrate solutions on pictures, and (b) show what you tried, so we can meet you where you are and correct any misconceptions. If you need help with (a), see the [FAQ on reproducible examples](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). The easiest way to share a bit of data in a copy/pasteable way is `dput`, like `dput(your_data[1:5, 1:7])` for the first 5 rows of the first 7 columns. – Gregor Thomas Apr 01 '20 at 13:38
  • One other minor comment: save mentions of `RStudio` to cases where the editor matters---like if you have code that doesn't run in RStudio but does run on the command line or in the default R GUI. – Gregor Thomas Apr 01 '20 at 13:41
  • Okey, thank you so much for your comments. I will pay attention to them. – econes Apr 01 '20 at 13:54
  • use 'dplyr' package and melt your dataset to long format – Daniel_j_iii Apr 02 '20 at 02:53

0 Answers0