{"action":"opened","issue":{"url":"https://api.github.com/repos/hadley/haven/issues/144","labels_url":"https://api.github.com/repos/hadley/haven/issues/144/labels{/name}","comments_url":"https://api.github.com/repos/hadley/haven/issues/144/comments","events_url":"https://api.github.com/repos/hadley/haven/issues/144/events","html_url":"https://github.com/hadley/haven/issues/144","id":120324462,"number":144,"title":"write_dta: numeric labelleds not written correctly","user":{"login":"diogocp","id":6563869,"avatar_url":"https://avatars.githubusercontent.com/u/6563869?v=3","gravatar_id":"","url":"https://api.github.com/users/diogocp","html_url":"https://github.com/diogocp","followers_url":"https://api.github.com/users/diogocp/followers","following_url":"https://api.github.com/users/diogocp/following{/other_user}","gists_url":"https://api.github.com/users/diogocp/gists{/gist_id}","starred_url":"https://api.github.com/users/diogocp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/diogocp/subscriptions","organizations_url":"https://api.github.com/users/diogocp/orgs","repos_url":"https://api.github.com/users/diogocp/repos","events_url":"https://api.github.com/users/diogocp/events{/privacy}","received_events_url":"https://api.github.com/users/diogocp/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-12-04T03:27:38Z","updated_at":"2015-12-04T03:27:38Z","closed_at":null,"body":"I caught this in #140 but have not yet discovered the cause of the problem.\r\n```\r\n> num <- labelled(c(1, 2), c(a = 1, b = 3))\r\n> num\r\n<Labelled>\r\n[1] 1 2\r\n\r\nLabels:\r\n value label is_na\r\n     1     a FALSE\r\n     3     b FALSE\r\n> roundtrip_var(num)\r\n<Labelled>\r\n[1] 1 2\r\n\r\nLabels:\r\n value label is_na\r\n     0     a FALSE\r\n     0     b FALSE\r\n```\r\n\r\nI opened the file in Stata and verified that the labels are not written correctly:\r\n```\r\n. label list\r\nx..i..:\r\n           0 a\r\n           0 b\r\n```\r\n\r\nIt might be a bug in ReadStat, since the [label-writing code](https://github.com/hadley/haven/blob/master/src/DfWriter.cpp#L165) in DfWriter seems to be basically the same as the code for integer labelleds, which do work fine.\r\n\r\n"}}