{"id":1418,"date":"2015-03-26T11:04:43","date_gmt":"2015-03-26T15:04:43","guid":{"rendered":"http:\/\/blog.originlab.com\/?p=1418"},"modified":"2022-08-23T13:26:03","modified_gmt":"2022-08-23T17:26:03","slug":"delete-every-nth-row-or-column-from-worksheet-2","status":"publish","type":"post","link":"https:\/\/blog.originlab.com\/ja\/delete-every-nth-row-or-column-from-worksheet-2","title":{"rendered":"Reduce Rows or Columns from Worksheet"},"content":{"rendered":"<p>When dealing with large dataset, you may want to reduce data before performing analysis or graphing. There are multiple\u00a0ways to <a href=\"http:\/\/originlab.com\/index.aspx?go=Products\/Origin\/DataAnalysis\/DataManipulation&amp;PID=1966\">reduce data in Origin<\/a>. This post will demonstrate how to reduce\u00a0rows and columns\u00a0from GUI and the corresponding LabTalk scripts.<\/p>\n<p>Download <a title=\"Reduce_Rows_Columns.zip\" href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/Reduce_Rows_Columns.zip\">Reduce_Rows_Columns.zip<\/a>\u00a0to follow the procedures below. Results are kept in <strong>Results<\/strong> folder of the opj file.<\/p>\n<h2>Reduce Rows<\/h2>\n<p>Go to <strong>Folder1 <\/strong>and\u00a0workbook <strong>Nitrite<\/strong>. The data\u00a0is\u00a0collected\u00a0in every\u00a00.01 sec.<\/p>\n<p><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_12.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1618 aligncenter\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_12.png\" alt=\"DOC-2350_1\" width=\"318\" height=\"428\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_12.png 318w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_12-223x300.png 223w\" sizes=\"auto, (max-width: 318px) 100vw, 318px\" \/><\/a><\/p>\n<p>First let&#8217;s reduce data to around\u00a0every second. Highlight <strong>Col(A)<\/strong> \u3001 <strong>Col(B)<\/strong>, and choose <strong>Worksheet: Reduce Rows&#8230;\u00a0<\/strong>menu. Set the settings as following.<\/p>\n<p><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_22.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1619 aligncenter\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_22.png\" alt=\"DOC-2350_2\" width=\"430\" height=\"361\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_22.png 430w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_22-300x252.png 300w\" sizes=\"auto, (max-width: 430px) 100vw, 430px\" \/><\/a><\/p>\n<p>After clicking <strong>OK<\/strong>, the reduced data are added to new columns.<\/p>\n<p><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_31.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1625 aligncenter\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_31.png\" alt=\"DOC-2350_3\" width=\"443\" height=\"432\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_31.png 443w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_31-300x293.png 300w\" sizes=\"auto, (max-width: 443px) 100vw, 443px\" \/><\/a><\/p>\n<p>Right click on\u00a0<strong>Sparklines<\/strong> row in workbook and choose<strong> Add or Update Sparklines<\/strong>. Click <strong>OK<\/strong>\u00a0to add sparklines of each column. Comparing column B and D, you can see many peaks are lost\u00a0in the reduced data.<\/p>\n<p><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_41.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1630 aligncenter\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_41.png\" alt=\"DOC-2350_4\" width=\"443\" height=\"432\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_41.png 443w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_41-300x293.png 300w\" sizes=\"auto, (max-width: 443px) 100vw, 443px\" \/><\/a><\/p>\n<p>To preserve peak shapes, we need to keep more\u00a0data. Just left click the green lock <a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/02\/DOC-2350_5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1437\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/02\/DOC-2350_5.png\" alt=\"DOC-2350_5\" width=\"20\" height=\"22\" \/><\/a>on column <strong>C<\/strong>\u00a0and choose <b>Change Parameters<\/b>\u00a0context menu to open the\u00a0dialog again. Change\u00a0<b>Delete Rows<\/b> to 9\u00a0and click <b>OK<\/b>.\u00a0Now the data is reduced to every 0.1 second. The sparklines of column C and D are updated and show a better data reduction.<\/p>\n<p><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1629 aligncenter\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_5.png\" alt=\"DOC-2350_5\" width=\"443\" height=\"432\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_5.png 443w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_5-300x293.png 300w\" sizes=\"auto, (max-width: 443px) 100vw, 443px\" \/><\/a><\/p>\n<p><strong>Reduce Rows<\/strong>\u00a0in Origin is based on X-Function <strong>wreducerows<\/strong>. To see the script behind it, left click the green lock<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"wp-image-1437 size-full alignleft\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/02\/DOC-2350_5.png\" alt=\"DOC-2350_5\" width=\"20\" height=\"22\" \/>on column <strong>C<\/strong>\u00a0and choose <strong>Generate Script<\/strong> context menu.\u00a0The script is dumped into <strong>Script Window<\/strong>. You can use the script in the future to do such data reduction.<\/p>\n<p><strong><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_121.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1663 alignleft\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_121.png\" alt=\"DOC-2350_12\" width=\"274\" height=\"232\" \/><\/a>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0<\/strong><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_8.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1637 alignleft\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_8.png\" alt=\"DOC-2350_8\" width=\"370\" height=\"146\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_8.png 370w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_8-300x118.png 300w\" sizes=\"auto, (max-width: 370px) 100vw, 370px\" \/><\/a><\/p>\n<p>There are other\u00a0<strong>Reduce Methods, <\/strong>e.g.\u00a0<strong>Reduce N rows with merged values:\u00a0<\/strong>mean, min, max, etc.<\/p>\n<p><strong>\u00a0<a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1632\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_6.png\" alt=\"DOC-2350_6\" width=\"356\" height=\"76\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_6.png 356w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_6-300x64.png 300w\" sizes=\"auto, (max-width: 356px) 100vw, 356px\" \/><\/a><\/strong><\/p>\n<p>Note: You can also use Worksheet: <a href=\"https:\/\/www.originlab.com\/doc\/origin-help\/wks-query\">Worksheet Query<\/a> to set conditions. Rows that fit the condition can be extracted to a new sheet.\u00a0E.g. set condition<\/p>\n<ul>\n<li><strong>B&gt;dmin AND B&lt;dmax<\/strong> to extract rows with min and max excluded<\/li>\n<li><strong>i&gt;= list(max(col(B)),col(B))<\/strong> to extract rows from maximum of B on<\/li>\n<\/ul>\n<h2 style=\"text-align: left;\">Reduce Columns<\/h2>\n<p>Similarly we have <strong>Reduce Columns<\/strong> dialog to reduce data column wise. Look at <strong>Sensor <\/strong>workbook in<strong> Folder1<\/strong>. There are many 3 XY pairs of data for each sensor. All X columns are the same.<\/p>\n<p><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_9.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1654 aligncenter\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_9.png\" alt=\"DOC-2350_9\" width=\"902\" height=\"330\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_9.png 902w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_9-300x110.png 300w\" sizes=\"auto, (max-width: 902px) 100vw, 902px\" \/><\/a><\/p>\n<p>If you want to remove all duplicated X columns and get the average Y values for each sensor,you need to use the Reduce Columns dialog twice.<\/p>\n<p>First, delete\u00a0every other\u00a0column starting from the 3rd column to remove all duplicated X columns.\u00a0See the images below.<\/p>\n<p><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_10.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1652 aligncenter\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_10.png\" alt=\"DOC-2350_10\" width=\"436\" height=\"314\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_10.png 436w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_10-300x216.png 300w\" sizes=\"auto, (max-width: 436px) 100vw, 436px\" \/><\/a><\/p>\n<p>Then with the new\u00a0worksheet active, open the\u00a0<strong>Reduce Columns<\/strong>\u00a0dialog again to merge every 3 Y columns by averaging. See the images below.<\/p>\n<p><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_11.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1653 aligncenter\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_11.png\" alt=\"DOC-2350_11\" width=\"434\" height=\"317\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_11.png 434w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_11-300x219.png 300w\" sizes=\"auto, (max-width: 434px) 100vw, 434px\" \/><\/a><\/p>\n<p>You can also run following scripts to run reduce columns twice without opening dialog.<\/p>\n<pre class=\"lang:c++ decode:true\" title=\"LT code reduce columns\">wreducecols start:=3 ow:=&lt;new&gt;; \/\/delete every other column first 3rd column on\nwreducecols method:=merge ncols:=3 merge:=ave start:=2 ow:=&lt;new&gt;; \/\/merge every 3 columns by averaging, starting from 2nd column on\n<\/pre>\n<p>Note:<\/p>\n<p>From the dialog,\u00a0you can click the arrow next to <strong>Dialog Theme<\/strong> anytime to generate script based on your current settings .<\/p>\n<p><a href=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_7.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1634\" src=\"http:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_7.png\" alt=\"DOC-2350_7\" width=\"580\" height=\"368\" srcset=\"https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_7.png 580w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_7-300x190.png 300w, https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_7-80x50.png 80w\" sizes=\"auto, (max-width: 580px) 100vw, 580px\" \/><\/a><\/p>\n<h2><\/h2>","protected":false},"excerpt":{"rendered":"<p>When dealing with large dataset, you may want to reduce &hellip; <\/p>","protected":false},"author":16,"featured_media":1629,"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-1418","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-mS","jetpack_likes_enabled":true,"jetpack_featured_media_url":"https:\/\/blog.originlab.com\/wp-content\/uploads\/2015\/03\/DOC-2350_5.png","post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/posts\/1418","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\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/comments?post=1418"}],"version-history":[{"count":53,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/posts\/1418\/revisions"}],"predecessor-version":[{"id":17306,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/posts\/1418\/revisions\/17306"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/media\/1629"}],"wp:attachment":[{"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/media?parent=1418"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/categories?post=1418"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.originlab.com\/ja\/wp-json\/wp\/v2\/tags?post=1418"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}