0

I have a .csv file I have imported to R, I need to convert the Data to Long format, where varying will be date from 4/1/1996 to 12/16/2017. The data has been stored in R, where the variables are RegionName, State, the sizerank and the different Dates which the observation was made for each Region in each State. Of course, the Idvar, will be the SizeRank:

Part of the Data is short as a snapshot

Uwe
  • 41,420
  • 11
  • 90
  • 134
sigma
  • 1

1 Answers1

2
library(data.table)
dt <- fread("file.csv")
melt(dt, id.vars = c("RegionName", "State", "SizeRank"), variable.name = "date")

I think this does what you want.

wligtenberg
  • 7,695
  • 3
  • 22
  • 28