ISAAKiel / oxcAAR

R Package - Interaction with Oxcal
GNU General Public License v2.0
21 stars 4 forks source link

Tidy Output #6

Open MartinHinz opened 7 years ago

MartinHinz commented 7 years ago

implement functions that extract informations from the resulting oxcAAR objects and present them in easily processible formats (vector, data frame)

Candidates are:

FFaupel commented 7 years ago

As I was busy during your report on oxcAAR with mortAAR, I am not up to date... Anyway, perhaps I have an idea for output once I read the vignette.

Sorry, for not listening ; )

MartinHinz commented 7 years ago

OK, going the other way round, what is in the object and what can potentially be extracted:

together with get, this might form a body of output functions. Not sure if name is relevant. So

What do you think? Enough, to much, or any idea about a derivative value that would benefit from an explicit function?

nevrome commented 7 years ago

Ok - I still don't understand oxcAAR completely, so correct me if I'm wrong.

There are two main classes: oxcAARCalibratedDates and oxcAARCalibratedDatesList

The tidy output should be a data.frame. I suggest to prepare an output data.frame were one row represents one date. In case of the oxcAARCalibratedDates, the output data.frame respectively has one row, in case of the oxcAARCalibratedDatesList many.

These are the values in oxcAARCalibratedDates:

' @param name a string giving the name of the date (usually the lab number)

' @param bp a integer giving the BP value for the date

' @param std a integer giving the standard deviation for the date

' @param cal_curve a string giving the used calibration curve

' @param sigma_ranges a list of three elements (one, two, three sigma), each a data frame with start, end and probability giving

' @param raw_probabilities a data frame of dates and the related probabilities for each date

Strings and integers can go into the data.frame immediately, the list and the data.frame can be stored in list columns. That's how I would do it. D'accord?

nevrome commented 7 years ago

Idea: We don't write an own tidy output function but prepare a pull request with one for the broom package. https://github.com/tidyverse/broom

MartinHinz commented 7 years ago

Now I understand much better what you have in mind.

What about the following:

Benefits:

Costs:

nevrome commented 7 years ago

get_tidy_oxcalresult() should be part of 1.0. We tackle the broom::tidy() implementation when oxcAAR 1.0 is on CRAN. Let's do it!

MartinHinz commented 7 years ago

50 % reached with e4af8749a9e43f312384c41c16667145e5e9e493. Yeahh!

Now the get_tidy_oxcalresult() function has to be implemented.

MartinHinz commented 7 years ago

Returned to thinking about the usefulness of this... It would make it necessary to import "tibble", just for this purpose. Especially questionable, when we still want or need to implement a function at broom. So I changed my mind, and would vote for transfering all tidy functionalitity to our broom fork. What do you think?

nevrome commented 7 years ago

I'm pretty confident that we don't need tibble for the basic implementation. Further on get_tidy_oxcalresult() could already be structured more or less like the future tidy() implementation. I'll give it a go this afternoon and you can decide afterwards if you like it, ja?

MartinHinz commented 7 years ago

Sure, would have done that my self, but fine. But I still do not know how you will do that without the actual tibble format!? How put the data.frame of probabilities into a "data.frame" of a tidy structure!?

nevrome commented 7 years ago

A normal dataframe also allows nested content. Do I miss something?

data.frame(
  a = 1:3, 
  b = I(list(1,1:2,1:3)), 
  c = I(list(list(1,1:2,1:3), list(1,1:2,1:3), list(1,1:2,1:3))), 
  d = I(list(mtcars, mtcars, mtcars))
)

I'm still working on the getter functions, but eventually I'll get to it...

MartinHinz commented 7 years ago

Right, damn, my ignorance. Was not aware of the I! OK, then it seems that I am looking forward to your solution!!

nevrome commented 7 years ago

af2cc5c1ee817efc805e87b0baf3205bd9e25e0d. You're right - would be much more nice with tibble. But I think that'll do for the moment until we have a CRAN release and can take a look at broom.

Was not in the mood to write tests yet. Will do later.

Concerning the getter functions: Does the call to unname() make sense?

MartinHinz commented 7 years ago

https://www.youtube.com/watch?v=BHsSgxpX8rY

Thanks alot, could also do the tests if you like, let me know.

Unname absolutely makes sense!

nevrome commented 7 years ago

Haha - nono I can write the tests. ;-)

MartinHinz commented 7 years ago

Do you think it is ok to move this issue than to 1.1?