{
  "id": 9616,
  "title": "Help getting started - Russian text not displaying in RStudio",
  "url": "/competitions/avito-prohibited-content/discussion/9616",
  "author_name": "",
  "post_date": "2014-06-30T13:37:52.010Z",
  "votes": null,
  "comment_count": 6,
  "views": 4017,
  "content": "<p>I asked a question about this on StackOverlow but no one has been able to help me yet and I would really like to try this competition. &nbsp;Can anyone help me with this?<br><br></p>\n<p>Original question: &nbsp;<a href=\"http://stackoverflow.com/questions/24437479/rstudio-output-of-russian-characters\">http://stackoverflow.com/questions/24437479/rstudio-output-of-russian-characters<br><br></a></p>\n<p>In the following code, I am reading in a TSV file and outputting the first few titles from it:<br><br></p>\n<p><code>&gt; raw &lt;- read.csv(&quot;avito_train.tsv&quot;, sep='\\t', stringsAsFactors = F, nrows = 100)<br>&gt; View(raw)<br>&gt; str(raw$title[1:3])<br> chr [1:3] &quot;Toyota Sera, 1991&quot; &quot;&#208;&#339;&#208;&#190;&#208;&#189;&#209;&#8218;&#208;&#176;&#208;&#182; &#208;&#186;&#209;&#8364;&#208;&#190;&#208;&#178;&#208;&#187;&#208;&#184;&quot; &quot;&#208;&#353;&#208;&#190;&#209;&#209;&#8218;&#209;&#381;&#208;&#188; Steilmann&quot;&quot;| __truncated__<br><br></code></p>\n<p>Whereas, the titles should display as:<br><br></p>\n<p><code>Toyota Sera, 1991 <br>&#1052;&#1086;&#1085;&#1090;&#1072;&#1078; &#1082;&#1088;&#1086;&#1074;&#1083;&#1080; <br>&#1050;&#1086;&#1089;&#1090;&#1102;&#1084; Steilmann</code></p>\n<p><br>When I open up my `raw` variable to view it in RStudio, I can see the characters fine (actual Russian characters). However, as you can see from above, the output into the R console is not Russian at all, it's some strangely encoded text.<br><br></p>\n<p>Is this correct? Why does it do this, and how can I get it to output the text as it does when I am viewing the `raw` variable loaded from the TSV file?</p>",
  "messages": [
    {
      "id": "49850",
      "postDate": "06/30/2014 13:37:52",
      "content": "<p>I asked a question about this on StackOverlow but no one has been able to help me yet and I would really like to try this competition. &nbsp;Can anyone help me with this?<br><br></p>\n<p>Original question: &nbsp;<a href=\"http://stackoverflow.com/questions/24437479/rstudio-output-of-russian-characters\">http://stackoverflow.com/questions/24437479/rstudio-output-of-russian-characters<br><br></a></p>\n<p>In the following code, I am reading in a TSV file and outputting the first few titles from it:<br><br></p>\n<p><code>&gt; raw &lt;- read.csv(&quot;avito_train.tsv&quot;, sep='\\t', stringsAsFactors = F, nrows = 100)<br>&gt; View(raw)<br>&gt; str(raw$title[1:3])<br> chr [1:3] &quot;Toyota Sera, 1991&quot; &quot;&#208;&#339;&#208;&#190;&#208;&#189;&#209;&#8218;&#208;&#176;&#208;&#182; &#208;&#186;&#209;&#8364;&#208;&#190;&#208;&#178;&#208;&#187;&#208;&#184;&quot; &quot;&#208;&#353;&#208;&#190;&#209;&#209;&#8218;&#209;&#381;&#208;&#188; Steilmann&quot;&quot;| __truncated__<br><br></code></p>\n<p>Whereas, the titles should display as:<br><br></p>\n<p><code>Toyota Sera, 1991 <br>&#1052;&#1086;&#1085;&#1090;&#1072;&#1078; &#1082;&#1088;&#1086;&#1074;&#1083;&#1080; <br>&#1050;&#1086;&#1089;&#1090;&#1102;&#1084; Steilmann</code></p>\n<p><br>When I open up my `raw` variable to view it in RStudio, I can see the characters fine (actual Russian characters). However, as you can see from above, the output into the R console is not Russian at all, it's some strangely encoded text.<br><br></p>\n<p>Is this correct? Why does it do this, and how can I get it to output the text as it does when I am viewing the `raw` variable loaded from the TSV file?</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "49856",
      "postDate": "06/30/2014 14:21:15",
      "content": "<p>Can you pass utf-8 encoding to the dataframe in R?</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "49864",
      "postDate": "06/30/2014 14:57:50",
      "content": "<p>I believe I have tried that last week but it didn't work. &nbsp;However, I have made some headway...<br><br></p>\n<p>As posted in my new question (<a href=\"http://stackoverflow.com/questions/24492969/apply-encoding-to-entire-data-table\">http://stackoverflow.com/questions/24492969/apply-encoding-to-entire-data-table</a>) it works perfectly if I&nbsp;set the encoding on a single row/column.<br><br></p>\n<p>But, I need to do that same thing to an entire data.table, not just one row/column. &nbsp;<br><br>Also, I am now using&nbsp;<em>fread</em> since it is much faster than <em>read.csv</em>.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "49874",
      "postDate": "06/30/2014 18:04:57",
      "content": "<p>Hi</p>\n\n<p>I tried running but getting below error.</p>\n\n<p>raw &lt;- read.csv(&quot;D:\\\\My content\\\\analytics\\\\kaggle_avito_competition\\\\avito_test\\\\avito_train.tsv&quot;, sep='\\t',encoding = 'UTF-8',allowEscapes=FALSE,quote=&quot;\\&quot;&quot;)</p>\n<p><br>Error in type.convert(data[[i]], as.is = as.is[i], dec = dec, na.strings = character(0L)) : <br> invalid input '&#208;&#353;&#208;&#190;&#208;&#187;&#209;&#338;&#209;&#8224;&#208;&#190; &#209; &#208;&#177;&#208;&#176;&#208;&#189;&#209;&#8218;&#208;&#184;&#208;&#186;&#208;&#190;&#208;&#188;&#240;&#376;&#381;&#8364; ^p &#208; &#208;&#176;&#208;&#183;&#208;&#188;&#208;&#181;&#209;&#8364; 16-16,5 ^p @@EMAIL@@' in 'utf8towcs'</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "49885",
      "postDate": "07/01/2014 02:57:41",
      "content": "<p>I believe the problem is wholly in RStudio.&nbsp; Not all of the text controls they use are&nbsp;Unicode compliant, and so while the content is read correctly the control cannot display it correctly.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "49886",
      "postDate": "07/01/2014 04:37:32",
      "content": "<p>I just curious to know will it really make any difference if i train my model with the UTF-8 option and without UTF-8 option</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "49897",
      "postDate": "07/01/2014 13:18:41",
      "content": "<p>I solved this (for myself, anyway). &nbsp;Please see my answer&nbsp;http://stackoverflow.com/questions/24492969/apply-encoding-to-entire-data-table</p>",
      "rawMarkdown": "",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 49856,
      "author_name": "irishsteve",
      "author_url": "",
      "post_date": "06/30/2014 14:21:15",
      "content": "<p>Can you pass utf-8 encoding to the dataframe in R?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 49864,
      "author_name": "dominic1",
      "author_url": "",
      "post_date": "06/30/2014 14:57:50",
      "content": "<p>I believe I have tried that last week but it didn't work. &nbsp;However, I have made some headway...<br><br></p>\n<p>As posted in my new question (<a href=\"http://stackoverflow.com/questions/24492969/apply-encoding-to-entire-data-table\">http://stackoverflow.com/questions/24492969/apply-encoding-to-entire-data-table</a>) it works perfectly if I&nbsp;set the encoding on a single row/column.<br><br></p>\n<p>But, I need to do that same thing to an entire data.table, not just one row/column. &nbsp;<br><br>Also, I am now using&nbsp;<em>fread</em> since it is much faster than <em>read.csv</em>.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 49874,
      "author_name": "emohit",
      "author_url": "",
      "post_date": "06/30/2014 18:04:57",
      "content": "<p>Hi</p>\n\n<p>I tried running but getting below error.</p>\n\n<p>raw &lt;- read.csv(&quot;D:\\\\My content\\\\analytics\\\\kaggle_avito_competition\\\\avito_test\\\\avito_train.tsv&quot;, sep='\\t',encoding = 'UTF-8',allowEscapes=FALSE,quote=&quot;\\&quot;&quot;)</p>\n<p><br>Error in type.convert(data[[i]], as.is = as.is[i], dec = dec, na.strings = character(0L)) : <br> invalid input '&#208;&#353;&#208;&#190;&#208;&#187;&#209;&#338;&#209;&#8224;&#208;&#190; &#209; &#208;&#177;&#208;&#176;&#208;&#189;&#209;&#8218;&#208;&#184;&#208;&#186;&#208;&#190;&#208;&#188;&#240;&#376;&#381;&#8364; ^p &#208; &#208;&#176;&#208;&#183;&#208;&#188;&#208;&#181;&#209;&#8364; 16-16,5 ^p @@EMAIL@@' in 'utf8towcs'</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 49885,
      "author_name": "walterwilliams",
      "author_url": "",
      "post_date": "07/01/2014 02:57:41",
      "content": "<p>I believe the problem is wholly in RStudio.&nbsp; Not all of the text controls they use are&nbsp;Unicode compliant, and so while the content is read correctly the control cannot display it correctly.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 49886,
      "author_name": "emohit",
      "author_url": "",
      "post_date": "07/01/2014 04:37:32",
      "content": "<p>I just curious to know will it really make any difference if i train my model with the UTF-8 option and without UTF-8 option</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 49897,
      "author_name": "dominic1",
      "author_url": "",
      "post_date": "07/01/2014 13:18:41",
      "content": "<p>I solved this (for myself, anyway). &nbsp;Please see my answer&nbsp;http://stackoverflow.com/questions/24492969/apply-encoding-to-entire-data-table</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "49850": "",
    "49856": "",
    "49864": "",
    "49874": "",
    "49885": "",
    "49886": "",
    "49897": ""
  },
  "source": "meta"
}