{"id":727,"date":"2015-01-29T22:55:09","date_gmt":"2015-01-30T03:55:09","guid":{"rendered":"http:\/\/blog.originlab.com\/?p=727"},"modified":"2018-11-20T17:19:40","modified_gmt":"2018-11-20T22:19:40","slug":"show-columns-mean-and-size-in-column-label-rows","status":"publish","type":"post","link":"https:\/\/blog.originlab.com\/ja\/show-columns-mean-and-size-in-column-label-rows","title":{"rendered":"Show Column&#8217;s Mean and Size in Column Label Rows"},"content":{"rendered":"<p><span style=\"color: #0000ff;\">In Origin <strong>2018<\/strong> and <strong>2018b<\/strong>, we support cell formula in User-Defined Parameter rows and Data area of worksheet. You can easily type <strong>=Mean(C)<\/strong> to calculate mean of column C or <strong>=Mean(This)<\/strong> to calculate mean of current Column.<\/span><\/p>\n<p><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/01\/Mean.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-8704\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/01\/Mean.gif\" alt=\"\" width=\"617\" height=\"389\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>In Versions before Origin 2018, you can calculate each column&#8217;s mean and size in worksheet and put them in column label rows by\u00a0a few lines of LabTalk Script.<br \/>\n<!--more--><\/p>\n<pre title=\"LT code to put Mean and Size on top of columns\" class=\"lang:c++ decode:true\">wks.userparam1$ = Mean; \/\/define a user-defined parameter row\r\nwks.userparam1 = 1; \/\/show this row named \"Mean\"\r\nwks.userparam2$ = Size;\/\/do the same for a \"Size\" row\r\nwks.userparam2 = 1;\r\n\r\nloop (j,1,wks.ncols)\r\n{\r\n\t\/\/calculate Mean and show 3 significant digits\r\n\twcol(j)[Mean]$ = $(mean(wcol(j)),*3); \r\n\t\/\/show 0 decimal places for Size\r\n\twcol(j)[Size]$ = $(count(wcol(j),1),.0);\r\n}<\/pre>\n<p>As you can see from the code above, you can use the user-defined parameter row&#8217;s name as cell row index to access it directly.<\/p>\n<p>If you want to show it immediately after import and dynamically update with change of data, and\u00a0save the script with the\u00a0worksheet for future uses, here are the steps:<\/p>\n<ol>\n<li>Choose Worksheet: Worksheet Script&#8230; menu.<\/li>\n<li>Copy the Script above into the big box in the dialog.<\/li>\n<li>Check <strong>After Script<\/strong> and <strong>Upon Changes in Ranges(s) (space separated)<\/strong> checkboxes.<\/li>\n<li>Enter <strong>1:end<\/strong>\u00a0as the range so changes in any column will trigger the script.<br \/>\n<a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/01\/doc2337_wks_script_db.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-734 size-full\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/01\/doc2337_wks_script_db.png\" alt=\"doc2337_wks_script_db\" width=\"498\" height=\"340\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/01\/doc2337_wks_script_db.png 498w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/01\/doc2337_wks_script_db-300x205.png 300w\" sizes=\"auto, (max-width: 498px) 100vw, 498px\" \/><\/a><\/li>\n<li>Click <strong>Do It<\/strong> or <strong>Update<\/strong> button.<\/li>\n<li>Choose <strong>File: Save Template As&#8230;<\/strong> and give a meaningful template name, e.g. <strong>Mean_Size_in_Label<\/strong>.<\/li>\n<li>Choose <strong>File: Recent Book:<\/strong> or use\u00a0<strong>Open Template button<\/strong> to load it and enter some data to see the update in <strong>Mean<\/strong> and <strong>Size<\/strong> rows.<br \/>\n<a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/01\/doc2337_mean_size_label.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-746\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/01\/doc2337_mean_size_label-297x300.png\" alt=\"doc2337_mean_size_label\" width=\"297\" height=\"300\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/01\/doc2337_mean_size_label-297x300.png 297w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/01\/doc2337_mean_size_label-90x90.png 90w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/01\/doc2337_mean_size_label-75x75.png 75w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/01\/doc2337_mean_size_label.png 338w\" sizes=\"auto, (max-width: 297px) 100vw, 297px\" \/><\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>In Origin 2018 and 2018b, we support cell formula in &hellip; <\/p>","protected":false},"author":4,"featured_media":8708,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[3],"tags":[],"class_list":["post-727","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-data-handling"],"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p7DvU2-bJ","jetpack_likes_enabled":true,"jetpack_featured_media_url":"https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/01\/Mean.png","post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/posts\/727","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/comments?post=727"}],"version-history":[{"count":36,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/posts\/727\/revisions"}],"predecessor-version":[{"id":919,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/posts\/727\/revisions\/919"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/media\/8708"}],"wp:attachment":[{"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/media?parent=727"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/categories?post=727"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/tags?post=727"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}