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

reshaping the data from wide to long [duplicate]

$
0
0

Please help me with the following matter I have a wide data frame that I need to reshape.
This is the df I have

mydf <- data.frame(date=1983:1985,January=c(5,7,8),February=c(12,18,19))  
mydf

this is the output I need

output <- data.frame(date=rep(c(1983,1984,1985),each=2),Month=rep(c("January","February"),3),Value=c(5,12,7,18,8,19))
output

Viewing all articles
Browse latest Browse all 201839

Trending Articles



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