Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- > ## Solution: reshape is obsolete. Use reshape2 with acast:
- > library(reshape2)
- >
- > t = 0:3
- > thesd = 0.1
- > dat = data.frame(
- + a1 = sin(2*pi*t/length(t)) + rnorm(t, sd=thesd),
- + b1 = sin(2*pi*t/length(t) - pi) + rnorm(t, sd=thesd),
- + c1 = sin(2*pi*t/length(t) - pi/2) + rnorm(t, sd=thesd),
- + t = t
- + )
- >
- > test_mx = acast(melt(dat, id.vars="t"), variable ~ t)
- > as.data.frame(test_mx)
- 0 1 2 3
- a1 0.00881139 1.00898951 0.007116073 -0.82006264
- b1 -0.12102260 -0.97846639 -0.095028245 0.84406265
- c1 -0.89275912 -0.02657619 1.214589078 0.07990604
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement