Group Abstract Group Abstract

Message Boards Message Boards

0
|
5.8K Views
|
6 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Transpose each column of a data set with the first column?

Posted 5 years ago
POSTED BY: Rory Foulger
6 Replies
Posted 5 years ago
POSTED BY: Rohit Namjoshi
POSTED BY: Henrik Schachner

If you want to end up with a DateListPlot (as you wrote), you first have to generate DateObject(s). The rest is just some re-arranging.

dates = DateObject[{#["date"], {"Day", "/", "Month"}}] & /@ ds;
data0 = Rest /@ ds;
data1 = MapThread[Function[{date, value}, {date, #} & /@ value], {dates, data0}];
DateListPlot[data1, GridLines -> Automatic]

enter image description here

I do not know if this is what you want, but I cannot see any other application of DateListPlot here.

POSTED BY: Henrik Schachner
Posted 5 years ago
POSTED BY: Rohit Namjoshi

Or without Table

gg[xx_] := {xx[[1]], #} & /@ Drop[xx, 1]

gg /@ assoc1
% // Grid

or

Function[{x}, {x[[1]], #} & /@ Drop[x, 1]] /@ assoc1
POSTED BY: Hans Dolhaine

My system (Mathematica 7) does not understand your assoc. So I tried this

assoc1 = {{"a" -> 5, "b" -> 7, "c" -> 9, "d" -> 8},
  {"a" -> 3, "b" -> 12, "c" -> 14, "d" -> 17},
  {"a" -> 8, "b" -> 0, "c" -> 5, "d" -> 32}}

ff[x_] := Table[{First[x], x[[j]]}, {j, 2, Length[x]}]

ff[assoc1[[1]]]

ff /@ assoc1
% // Grid
POSTED BY: Hans Dolhaine
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard