{
  "id": 10453,
  "title": "Load the .mat file in R ?",
  "url": "/competitions/seizure-prediction/discussion/10453",
  "author_name": "",
  "post_date": "2014-09-25T21:25:49.313Z",
  "votes": 1,
  "comment_count": 4,
  "views": 10025,
  "content": "<p>Hi. I'm trying to learn R while doing this competition at the same time. I was wondering if someone can tell me how to load the .mat file in R?</p>\n<p>I got the R.matlab package and I can use</p>\n<p>data &lt;- readMat(filename.mat)</p>\n<p>I'm not sure if it actually parsed out a matrix successfully though.</p>\n<p>data$preictal.segment.1[1]</p>\n<p>That appears to return me a list of numbers then at the end it says...</p>\n<p>[,239752] [,239753] [,239754] [,239755] [,239756] [,239757] [,239758] [,239759] [,239760] [,239761] [,239762] [,239763] [,239764] [,239765] [,239766]<br> [ reached getOption(&quot;max.print&quot;) -- omitted 15 rows ]</p>\n<p>but I'm not sure how to convert this to a matrix.</p>\n<p>Any help would be appreciated! Thanks.</p>",
  "messages": [
    {
      "id": "55250",
      "postDate": "09/25/2014 21:25:49",
      "content": "<p>Hi. I'm trying to learn R while doing this competition at the same time. I was wondering if someone can tell me how to load the .mat file in R?</p>\n<p>I got the R.matlab package and I can use</p>\n<p>data &lt;- readMat(filename.mat)</p>\n<p>I'm not sure if it actually parsed out a matrix successfully though.</p>\n<p>data$preictal.segment.1[1]</p>\n<p>That appears to return me a list of numbers then at the end it says...</p>\n<p>[,239752] [,239753] [,239754] [,239755] [,239756] [,239757] [,239758] [,239759] [,239760] [,239761] [,239762] [,239763] [,239764] [,239765] [,239766]<br> [ reached getOption(&quot;max.print&quot;) -- omitted 15 rows ]</p>\n<p>but I'm not sure how to convert this to a matrix.</p>\n<p>Any help would be appreciated! Thanks.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "55255",
      "postDate": "09/25/2014 22:32:03",
      "content": "<p>Hi!</p>\n<p>I have created this simple function that can get you started. It will return a data frame with the measurements. A row is the data from one electrode (you will have 16 rows) and columns are measurements taken periodically (a lot of columns).</p>\n<p>I also show how to get &quot;data.length.sec&quot;, &quot;sequence&quot; etc. Hope that helps!</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "55258",
      "postDate": "09/25/2014 22:55:57",
      "content": "<p>LKay,</p>\n<p>You are almost there. You have read a list. Use str() to see this fact. The first entry of this list is also a list. The first entry of the second list is your data, stored by rows. So if you transpose it, you'll get the matrix you are probably used to work with. In other words,</p>\n<p>dog1 &lt;- readMat (fname)<br> data &lt;- t(dog1[[1]][[1]])</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "55261",
      "postDate": "09/26/2014 02:07:40",
      "content": "<p>Thank you both. That helped a lot. I didn't know that I need to use [[1]] to get the first element from the list. I kept on trying to use [1].</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "105491",
      "postDate": "01/23/2016 18:46:15",
      "content": "<p>Well I used only one [[]] without transposing and it worked so maybe this is the new version;</p>\n\n<blockquote>\n  <p>dog1 &lt;- readMat (fname) </p>\n  \n  <p>data &lt;- dog1[[1]]</p>\n</blockquote>",
      "rawMarkdown": "Well I used only one [[]] without transposing and it worked so maybe this is the new version;\r\n\r\n> dog1 <- readMat (fname) \r\n\r\n> data <- dog1[[1]]",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 55255,
      "author_name": "victordegliame",
      "author_url": "",
      "post_date": "09/25/2014 22:32:03",
      "content": "<p>Hi!</p>\n<p>I have created this simple function that can get you started. It will return a data frame with the measurements. A row is the data from one electrode (you will have 16 rows) and columns are measurements taken periodically (a lot of columns).</p>\n<p>I also show how to get &quot;data.length.sec&quot;, &quot;sequence&quot; etc. Hope that helps!</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 55258,
      "author_name": "mkozine",
      "author_url": "",
      "post_date": "09/25/2014 22:55:57",
      "content": "<p>LKay,</p>\n<p>You are almost there. You have read a list. Use str() to see this fact. The first entry of this list is also a list. The first entry of the second list is your data, stored by rows. So if you transpose it, you'll get the matrix you are probably used to work with. In other words,</p>\n<p>dog1 &lt;- readMat (fname)<br> data &lt;- t(dog1[[1]][[1]])</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 55261,
      "author_name": "lkay83",
      "author_url": "",
      "post_date": "09/26/2014 02:07:40",
      "content": "<p>Thank you both. That helped a lot. I didn't know that I need to use [[1]] to get the first element from the list. I kept on trying to use [1].</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 105491,
      "author_name": "yousrahmoh",
      "author_url": "",
      "post_date": "01/23/2016 18:46:15",
      "content": "<p>Well I used only one [[]] without transposing and it worked so maybe this is the new version;</p>\n\n<blockquote>\n  <p>dog1 &lt;- readMat (fname) </p>\n  \n  <p>data &lt;- dog1[[1]]</p>\n</blockquote>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "55250": "",
    "55255": "",
    "55258": "",
    "55261": "",
    "105491": "Well I used only one [[]] without transposing and it worked so maybe this is the new version;\r\n\r\n> dog1 <- readMat (fname) \r\n\r\n> data <- dog1[[1]]"
  },
  "source": "meta"
}