-
Notifications
You must be signed in to change notification settings - Fork 235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add percentile function for p-quantile #342
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @lulunac27a, could you please add/update test files in the example vault that both demonstrates this function being used but also works as a way to test that it is working? You can either add a new file or update https://github.com/pyrochlore/obsidian-tracker/blob/master/examples/TestExpression.md to include usage of the new function and then update a few of the files in the diary directory to use as the dataset
20-percentile of [12, 25, 48] is 17.2 and 60-percentile of [12, 25, 48] is 29.6
I added the test expressions. |
@@ -448,6 +448,10 @@ const fnMapDatasetToValue: FnMapDatasetToValue = { | |||
// return number | |||
return d3.median(dataset.getValues()); | |||
}, | |||
percentile: function (dataset, percentage, renderInfo) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't work since expression functions can only accept dataset
and renderInfo
. I checked locally and it won't even compile when I run npm run dev
. I would suggest instead looking at the RenderInfo class and adding a new field there to hold percentage
. Then your dataView code would look something like:
searchType: dvField
searchTarget: dataviewTarget
folder: /diary
endDate: 2021-01-03
percentage: 0.6
summary:
template: '60-percentile value: {{percentage(dataset(0))::.1f}} <-- should be 29.6'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After you have made changes, I strongly encourage you to run npm run dev
and then open up the example folder in Obsidian so you can verify it works (this is what I do with every new feature submitted)
Description
Add percentile function for datasets with p-quantile based from an array of numbers.
percentile
value is 0 to 100.Type of change
Please delete options that are not relevant.
How Has This Been Tested?