{"id":2479,"date":"2016-05-04T18:06:36","date_gmt":"2016-05-04T10:06:36","guid":{"rendered":"http:\/\/www.banbanli.net\/blog\/?p=2479"},"modified":"2016-05-04T18:06:36","modified_gmt":"2016-05-04T10:06:36","slug":"r-write-csv-missing-data","status":"publish","type":"post","link":"http:\/\/www.banbanli.net\/blog\/?p=2479","title":{"rendered":"R &#8211; write.csv missing data"},"content":{"rendered":"<p>http:\/\/stackoverflow.com\/questions\/15796499\/date-information-disappears-when-save-to-csv<\/p>\n<p>&nbsp;<\/p>\n<p>as SPY is a xts\/zoo object this will do the trick:<\/p>\n<p>replace:<\/p>\n<pre class=\"lang-r prettyprint prettyprinted\"><code><span class=\"pln\">write.csv<\/span><span class=\"pun\">(<\/span><span class=\"pln\">SPY<\/span><span class=\"pun\">,<\/span> <span class=\"str\">\"C:\/SPY.csv\"<\/span><span class=\"pun\">)<\/span><\/code><\/pre>\n<p>with<\/p>\n<pre class=\"lang-r prettyprint prettyprinted\"><code><span class=\"pln\">write.zoo<\/span><span class=\"pun\">(<\/span><span class=\"pln\">SPY<\/span><span class=\"pun\">,<\/span><span class=\"str\">\"C:\/SPY.csv\"<\/span><span class=\"pun\">,<\/span><span class=\"pln\">index.name<\/span><span class=\"pun\">=<\/span><span class=\"str\">\"Date\"<\/span><span class=\"pun\">,<\/span><span class=\"pln\">sep<\/span><span class=\"pun\">=<\/span><span class=\"str\">\",\"<\/span><span class=\"pun\">)<\/span><\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>http:\/\/stackoverflow.com\/questions\/15796499\/date-information-disappears-when-save-to-csv &nbsp; as SPY is a xts\/zoo object this will do the trick: replace: write.csv(SPY, &#8220;C:\/SPY.csv&#8221;) with write.zoo(SPY,&#8221;C:\/SPY.csv&#8221;,index.name=&#8221;Date&#8221;,sep=&#8221;,&#8221;)<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-2479","post","type-post","status-publish","format-standard","hentry","category-daily"],"_links":{"self":[{"href":"http:\/\/www.banbanli.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2479","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.banbanli.net\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.banbanli.net\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.banbanli.net\/blog\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/www.banbanli.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2479"}],"version-history":[{"count":1,"href":"http:\/\/www.banbanli.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2479\/revisions"}],"predecessor-version":[{"id":2480,"href":"http:\/\/www.banbanli.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2479\/revisions\/2480"}],"wp:attachment":[{"href":"http:\/\/www.banbanli.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2479"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.banbanli.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2479"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.banbanli.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2479"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}