{ "cells": [ { "cell_type": "markdown", "id": "f6b68dfa-a402-4c30-802b-a8cbaec69a7b", "metadata": {}, "source": [ "# Palmer Penguins\n", "\n", "This notebook is inspired by an example [Radar chart with ggradar](https://r-graph-gallery.com/web-radar-chart-with-R.html)." ] }, { "cell_type": "code", "execution_count": 1, "id": "aebbd473-7db1-4144-8bae-a61aefc67e9d", "metadata": { "execution": { "iopub.execute_input": "2024-11-01T20:41:59.524668Z", "iopub.status.busy": "2024-11-01T20:41:59.522659Z", "iopub.status.idle": "2024-11-01T20:42:02.350686Z", "shell.execute_reply": "2024-11-01T20:42:02.350441Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", " " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ " " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "%useLatestDescriptors\n", "%use dataframe\n", "%use lets-plot" ] }, { "cell_type": "code", "execution_count": 2, "id": "4cc8902f-7761-43ef-9fa9-26c72c2b8f00", "metadata": { "execution": { "iopub.execute_input": "2024-11-01T20:42:02.352811Z", "iopub.status.busy": "2024-11-01T20:42:02.352601Z", "iopub.status.idle": "2024-11-01T20:42:02.740735Z", "shell.execute_reply": "2024-11-01T20:42:02.740460Z" } }, "outputs": [], "source": [ "fun rescaleInGroupDataFrame(df: DataFrame<*>, valueCol: String, groupCol: String, rescaledCol: String? = null): DataFrame<*> {\n", " val rescaledColName = if (rescaledCol == null) {\n", " \"rescaled_${valueCol}\"\n", " } else {\n", " rescaledCol\n", " }\n", " fun rescaleSubDataFrame(subDf: DataFrame<*>): DataFrame<*> {\n", " val minValue = subDf.minByOrNull(valueCol)?.let { it[valueCol] } as Double\n", " val maxValue = subDf.maxByOrNull(valueCol)?.let { it[valueCol] } as Double\n", " return subDf.add(rescaledColName) { (valueColDataFrame: rowsCount = 4, columnsCount = 6
\n", "species | variable | value | units | rescaled_value | rescaled_value_pct |
---|---|---|---|---|---|
Adelie | avg. bill length | 38.823973 | mm | 0.000000 | 0 |
Adelie | avg. bill depth | 18.347260 | mm | 0.978584 | 97 |
Adelie | avg. flipper length | 190.102740 | mm | 0.000000 | 0 |
Adelie | avg. body mass | 3.706164 | kg | 0.000000 | 0 |