Formatting a table to look niceHow to create a Table of Tables with indexed variablesTable shifting...

What does "rhumatis" mean?

Effect of "wrong" driver with slightly long RS-485 stubs

PTIJ: Aliyot for the deceased

Paper published similar to PhD thesis

Is there a way to find out the age of climbing ropes?

Ultrafilters as a double dual

“I had a flat in the centre of town, but I didn’t like living there, so …”

PTIJ: Mordechai mourning

Why are special aircraft used for the carriers in the United States Navy?

Learning to quickly identify valid fingering for piano?

Can a space-faring robot still function over a billion years?

Why would the IRS ask for birth certificates or even audit a small tax return?

Is there a math equivalent to the conditional ternary operator?

Where is the fallacy here?

Create chunks from an array

Forcing Mathematica's Integrate to give more general answers

Convert an array of objects to array of the objects' values

Giving a talk in my old university, how prominently should I tell students my salary?

The need of reserving one's ability in job interviews

How do we objectively assess if a dialogue sounds unnatural or cringy?

I can't die. Who am I?

If nine coins are tossed, what is the probability that the number of heads is even?

Called into a meeting and told we are being made redundant (laid off) and "not to share outside". Can I tell my partner?

Did Amazon pay $0 in taxes last year?



Formatting a table to look nice


How to create a Table of Tables with indexed variablesTable shifting bug?Transposing a tableHow to create a table of tables with different table lengths?Looping with “Table” over two variablesHow to plot data from table dynamically, without knowing how many columns are there?Creating iterations on a circle using the Table functionProgress bar / counter for multi-row table with 2 variablesPlotting in Table[…]Attempting to fill a table with the number of elements in each bin and make a table with the elements in the bins?













7












$begingroup$


my current code is:



binsize = 21;
data = {535, 481, 554, 567, 565, 513, 526, 506, 565, 475, 552, 533,
474, 556, 520, 508, 597, 479, 537, 499, 546, 473, 579, 526, 594,
477, 518, 538, 497, 565};
firstbin = 472;
a = BinCounts[data, {firstbin, Max[data] + binsize, binsize}];
b = Range[firstbin, Max[data] + binsize, binsize];
Transpose[{Take[b, Length[a]], a}] // TableForm


Which does give me a nice table, however I would like the bins to be labeled something like "472-492 6" instead of just "472 6"



any advice would be great, thank you.










share|improve this question











