{"id":396,"date":"2020-07-15T10:39:21","date_gmt":"2020-07-15T10:39:21","guid":{"rendered":"https:\/\/webtrackr.de\/?p=396"},"modified":"2020-07-15T10:39:21","modified_gmt":"2020-07-15T10:39:21","slug":"some-useful-r-code-postprocessing","status":"publish","type":"post","link":"https:\/\/webtrackr.de\/index.php\/2020\/07\/15\/some-useful-r-code-postprocessing\/","title":{"rendered":"Some Useful R Code: Postprocessing"},"content":{"rendered":"<p>In order to preprocess the data, you can use the following code to extract the selected item name:<\/p>\n<p>&nbsp;<\/p>\n<blockquote><p>total$selecteditem &lt;- total$options_left<br \/>\ntotal$selecteditem[total$selected== 1] &lt;- total$options_right[total$selected== 1]<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<p>To generate a 7 point likert scale from the data set, use this code<\/p>\n<p>&nbsp;<\/p>\n<blockquote><p>total$tracker.likert1&lt;- total$tracker1.likert1<br \/>\ntotal$tracker.likert1[total$id==&#8220;tracker2&#8243;]&lt;- total$tracker2.likert1[total$id==&#8220;tracker2&#8243;]<br \/>\ntotal$tracker.likert1[total$id==&#8220;tracker3&#8243;]&lt;- total$tracker3.likert1[total$id==&#8220;tracker3&#8243;]<br \/>\ntotal$tracker.likert1[total$id==&#8220;tracker4&#8243;]&lt;- total$tracker4.likert1[total$id==&#8220;tracker4&#8243;]<br \/>\ntotal$tracker.likert1[total$id==&#8220;tracker5&#8243;]&lt;- total$tracker5.likert1[total$id==&#8220;tracker5&#8243;]<br \/>\ntotal$tracker.likert1[total$id==&#8220;tracker6&#8243;]&lt;- total$tracker6.likert1[total$id==&#8220;tracker6&#8243;]<br \/>\ntotal$tracker.likert1[total$id==&#8220;tracker7&#8243;]&lt;- total$tracker7.likert1[total$id==&#8220;tracker7&#8243;]<\/p><\/blockquote>\n<p>In both instances, we use the data frame <strong>total<\/strong> and 7 different trackers.<\/p>\n<p>To mark the deselected item on the consideration page, use<\/p>\n<blockquote><p>total$dropitem&lt;-0<br \/>\ntotal$dropitem[total$item.consideration==total$selecteditem] &lt;- 1<\/p><\/blockquote>\n<p>To export the code for stata\/spss, it is helpful to use<\/p>\n<blockquote><p>write.csv2(total,&#8220;total.csv&#8220;, row.names = FALSE)<\/p><\/blockquote>\n<p>If you prefer decimal commas, use write.csv instead of write.csv2.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In order to preprocess the data, you can use the following code&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-396","post","type-post","status-publish","format-standard","hentry","category-statistical-analysis"],"_links":{"self":[{"href":"https:\/\/webtrackr.de\/index.php\/wp-json\/wp\/v2\/posts\/396","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webtrackr.de\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webtrackr.de\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webtrackr.de\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/webtrackr.de\/index.php\/wp-json\/wp\/v2\/comments?post=396"}],"version-history":[{"count":1,"href":"https:\/\/webtrackr.de\/index.php\/wp-json\/wp\/v2\/posts\/396\/revisions"}],"predecessor-version":[{"id":397,"href":"https:\/\/webtrackr.de\/index.php\/wp-json\/wp\/v2\/posts\/396\/revisions\/397"}],"wp:attachment":[{"href":"https:\/\/webtrackr.de\/index.php\/wp-json\/wp\/v2\/media?parent=396"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webtrackr.de\/index.php\/wp-json\/wp\/v2\/categories?post=396"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webtrackr.de\/index.php\/wp-json\/wp\/v2\/tags?post=396"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}