{
  "id": 21183,
  "title": "How to create the submission file in R?",
  "url": "/competitions/facebook-v-predicting-check-ins/discussion/21183",
  "author_name": "",
  "post_date": "2016-05-24T18:56:14.250Z",
  "votes": null,
  "comment_count": 3,
  "views": 452,
  "content": "<p>I think I am missing something very trivial here.. I have been saving the prediction matrix (4 columns: row_Id and 3 place_Ids) as a comma delimited csv file. But, the required format uses comma only after row_Id and spaces between the 3 place_Id columns. I would greatly appreciate if  someone could show me how to save the prediction matrix in the required format in R.</p>",
  "messages": [
    {
      "id": "121177",
      "postDate": "05/24/2016 18:56:14",
      "content": "<p>I think I am missing something very trivial here.. I have been saving the prediction matrix (4 columns: row_Id and 3 place_Ids) as a comma delimited csv file. But, the required format uses comma only after row_Id and spaces between the 3 place_Id columns. I would greatly appreciate if  someone could show me how to save the prediction matrix in the required format in R.</p>",
      "rawMarkdown": "I think I am missing something very trivial here.. I have been saving the prediction matrix (4 columns: row_Id and 3 place_Ids) as a comma delimited csv file. But, the required format uses comma only after row_Id and spaces between the 3 place_Id columns. I would greatly appreciate if  someone could show me how to save the prediction matrix in the required format in R.",
      "votes": null
    },
    {
      "id": "121187",
      "postDate": "05/24/2016 19:25:00",
      "content": "<p>test &lt;- data.frame(test)</p>\n\n<p>apply(test[,2:4], 1, paste, collapse=&quot; &quot;) -&gt; test$place_id</p>\n\n<p>test &lt;- test[,c(1,5)]</p>\n\n<p>names(test) &lt;- c(&quot;row_id&quot;,&quot;place_id&quot;)</p>\n\n<p>write.csv(test, &quot;submission.csv&quot;, row.names=FALSE)</p>",
      "rawMarkdown": "test <- data.frame(test)\r\n\r\napply(test[,2:4], 1, paste, collapse=\" \") -> test$place_id\r\n\r\ntest <- test[,c(1,5)]\r\n\r\nnames(test) <- c(\"row_id\",\"place_id\")\r\n\r\nwrite.csv(test, \"submission.csv\", row.names=FALSE)",
      "votes": null
    },
    {
      "id": "121202",
      "postDate": "05/24/2016 21:05:30",
      "content": "<p>Thanks a lot! .. that collapse does the trick. One more point here: just needed to run </p>\n\n<pre><code>options(scipen = 999)\n</code></pre>\n\n<p>before saving to suppress scientific notation (I got error messages from Kaggle without that).</p>",
      "rawMarkdown": "Thanks a lot! .. that collapse does the trick. One more point here: just needed to run \r\n\r\n    options(scipen = 999)\r\n\r\nbefore saving to suppress scientific notation (I got error messages from Kaggle without that).",
      "votes": null
    },
    {
      "id": "121729",
      "postDate": "05/29/2016 06:44:57",
      "content": "<p>place_id should  be type 'character' rather than numeric since its just a label.   That will prevent any numeric conversion.  An elegant  way to do this using fread is:\ntrain &lt;- fread(&quot;../input/train.csv&quot;, integer64 = &quot;character&quot;)</p>\n\n<p>Note: Tip of the hat to Stanislov Chistyakov's script where I lifted that line</p>",
      "rawMarkdown": "place_id should  be type 'character' rather than numeric since its just a label.   That will prevent any numeric conversion.  An elegant  way to do this using fread is:\r\ntrain <- fread(\"../input/train.csv\", integer64 = \"character\")\r\n\r\nNote: Tip of the hat to Stanislov Chistyakov's script where I lifted that line",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 121187,
      "author_name": "freeball",
      "author_url": "",
      "post_date": "05/24/2016 19:25:00",
      "content": "<p>test &lt;- data.frame(test)</p>\n\n<p>apply(test[,2:4], 1, paste, collapse=&quot; &quot;) -&gt; test$place_id</p>\n\n<p>test &lt;- test[,c(1,5)]</p>\n\n<p>names(test) &lt;- c(&quot;row_id&quot;,&quot;place_id&quot;)</p>\n\n<p>write.csv(test, &quot;submission.csv&quot;, row.names=FALSE)</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 121202,
      "author_name": "knadeem",
      "author_url": "",
      "post_date": "05/24/2016 21:05:30",
      "content": "<p>Thanks a lot! .. that collapse does the trick. One more point here: just needed to run </p>\n\n<pre><code>options(scipen = 999)\n</code></pre>\n\n<p>before saving to suppress scientific notation (I got error messages from Kaggle without that).</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 121729,
      "author_name": "datadave",
      "author_url": "",
      "post_date": "05/29/2016 06:44:57",
      "content": "<p>place_id should  be type 'character' rather than numeric since its just a label.   That will prevent any numeric conversion.  An elegant  way to do this using fread is:\ntrain &lt;- fread(&quot;../input/train.csv&quot;, integer64 = &quot;character&quot;)</p>\n\n<p>Note: Tip of the hat to Stanislov Chistyakov's script where I lifted that line</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "121177": "I think I am missing something very trivial here.. I have been saving the prediction matrix (4 columns: row_Id and 3 place_Ids) as a comma delimited csv file. But, the required format uses comma only after row_Id and spaces between the 3 place_Id columns. I would greatly appreciate if  someone could show me how to save the prediction matrix in the required format in R.",
    "121187": "test <- data.frame(test)\r\n\r\napply(test[,2:4], 1, paste, collapse=\" \") -> test$place_id\r\n\r\ntest <- test[,c(1,5)]\r\n\r\nnames(test) <- c(\"row_id\",\"place_id\")\r\n\r\nwrite.csv(test, \"submission.csv\", row.names=FALSE)",
    "121202": "Thanks a lot! .. that collapse does the trick. One more point here: just needed to run \r\n\r\n    options(scipen = 999)\r\n\r\nbefore saving to suppress scientific notation (I got error messages from Kaggle without that).",
    "121729": "place_id should  be type 'character' rather than numeric since its just a label.   That will prevent any numeric conversion.  An elegant  way to do this using fread is:\r\ntrain <- fread(\"../input/train.csv\", integer64 = \"character\")\r\n\r\nNote: Tip of the hat to Stanislov Chistyakov's script where I lifted that line"
  },
  "source": "meta"
}