JohnCoene / javascript-for-r-comments

1 stars 0 forks source link

Note on Chapter 5 #8

Open MayaGans opened 4 years ago

MayaGans commented 4 years ago

OMG I love this chapter so much!

I don't know if this is too much for an intro chapter (maybe you can consider adding exercises at the end of some of these chapters?) but I wanted to see how test would return in the following example

  x = list(
    message = as.character(message),
    test = data.frame(COL1 = c(1,2,3), COL2 = c("a", "b", "c"))
  )

My mental model was that it'd be returned like this:

test = [
  {COL1: 1, COL2: "a"},
  {COL1: 2, COL2: "b"},
  {COL1: 3, COL2: "c"},
]

But really this returns two arrays which we can access using x.test.COL1 and x.test.COL2.

Again this is just a note, figured I'd share something I explored as a learner as it may be worth including a data structure a user is likely to pass into the widget (but maybe you do that in future chapters 😊 )

JohnCoene commented 4 years ago

Hah, yes indeed there is a bit about that in the introduction on JSON.

If you don't mind, keep reading as this is a recurring "issue" that is encountered repeatedly in the book, there is a solid section on this in a later htmlwidgets-related chapter. Then you can tell me if that should perhaps be placed earlier in the book. :)

And you are correct, I think: it should serialise rowwise but (for legacy reasons I think) it serialises columnwise.

MayaGans commented 4 years ago

Ah ha! Just got to the section in Chapter 7! Maybe consider a note box with those cute warning icons that you will address data manipulation in a future chapter? Might not be necessary though - I think we can close this issue since it's covered