Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I maintain an order after creating a list from a data.frame
    primarykey
    data
    text
    <p>I have a data.frame in R, myTable consisting of a date , myDate; integer, myCount and factor ,myCategory. It is sorted by date</p> <p>I need to create a list from the data.frame (in order to plot a Highcharts graph in rCharts) </p> <pre><code>mySeries &lt;- lapply(split(myTable, myTable$myCategory), function(x) { res &lt;- lapply(split(x, rownames(x)), as.list) names(res) &lt;- NULL return(res) }) </code></pre> <p>However, the resulting list is not ordered by myDate within myCategory. How can this be achieved? myTable shown below</p> <p>TIA</p> <pre><code>myTable &lt;- structure(list(myDate = structure(c(15642, 15649, 15656, 15663, 15670, 15670, 15677, 15677, 15684, 15684, 15691, 15691, 15698, 15698, 15705, 15705, 15712, 15712, 15719, 15719, 15726, 15726, 15733, 15733, 15740, 15740, 15747, 15747, 15754, 15754, 15761, 15761, 15768, 15768, 15775, 15775, 15782, 15782, 15789, 15789, 15796, 15796, 15803, 15803, 15810, 15810, 15817, 15817, 15824, 15824, 15831, 15831, 15838, 15838, 15845, 15845, 15852, 15852, 15859, 15859, 15866, 15866), class = "Date"), myCount = c(142L, 338L, 350L, 324L, 490L, 4L, 567L, 178L, 414L, 113L, 489L, 195L, 241L, 168L, 355L, 164L, 1215L, 253L, 2171L, 222L, 1916L, 437L, 1820L, 420L, 1897L, 356L, 1632L, 381L, 1571L, 464L, 1835L, 620L, 1348L, 500L, 1398L, 448L, 2668L, 461L, 2510L, 456L, 2654L, 733L, 1977L, 617L, 1645L, 523L, 1857L, 550L, 1247L, 477L, 1286L, 560L, 1168L, 719L, 1264L, 649L, 1162L, 682L, 1149L, 801L, 1450L, 1018L ), myCategory = structure(c(1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L), .Label = c("A", "B"), class = "factor")), .Names = c("myDate", "myCount", "myCategory"), row.names = c(62L, 59L, 56L, 55L, 51L, 52L, 47L, 48L, 49L, 50L, 53L, 54L, 60L, 61L, 57L, 58L, 45L, 46L, 39L, 40L, 1L, 2L, 23L, 24L, 35L, 36L, 41L, 42L, 31L, 32L, 27L, 28L, 11L, 12L, 33L, 34L, 37L, 38L, 43L, 44L, 17L, 18L, 15L, 16L, 7L, 8L, 3L, 4L, 29L, 30L, 19L, 20L, 13L, 14L, 9L, 10L, 21L, 22L, </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload