Formatting a table to look nice
$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.
table formatting
$endgroup$
add a comment |
$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.
table formatting
$endgroup$
add a comment |
$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.
table formatting
$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
table formatting
edited 4 hours ago
Wombles
asked 4 hours ago
WomblesWombles
384
384
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
$begingroup$
{binlims, bincounts} = HistogramList[data, {firstbin, Max[data] + binsize, binsize}];
bins = Row[{#, #2 - 1}, "-"] & @@@ Partition[binlims, 2, 1];
TableForm[Transpose[{bins, bincounts}]]
$endgroup$
$begingroup$
Thank you very much!
$endgroup$
– Wombles
4 hours ago
$begingroup$
@Wombles, you are welcome.
$endgroup$
– kglr
4 hours ago
add a comment |
$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:
$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
4 hours ago
$begingroup$
You might wantToString
andStringJoin
$endgroup$
– MarcoB
3 hours ago
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
$begingroup$
{binlims, bincounts} = HistogramList[data, {firstbin, Max[data] + binsize, binsize}];
bins = Row[{#, #2 - 1}, "-"] & @@@ Partition[binlims, 2, 1];
TableForm[Transpose[{bins, bincounts}]]
$endgroup$
$begingroup$
Thank you very much!
$endgroup$
– Wombles
4 hours ago
$begingroup$
@Wombles, you are welcome.
$endgroup$
– kglr
4 hours ago
add a comment |
$begingroup$
{binlims, bincounts} = HistogramList[data, {firstbin, Max[data] + binsize, binsize}];
bins = Row[{#, #2 - 1}, "-"] & @@@ Partition[binlims, 2, 1];
TableForm[Transpose[{bins, bincounts}]]
$endgroup$
$begingroup$
Thank you very much!
$endgroup$
– Wombles
4 hours ago
$begingroup$
@Wombles, you are welcome.
$endgroup$
– kglr
4 hours ago
add a comment |
$begingroup$
{binlims, bincounts} = HistogramList[data, {firstbin, Max[data] + binsize, binsize}];
bins = Row[{#, #2 - 1}, "-"] & @@@ Partition[binlims, 2, 1];
TableForm[Transpose[{bins, bincounts}]]
$endgroup$
{binlims, bincounts} = HistogramList[data, {firstbin, Max[data] + binsize, binsize}];
bins = Row[{#, #2 - 1}, "-"] & @@@ Partition[binlims, 2, 1];
TableForm[Transpose[{bins, bincounts}]]
answered 4 hours ago
kglrkglr
187k10203421
187k10203421
$begingroup$
Thank you very much!
$endgroup$
– Wombles
4 hours ago
$begingroup$
@Wombles, you are welcome.
$endgroup$
– kglr
4 hours ago
add a comment |
$begingroup$
Thank you very much!
$endgroup$
– Wombles
4 hours ago
$begingroup$
@Wombles, you are welcome.
$endgroup$
– kglr
4 hours ago
$begingroup$
Thank you very much!
$endgroup$
– Wombles
4 hours ago
$begingroup$
Thank you very much!
$endgroup$
– Wombles
4 hours ago
$begingroup$
@Wombles, you are welcome.
$endgroup$
– kglr
4 hours ago
$begingroup$
@Wombles, you are welcome.
$endgroup$
– kglr
4 hours ago
add a comment |
$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:
$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
4 hours ago
$begingroup$
You might wantToString
andStringJoin
$endgroup$
– MarcoB
3 hours ago
add a comment |
$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:
$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
4 hours ago
$begingroup$
You might wantToString
andStringJoin
$endgroup$
– MarcoB
3 hours ago
add a comment |
$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:
$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:
edited 4 hours ago
answered 4 hours ago
mjwmjw
4328
4328
$begingroup$
I wish I knew more about string manipulation to get the first three columns to combine to one column of text!
$endgroup$
– mjw
4 hours ago
$begingroup$
You might wantToString
andStringJoin
$endgroup$
– MarcoB
3 hours ago
add a comment |
$begingroup$
I wish I knew more about string manipulation to get the first three columns to combine to one column of text!
$endgroup$
– mjw
4 hours ago
$begingroup$
You might wantToString
andStringJoin
$endgroup$
– MarcoB
3 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
4 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
4 hours ago
$begingroup$
You might want
ToString
and StringJoin
$endgroup$
– MarcoB
3 hours ago
$begingroup$
You might want
ToString
and StringJoin
$endgroup$
– MarcoB
3 hours ago
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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