Group Abstract Group Abstract

Message Boards Message Boards

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

How can I merge lists using Riffle and Partition, when I need a function?

Posted 12 years ago

I've got the data, containing the values in 5 studies and the days in the first column. I am trying to create the ErrorListPlot, but I've got the problem with syntax.

Needs["ErrorBarPlots`"]

pathTransplant = 
  "C:UsersMeklonownCloudRegenLabDataWeightTransplant_
weight.xlsx";

dataTransplant1Weight = Import[pathTransplant, {"Data", 1, All, 2}];
dataTransplant2Weight = Import[pathTransplant, {"Data", 1, All, 3}];
dataTransplant3Weight = Import[pathTransplant, {"Data", 1, All, 4}];
dataTransplant4Weight = Import[pathTransplant, {"Data", 1, All, 5}];
dataTransplant5Weight = Import[pathTransplant, {"Data", 1, All, 6}];
dataTransplantWeight = List[dataTransplant1Weight, dataTransplant2Weight, dataTransplant3Weight, dataTransplant4Weight, dataTransplant5Weight];

dataDay = Import[pathTransplant, {"Data", 1, All, 1}];
meanTransplant = Mean[dataTransplantWeight];
standardErrorTransplant = StandardDeviation[dataTransplantWeight]/Sqrt[Length[dataTransplantWeight]];


plotDataTransplant = Partition[Riffle[dataDay, meanTransplant], 2]
plotDataTransplantErr = Partition[Riffle[plotDataTransplant, standardErrorTransplant], 2]

ErrorListPlot[plotDataTransplantErr]

The problem is with plotDataTransplantErr = Partition[Riffle[plotDataTransplant, standardErrorTransplant], 2] It gives me the output like this:

