{
  "id": 21152,
  "title": "mapk giving unexpected results in R",
  "url": "/competitions/expedia-hotel-recommendations/discussion/21152",
  "author_name": "",
  "post_date": "2016-05-23T11:13:35.877Z",
  "votes": null,
  "comment_count": 1,
  "views": 519,
  "content": "<p>I can't quite wrap my head around how mapk works. I got these results:</p>\n\n<blockquote>\n  <p>mapk(5, as.list(c(1,10)), as.list(c(2,3,4,5,6), c(20, 30, 40, 50, 60)))</p>\n</blockquote>\n\n<p>[1] 0</p>\n\n<blockquote>\n  <p>mapk(5, as.list(c(1,10)), as.list(c(2,3,4,5,6), c(20, 10, 40, 50, 60)))</p>\n</blockquote>\n\n<p>[1] 0</p>\n\n<p>I definitely wasn't expecting 0 from the second one as the second true value, 10, is among the values of c(20, 10, 40, 50, 60). Anyone got any insight on this?</p>",
  "messages": [
    {
      "id": "121059",
      "postDate": "05/23/2016 11:13:35",
      "content": "<p>I can't quite wrap my head around how mapk works. I got these results:</p>\n\n<blockquote>\n  <p>mapk(5, as.list(c(1,10)), as.list(c(2,3,4,5,6), c(20, 30, 40, 50, 60)))</p>\n</blockquote>\n\n<p>[1] 0</p>\n\n<blockquote>\n  <p>mapk(5, as.list(c(1,10)), as.list(c(2,3,4,5,6), c(20, 10, 40, 50, 60)))</p>\n</blockquote>\n\n<p>[1] 0</p>\n\n<p>I definitely wasn't expecting 0 from the second one as the second true value, 10, is among the values of c(20, 10, 40, 50, 60). Anyone got any insight on this?</p>",
      "rawMarkdown": "I can't quite wrap my head around how mapk works. I got these results:\r\n\r\n> mapk(5, as.list(c(1,10)), as.list(c(2,3,4,5,6), c(20, 30, 40, 50, 60)))\r\n\r\n[1] 0\r\n\r\n> mapk(5, as.list(c(1,10)), as.list(c(2,3,4,5,6), c(20, 10, 40, 50, 60)))\r\n\r\n[1] 0\r\n\r\nI definitely wasn't expecting 0 from the second one as the second true value, 10, is among the values of c(20, 10, 40, 50, 60). Anyone got any insight on this?",
      "votes": null
    },
    {
      "id": "121107",
      "postDate": "05/24/2016 01:01:49",
      "content": "<p>Check how the function is called: <strong>mapk &lt;- function (k, actual, predicted)</strong>. \nIn your kase k=5, actual = c(1,10), and predicted c(2,3,4,5,6), so no wonder that mapk=0.</p>\n\n<p>change your mapk.r source to make it print out your actual and predicted values, and you will see what vectors are used for comparison.</p>",
      "rawMarkdown": "Check how the function is called: **mapk <- function (k, actual, predicted)**. \r\nIn your kase k=5, actual = c(1,10), and predicted c(2,3,4,5,6), so no wonder that mapk=0.\r\n\r\nchange your mapk.r source to make it print out your actual and predicted values, and you will see what vectors are used for comparison.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 121107,
      "author_name": "omovchan",
      "author_url": "",
      "post_date": "05/24/2016 01:01:49",
      "content": "<p>Check how the function is called: <strong>mapk &lt;- function (k, actual, predicted)</strong>. \nIn your kase k=5, actual = c(1,10), and predicted c(2,3,4,5,6), so no wonder that mapk=0.</p>\n\n<p>change your mapk.r source to make it print out your actual and predicted values, and you will see what vectors are used for comparison.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "121059": "I can't quite wrap my head around how mapk works. I got these results:\r\n\r\n> mapk(5, as.list(c(1,10)), as.list(c(2,3,4,5,6), c(20, 30, 40, 50, 60)))\r\n\r\n[1] 0\r\n\r\n> mapk(5, as.list(c(1,10)), as.list(c(2,3,4,5,6), c(20, 10, 40, 50, 60)))\r\n\r\n[1] 0\r\n\r\nI definitely wasn't expecting 0 from the second one as the second true value, 10, is among the values of c(20, 10, 40, 50, 60). Anyone got any insight on this?",
    "121107": "Check how the function is called: **mapk <- function (k, actual, predicted)**. \r\nIn your kase k=5, actual = c(1,10), and predicted c(2,3,4,5,6), so no wonder that mapk=0.\r\n\r\nchange your mapk.r source to make it print out your actual and predicted values, and you will see what vectors are used for comparison."
  },
  "source": "meta"
}