$endgroup$

















    7












    $begingroup$


    my current code is:



    binsize = 21;
    data = {535, 481, 554, 567, 565, 513, 526, 506, 565, 475, 552, 533,
    474, 556, 520, 508, 597, 479, 537, 499, 546, 473, 579, 526, 594,
    477, 518, 538, 497, 565};
    firstbin = 472;
    a = BinCounts[data, {firstbin, Max[data] + binsize, binsize}];
    b = Range[firstbin, Max[data] + binsize, binsize];
    Transpose[{Take[b, Length[a]], a}] // TableForm


    Which does give me a nice table, however I would like the bins to be labeled something like "472-492 6" instead of just "472 6"



    any advice would be great, thank you.










    share|improve this question











    $endgroup$















      7












      7








      7


      1



      $begingroup$


      my current code is:



      binsize = 21;
      data = {535, 481, 554, 567, 565, 513, 526, 506, 565, 475, 552, 533,
      474, 556, 520, 508, 597, 479, 537, 499, 546, 473, 579, 526, 594,
      477, 518, 538, 497, 565};
      firstbin = 472;
      a = BinCounts[data, {firstbin, Max[data] + binsize, binsize}];
      b = Range[firstbin, Max[data] + binsize, binsize];
      Transpose[{Take[b, Length[a]], a}] // TableForm


      Which does give me a nice table, however I would like the bins to be labeled something like "472-492 6" instead of just "472 6"



      any advice would be great, thank you.










      share|improve this question











      $endgroup$




      my current code is:



      binsize = 21;
      data = {535, 481, 554, 567, 565, 513, 526, 506, 565, 475, 552, 533,
      474, 556, 520, 508, 597, 479, 537, 499, 546, 473, 579, 526, 594,
      477, 518, 538, 497, 565};
      firstbin = 472;
      a = BinCounts[data, {firstbin, Max[data] + binsize, binsize}];
      b = Range[firstbin, Max[data] + binsize, binsize];
      Transpose[{Take[b, Length[a]], a}] // TableForm


      Which does give me a nice table, however I would like the bins to be labeled something like "472-492 6" instead of just "472 6"



      any advice would be great, thank you.







      table formatting






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 22 hours ago







      Wombles

















      asked 22 hours ago









      WomblesWombles

      534




      534






















          2 Answers
          2






          active

          oldest

          votes


















          8












          $begingroup$

          You can use HistogramList to get bin limits and bin counts in one step and process the output to get the desired structure:



          {binlims, bincounts} = HistogramList[data, {firstbin, Max[data] + binsize, binsize}];
          bins = Row[{#, #2 - 1}, "-"] & @@@ Partition[binlims, 2, 1];
          TableForm[Transpose[{bins, bincounts}]]


          enter image description here



          Alternatively, you can use MovingMap, Developer`PartitionMap or
          the (undocumented) 6-argument form of Partition to get the first column:



          bins2 = MovingMap[Row[{First@#, Last@# - 1}, "-"] &, binlims, 1]
          bins3 = Developer`PartitionMap[Row[{First@#, Last@# - 1}, "-"] &, binlims, 2, 1];
          bins4 = Partition[binlims, 2, 1, {1, -1}, {}, Row[{#, #2 - 1}, "-"] &];
          bins == bins2 == bins3 == bins4



          True




          Finally, you can also use a combination of StringRiffle and ToString in place of Rowas follows:



          bins5 = Partition[binlims, 2, 1, {1, -1}, {}, StringRiffle[ToString/@{#, #2 - 1}, " - "]&]
          TableForm[Transpose[{bins5, bincounts}]]


          enter image description here






          share|improve this answer











          $endgroup$













          • $begingroup$
            Thank you very much!
            $endgroup$
            – Wombles
            21 hours ago










          • $begingroup$
            @Wombles, you are welcome.
            $endgroup$
            – kglr
            21 hours ago



















          4












          $begingroup$

          Here is one way:



          bb = b - 1;
          c = Complement[bb, {Min[bb]}];
          Transpose[{Take[b, Length[a]], ConstantArray["---", Length[a]], c, a}] // TableForm


          Here is the output:



          enter image description here



          With MarcoB's hint, and some experimenting:



          c = Complement[b - 1, {Min[b - 1]}];
          y = Map[ToString, Take[b, Length[a]]];
          z = Map[ToString, c];
          Transpose@{Map[StringJoin, Transpose[{y, ConstantArray["---", Length[a]], z}]], a} // TableForm


          enter image description here






          share|improve this answer











          $endgroup$













          • $begingroup$
            I wish I knew more about string manipulation to get the first three columns to combine to one column of text!
            $endgroup$
            – mjw
            22 hours ago






          • 1




            $begingroup$
            You might want ToString and StringJoin
            $endgroup$
            – MarcoB
            21 hours ago










          • $begingroup$
            @MarcoB, Yes, Thank you! That's what I was looking for! I actually found ToString and figured there was a way of joining the columns ... Probably there is a more efficient way then what I've put together. At least it is a start.
            $endgroup$
            – mjw
            17 hours ago












          • $begingroup$
            Row as suggested in kglr's answer, can also work as a substitute for StringJoin.
            $endgroup$
            – mjw
            16 hours ago













          Your Answer





          StackExchange.ifUsing("editor", function () {
          return StackExchange.using("mathjaxEditing", function () {
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
          });
          });
          }, "mathjax-editing");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "387"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f192750%2fformatting-a-table-to-look-nice%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          8












          $begingroup$

          You can use HistogramList to get bin limits and bin counts in one step and process the output to get the desired structure:



          {binlims, bincounts} = HistogramList[data, {firstbin, Max[data] + binsize, binsize}];
          bins = Row[{#, #2 - 1}, "-"] & @@@ Partition[binlims, 2, 1];
          TableForm[Transpose[{bins, bincounts}]]


          enter image description here



          Alternatively, you can use MovingMap, Developer`PartitionMap or
          the (undocumented) 6-argument form of Partition to get the first column:



          bins2 = MovingMap[Row[{First@#, Last@# - 1}, "-"] &, binlims, 1]
          bins3 = Developer`PartitionMap[Row[{First@#, Last@# - 1}, "-"] &, binlims, 2, 1];
          bins4 = Partition[binlims, 2, 1, {1, -1}, {}, Row[{#, #2 - 1}, "-"] &];
          bins == bins2 == bins3 == bins4



          True




          Finally, you can also use a combination of StringRiffle and ToString in place of Rowas follows:



          bins5 = Partition[binlims, 2, 1, {1, -1}, {}, StringRiffle[ToString/@{#, #2 - 1}, " - "]&]
          TableForm[Transpose[{bins5, bincounts}]]


          enter image description here






          share|improve this answer











          $endgroup$













          • $begingroup$
            Thank you very much!
            $endgroup$
            – Wombles
            21 hours ago










          • $begingroup$
            @Wombles, you are welcome.
            $endgroup$
            – kglr
            21 hours ago
















          8












          $begingroup$

          You can use HistogramList to get bin limits and bin counts in one step and process the output to get the desired structure:



          {binlims, bincounts} = HistogramList[data, {firstbin, Max[data] + binsize, binsize}];
          bins = Row[{#, #2 - 1}, "-"] & @@@ Partition[binlims, 2, 1];
          TableForm[Transpose[{bins, bincounts}]]


          enter image description here



          Alternatively, you can use MovingMap, Developer`PartitionMap or
          the (undocumented) 6-argument form of Partition to get the first column:



          bins2 = MovingMap[Row[{First@#, Last@# - 1}, "-"] &, binlims, 1]
          bins3 = Developer`PartitionMap[Row[{First@#, Last@# - 1}, "-"] &, binlims, 2, 1];
          bins4 = Partition[binlims, 2, 1, {1, -1}, {}, Row[{#, #2 - 1}, "-"] &];
          bins == bins2 == bins3 == bins4



          True




          Finally, you can also use a combination of StringRiffle and ToString in place of Rowas follows:



          bins5 = Partition[binlims, 2, 1, {1, -1}, {}, StringRiffle[ToString/@{#, #2 - 1}, " - "]&]
          TableForm[Transpose[{bins5, bincounts}]]


          enter image description here






          share|improve this answer











          $endgroup$













          • $begingroup$
            Thank you very much!
            $endgroup$
            – Wombles
            21 hours ago










          • $begingroup$
            @Wombles, you are welcome.
            $endgroup$
            – kglr
            21 hours ago














          8












          8








          8





          $begingroup$

          You can use HistogramList to get bin limits and bin counts in one step and process the output to get the desired structure:



          {binlims, bincounts} = HistogramList[data, {firstbin, Max[data] + binsize, binsize}];
          bins = Row[{#, #2 - 1}, "-"] & @@@ Partition[binlims, 2, 1];
          TableForm[Transpose[{bins, bincounts}]]


          enter image description here



          Alternatively, you can use MovingMap, Developer`PartitionMap or
          the (undocumented) 6-argument form of Partition to get the first column:



          bins2 = MovingMap[Row[{First@#, Last@# - 1}, "-"] &, binlims, 1]
          bins3 = Developer`PartitionMap[Row[{First@#, Last@# - 1}, "-"] &, binlims, 2, 1];
          bins4 = Partition[binlims, 2, 1, {1, -1}, {}, Row[{#, #2 - 1}, "-"] &];
          bins == bins2 == bins3 == bins4



          True




          Finally, you can also use a combination of StringRiffle and ToString in place of Rowas follows:



          bins5 = Partition[binlims, 2, 1, {1, -1}, {}, StringRiffle[ToString/@{#, #2 - 1}, " - "]&]
          TableForm[Transpose[{bins5, bincounts}]]


          enter image description here






          share|improve this answer











          $endgroup$



          You can use HistogramList to get bin limits and bin counts in one step and process the output to get the desired structure:



          {binlims, bincounts} = HistogramList[data, {firstbin, Max[data] + binsize, binsize}];
          bins = Row[{#, #2 - 1}, "-"] & @@@ Partition[binlims, 2, 1];
          TableForm[Transpose[{bins, bincounts}]]


          enter image description here



          Alternatively, you can use MovingMap, Developer`PartitionMap or
          the (undocumented) 6-argument form of Partition to get the first column:



          bins2 = MovingMap[Row[{First@#, Last@# - 1}, "-"] &, binlims, 1]
          bins3 = Developer`PartitionMap[Row[{First@#, Last@# - 1}, "-"] &, binlims, 2, 1];
          bins4 = Partition[binlims, 2, 1, {1, -1}, {}, Row[{#, #2 - 1}, "-"] &];
          bins == bins2 == bins3 == bins4



          True




          Finally, you can also use a combination of StringRiffle and ToString in place of Rowas follows:



          bins5 = Partition[binlims, 2, 1, {1, -1}, {}, StringRiffle[ToString/@{#, #2 - 1}, " - "]&]
          TableForm[Transpose[{bins5, bincounts}]]


          enter image description here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 16 hours ago

























          answered 22 hours ago









          kglrkglr

          187k10203421




          187k10203421












          • $begingroup$
            Thank you very much!
            $endgroup$
            – Wombles
            21 hours ago










          • $begingroup$
            @Wombles, you are welcome.
            $endgroup$
            – kglr
            21 hours ago


















          • $begingroup$
            Thank you very much!
            $endgroup$
            – Wombles
            21 hours ago










          • $begingroup$
            @Wombles, you are welcome.
            $endgroup$
            – kglr
            21 hours ago
















          $begingroup$
          Thank you very much!
          $endgroup$
          – Wombles
          21 hours ago




          $begingroup$
          Thank you very much!
          $endgroup$
          – Wombles
          21 hours ago












          $begingroup$
          @Wombles, you are welcome.
          $endgroup$
          – kglr
          21 hours ago




          $begingroup$
          @Wombles, you are welcome.
          $endgroup$
          – kglr
          21 hours ago











          4












          $begingroup$

          Here is one way:



          bb = b - 1;
          c = Complement[bb, {Min[bb]}];
          Transpose[{Take[b, Length[a]], ConstantArray["---", Length[a]], c, a}] // TableForm


          Here is the output:



          enter image description here



          With MarcoB's hint, and some experimenting:



          c = Complement[b - 1, {Min[b - 1]}];
          y = Map[ToString, Take[b, Length[a]]];
          z = Map[ToString, c];
          Transpose@{Map[StringJoin, Transpose[{y, ConstantArray["---", Length[a]], z}]], a} // TableForm


          enter image description here






          share|improve this answer











          $endgroup$













          • $begingroup$
            I wish I knew more about string manipulation to get the first three columns to combine to one column of text!
            $endgroup$
            – mjw
            22 hours ago






          • 1




            $begingroup$
            You might want ToString and StringJoin
            $endgroup$
            – MarcoB
            21 hours ago










          • $begingroup$
            @MarcoB, Yes, Thank you! That's what I was looking for! I actually found ToString and figured there was a way of joining the columns ... Probably there is a more efficient way then what I've put together. At least it is a start.
            $endgroup$
            – mjw
            17 hours ago












          • $begingroup$
            Row as suggested in kglr's answer, can also work as a substitute for StringJoin.
            $endgroup$
            – mjw
            16 hours ago


















          4












          $begingroup$

          Here is one way:



          bb = b - 1;
          c = Complement[bb, {Min[bb]}];
          Transpose[{Take[b, Length[a]], ConstantArray["---", Length[a]], c, a}] // TableForm


          Here is the output:



          enter image description here



          With MarcoB's hint, and some experimenting:



          c = Complement[b - 1, {Min[b - 1]}];
          y = Map[ToString, Take[b, Length[a]]];
          z = Map[ToString, c];
          Transpose@{Map[StringJoin, Transpose[{y, ConstantArray["---", Length[a]], z}]], a} // TableForm


          enter image description here






          share|improve this answer











          $endgroup$













          • $begingroup$
            I wish I knew more about string manipulation to get the first three columns to combine to one column of text!
            $endgroup$
            – mjw
            22 hours ago






          • 1




            $begingroup$
            You might want ToString and StringJoin
            $endgroup$
            – MarcoB
            21 hours ago










          • $begingroup$
            @MarcoB, Yes, Thank you! That's what I was looking for! I actually found ToString and figured there was a way of joining the columns ... Probably there is a more efficient way then what I've put together. At least it is a start.
            $endgroup$
            – mjw
            17 hours ago












          • $begingroup$
            Row as suggested in kglr's answer, can also work as a substitute for StringJoin.
            $endgroup$
            – mjw
            16 hours ago
















          4












          4








          4





          $begingroup$

          Here is one way:



          bb = b - 1;
          c = Complement[bb, {Min[bb]}];
          Transpose[{Take[b, Length[a]], ConstantArray["---", Length[a]], c, a}] // TableForm


          Here is the output:



          enter image description here



          With MarcoB's hint, and some experimenting:



          c = Complement[b - 1, {Min[b - 1]}];
          y = Map[ToString, Take[b, Length[a]]];
          z = Map[ToString, c];
          Transpose@{Map[StringJoin, Transpose[{y, ConstantArray["---", Length[a]], z}]], a} // TableForm


          enter image description here






          share|improve this answer











          $endgroup$



          Here is one way:



          bb = b - 1;
          c = Complement[bb, {Min[bb]}];
          Transpose[{Take[b, Length[a]], ConstantArray["---", Length[a]], c, a}] // TableForm


          Here is the output:



          enter image description here



          With MarcoB's hint, and some experimenting:



          c = Complement[b - 1, {Min[b - 1]}];
          y = Map[ToString, Take[b, Length[a]]];
          z = Map[ToString, c];
          Transpose@{Map[StringJoin, Transpose[{y, ConstantArray["---", Length[a]], z}]], a} // TableForm


          enter image description here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 16 hours ago

























          answered 22 hours ago









          mjwmjw

          4828




          4828












          • $begingroup$
            I wish I knew more about string manipulation to get the first three columns to combine to one column of text!
            $endgroup$
            – mjw
            22 hours ago






          • 1




            $begingroup$
            You might want ToString and StringJoin
            $endgroup$
            – MarcoB
            21 hours ago










          • $begingroup$
            @MarcoB, Yes, Thank you! That's what I was looking for! I actually found ToString and figured there was a way of joining the columns ... Probably there is a more efficient way then what I've put together. At least it is a start.
            $endgroup$
            – mjw
            17 hours ago












          • $begingroup$
            Row as suggested in kglr's answer, can also work as a substitute for StringJoin.
            $endgroup$
            – mjw
            16 hours ago




















          • $begingroup$
            I wish I knew more about string manipulation to get the first three columns to combine to one column of text!
            $endgroup$
            – mjw
            22 hours ago






          • 1




            $begingroup$
            You might want ToString and StringJoin
            $endgroup$
            – MarcoB
            21 hours ago










          • $begingroup$
            @MarcoB, Yes, Thank you! That's what I was looking for! I actually found ToString and figured there was a way of joining the columns ... Probably there is a more efficient way then what I've put together. At least it is a start.
            $endgroup$
            – mjw
            17 hours ago












          • $begingroup$
            Row as suggested in kglr's answer, can also work as a substitute for StringJoin.
            $endgroup$
            – mjw
            16 hours ago


















          $begingroup$
          I wish I knew more about string manipulation to get the first three columns to combine to one column of text!
          $endgroup$
          – mjw
          22 hours ago




          $begingroup$
          I wish I knew more about string manipulation to get the first three columns to combine to one column of text!
          $endgroup$
          – mjw
          22 hours ago




          1




          1




          $begingroup$
          You might want ToString and StringJoin
          $endgroup$
          – MarcoB
          21 hours ago




          $begingroup$
          You might want ToString and StringJoin
          $endgroup$
          – MarcoB
          21 hours ago












          $begingroup$
          @MarcoB, Yes, Thank you! That's what I was looking for! I actually found ToString and figured there was a way of joining the columns ... Probably there is a more efficient way then what I've put together. At least it is a start.
          $endgroup$
          – mjw
          17 hours ago






          $begingroup$
          @MarcoB, Yes, Thank you! That's what I was looking for! I actually found ToString and figured there was a way of joining the columns ... Probably there is a more efficient way then what I've put together. At least it is a start.
          $endgroup$
          – mjw
          17 hours ago














          $begingroup$
          Row as suggested in kglr's answer, can also work as a substitute for StringJoin.
          $endgroup$
          – mjw
          16 hours ago






          $begingroup$
          Row as suggested in kglr's answer, can also work as a substitute for StringJoin.
          $endgroup$
          – mjw
          16 hours ago




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Mathematica Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f192750%2fformatting-a-table-to-look-nice%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Nidaros erkebispedøme

          Birsay

          Where did Arya get these scars? Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara Favourite questions and answers from the 1st quarter of 2019Why did Arya refuse to end it?Has the pronunciation of Arya Stark's name changed?Has Arya forgiven people?Why did Arya Stark lose her vision?Why can Arya still use the faces?Has the Narrow Sea become narrower?Does Arya Stark know how to make poisons outside of the House of Black and White?Why did Nymeria leave Arya?Why did Arya not kill the Lannister soldiers she encountered in the Riverlands?What is the current canonical age of Sansa, Bran and Arya Stark?