{{{0., 245.6}, 3.9064}, {{1., 204.8}, 3.33766}, {{3., 202.6}, 2.65707}...

It is practically what I need, but I cannot insert the text "ErrorBar" in it, as I need something like this for input of ErrorListPlot:

{{{0., 245.6}, ErrorBar [3.9064]}, {{1., 204.8}, ErrorBar [3.33766]}, {{3., 202.6}, ErrorBar [2.65707]}

This doesn't work either:

ErrorListPlot[{plotDataTransplant, ErrorBar[standardErrorTransplant]}]

Strange plot

Attachments:
POSTED BY: Ivan Gumenyuk
6 Replies
POSTED BY: W. Craig Carter
Posted 12 years ago

Sounds like a dark magic) But I still have the problem. It's 1:07 here, so I should sleep for a while. Can you provide me some links to the documentation from my case? Or can you solve the current problem if you have some time. It's hard for me to understand the problem after 12 hours of hard work(

plotDataTransplantErr={{{0., 245.6}, 3.9064}, {{1., 204.8}, 3.33766}, {{3., 202.6}, 
  2.65707}, {{6., 214.2}, 3.18434}, {{9., 237.}, 
  2.46982}, {{12., 272.2}, 3.81314}, {{15., 296.}, 
  2.40832}, {{18., 313.6}, 4.31972}, {{21., 323.4}, 3.88072}}
plotDataTransplantErr = plotDataTransplantErr /. {{a_, b_}, c_} -> {{a, b}, ErrorBar[c]}

The output is abnormal:

{{{{{0., 245.6}, {1., 204.8}, {3., 202.6}, {6., 214.2}, {9., 
     237.}, {12., 272.2}, {15., 296.}, {18., 313.6}, {21., 
     323.4}}, {{{0., 245.6}, 3.9064}, {{1., 204.8}, 
     3.33766}, {{3., 202.6}, 2.65707}, {{6., 214.2}, 
     3.18434}, {{9., 237.}, 2.46982}, {{12., 272.2}, 
     3.81314}, {{15., 296.}, 2.40832}, {{18., 313.6}, 
     4.31972}, {{21., 323.4}, 3.88072}}}, 
  ErrorBar[{{0., 245.6, x}, {1., 204.8, x}, {3., 202.6, x}, {6., 
     214.2, x}, {9., 237., x}, {12., 272.2, x}, {15., 296., x}, {18., 
     313.6, x}}]}, {{{{0., 245.6}, {1., 204.8}, {3., 202.6}, {6., 
     214.2}, {9., 237.}, {12., 272.2}, {15., 296.}, {18., 
     313.6}, {21., 323.4}}, {{{0., 245.6}, 3.9064}, {{1., 204.8}, 
     3.33766}, {{3., 202.6}, 2.65707}, {{6., 214.2}, 
     3.18434}, {{9., 237.}, 2.46982}, {{12., 272.2}, 
     3.81314}, {{15., 296.}, 2.40832}, {{18., 313.6}, 
     4.31972}, {{21., 323.4}, 3.88072}}}, 
  ErrorBar[{{0., 245.6, x}, {1., 204.8, x}, {3., 202.6, x}, {6., 
     214.2, x}, {9., 237., x}, {12., 272.2, x}, {15., 296., x}, {18., 
     313.6, x}}]}, {{{{0., 245.6}, {1., 204.8}, {3., 202.6}, {6., 
     214.2}, {9., 237.}, {12., 272.2}, {15., 296.}, {18., 
     313.6}, {21., 323.4}}, {{{0., 245.6}, 3.9064}, {{1., 204.8}, 
     3.33766}, {{3., 202.6}, 2.65707}, {{6., 214.2}, 
     3.18434}, {{9., 237.}, 2.46982}, {{12., 272.2}, 
     3.81314}, {{15., 296.}, 2.40832}, {{18., 313.6}, 
     4.31972}, {{21., 323.4}, 3.88072}}}, 
  ErrorBar[{{0., 245.6, x}, {1., 204.8, x}, {3., 202.6, x}, {6., 
     214.2, x}, {9., 237., x}, {12., 272.2, x}, {15., 296., x}, {18., 
     313.6, x}}]}, {{{{0., 245.6}, {1., 204.8}, {3., 202.6}, {6., 
     214.2}, {9., 237.}, {12., 272.2}, {15., 296.}, {18., 
     313.6}, {21., 323.4}}, {{{0., 245.6}, 3.9064}, {{1., 204.8}, 
     3.33766}, {{3., 202.6}, 2.65707}, {{6., 214.2}, 
     3.18434}, {{9., 237.}, 2.46982}, {{12., 272.2}, 
     3.81314}, {{15., 296.}, 2.40832}, {{18., 313.6}, 
     4.31972}, {{21., 323.4}, 3.88072}}}, 
  ErrorBar[{{0., 245.6, x}, {1., 204.8, x}, {3., 202.6, x}, {6., 
     214.2, x}, {9., 237., x}, {12., 272.2, x}, {15., 296., x}, {18., 
     313.6, x}}]}, {{{{0., 245.6}, {1., 204.8}, {3., 202.6}, {6., 
     214.2}, {9., 237.}, {12., 272.2}, {15., 296.}, {18., 
     313.6}, {21., 323.4}}, {{{0., 245.6}, 3.9064}, {{1., 204.8}, 
     3.33766}, {{3., 202.6}, 2.65707}, {{6., 214.2}, 
     3.18434}, {{9., 237.}, 2.46982}, {{12., 272.2}, 
     3.81314}, {{15., 296.}, 2.40832}, {{18., 313.6}, 
     4.31972}, {{21., 323.4}, 3.88072}}}, 
  ErrorBar[{{0., 245.6, x}, {1., 204.8, x}, {3., 202.6, x}, {6., 
     214.2, x}, {9., 237., x}, {12., 272.2, x}, {15., 296., x}, {18., 
     313.6, x}}]}, {{{{0., 245.6}, {1., 204.8}, {3., 202.6}, {6., 
     214.2}, {9., 237.}, {12., 272.2}, {15., 296.}, {18., 
     313.6}, {21., 323.4}}, {{{0., 245.6}, 3.9064}, {{1., 204.8}, 
     3.33766}, {{3., 202.6}, 2.65707}, {{6., 214.2}, 
     3.18434}, {{9., 237.}, 2.46982}, {{12., 272.2}, 
     3.81314}, {{15., 296.}, 2.40832}, {{18., 313.6}, 
     4.31972}, {{21., 323.4}, 3.88072}}}, 
  ErrorBar[{{0., 245.6, x}, {1., 204.8, x}, {3., 202.6, x}, {6., 
     214.2, x}, {9., 237., x}, {12., 272.2, x}, {15., 296., x}, {18., 
     313.6, x}}]}, {{{{0., 245.6}, {1., 204.8}, {3., 202.6}, {6., 
     214.2}, {9., 237.}, {12., 272.2}, {15., 296.}, {18., 
     313.6}, {21., 323.4}}, {{{0., 245.6}, 3.9064}, {{1., 204.8}, 
     3.33766}, {{3., 202.6}, 2.65707}, {{6., 214.2}, 
     3.18434}, {{9., 237.}, 2.46982}, {{12., 272.2}, 
     3.81314}, {{15., 296.}, 2.40832}, {{18., 313.6}, 
     4.31972}, {{21., 323.4}, 3.88072}}}, 
  ErrorBar[{{0., 245.6, x}, {1., 204.8, x}, {3., 202.6, x}, {6., 
     214.2, x}, {9., 237., x}, {12., 272.2, x}, {15., 296., x}, {18., 
     313.6, x}}]}, {{{{0., 245.6}, {1., 204.8}, {3., 202.6}, {6., 
     214.2}, {9., 237.}, {12., 272.2}, {15., 296.}, {18., 
     313.6}, {21., 323.4}}, {{{0., 245.6}, 3.9064}, {{1., 204.8}, 
     3.33766}, {{3., 202.6}, 2.65707}, {{6., 214.2}, 
     3.18434}, {{9., 237.}, 2.46982}, {{12., 272.2}, 
     3.81314}, {{15., 296.}, 2.40832}, {{18., 313.6}, 
     4.31972}, {{21., 323.4}, 3.88072}}}, 
  ErrorBar[{{0., 245.6, x}, {1., 204.8, x}, {3., 202.6, x}, {6., 
     214.2, x}, {9., 237., x}, {12., 272.2, x}, {15., 296., x}, {18., 
     313.6, x}}]}, {{{{0., 245.6}, {1., 204.8}, {3., 202.6}, {6., 
     214.2}, {9., 237.}, {12., 272.2}, {15., 296.}, {18., 
     313.6}, {21., 323.4}}, {{{0., 245.6}, 3.9064}, {{1., 204.8}, 
     3.33766}, {{3., 202.6}, 2.65707}, {{6., 214.2}, 
     3.18434}, {{9., 237.}, 2.46982}, {{12., 272.2}, 
     3.81314}, {{15., 296.}, 2.40832}, {{18., 313.6}, 
     4.31972}, {{21., 323.4}, 3.88072}}}, 
  ErrorBar[{{0., 245.6, x}, {1., 204.8, x}, {3., 202.6, x}, {6., 
     214.2, x}, {9., 237., x}, {12., 272.2, x}, {15., 296., x}, {18., 
     313.6, x}}]}}
POSTED BY: Ivan Gumenyuk

It appears that you may have already defined c previously. In that case, this will work.

plotDataTransplantErr = {{{0., 245.6}, 3.9064}, {{1., 204.8}, 
   3.33766}, {{3., 202.6}, 2.65707}, {{6., 214.2}, 
   3.18434}, {{9., 237.}, 2.46982}, {{12., 272.2}, 
   3.81314}, {{15., 296.}, 2.40832}, {{18., 313.6}, 
   4.31972}, {{21., 323.4}, 3.88072}}


plotDataTransplantErr = 
 plotDataTransplantErr /. {{a_, b_}, c_} :> {{a, b}, ErrorBar[c]}

The difference here is that :> replaces the -> (it has the same purpose here as how := replaces =). Sleep well, WCC

POSTED BY: W. Craig Carter
Posted 12 years ago

Wonderful. You've helped me very much. Thanks.

POSTED BY: Ivan Gumenyuk
POSTED BY: W. Craig Carter
Posted 12 years ago

Can you express this idea more completely? I'm using Wolfram for several weeks and it's too hard for me to understand this sometimes) I'm a doctor))

POSTED BY: Ivan Gumenyuk
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard