Mathematica Asked on October 22, 2021
I am working on, with the Animal Weights
data set and creating MyFunction
which calculates the Max,Min,Mean,Median and first quartile. Then a apply the function to the data set and show it as a menu with MenuView
. My question is, is there a possible way to use add the calculation name in the data set object? Like in the image below.
ResourceObject["Sample Data: Animal Weights"];
dataset = ResourceData["Sample Data: Animal Weights"];
MyFunction[dataset_] :=
{Max[dataset], Min[dataset], Mean[dataset], Median[dataset],
Quantile[dataset, 0.25]}
MenuView[{"BodyWeight" -> dataset[MyFunction, "BodyWeight"],
"BrainWeight" -> dataset[MyFunction, "BrainWeight"]}]
Clear["Global`*"]
ResourceObject["Sample Data: Animal Weights"];
dataset = ResourceData["Sample Data: Animal Weights"];
MyFunction[
dataset_] := {# /. _Function :> "1st Quartile", #[dataset]} & /@
{Max, Min, Mean, Median, Quantile[#, 0.25] &}
MenuView[{"BodyWeight" -> dataset[MyFunction, "BodyWeight"],
"BrainWeight" -> dataset[MyFunction, "BrainWeight"]}]
Answered by Bob Hanlon on October 22, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP