{ "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": "2025-12-03T16:13:57.846074Z", "iopub.status.busy": "2025-12-03T16:13:57.844394Z", "iopub.status.idle": "2025-12-03T16:14:00.375463Z", "shell.execute_reply": "2025-12-03T16:14:00.375206Z" } }, "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" }, { "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": "d5f7ef92-18ee-4435-850b-ce1eda0a98cd", "metadata": { "execution": { "iopub.execute_input": "2025-12-03T16:14:00.378111Z", "iopub.status.busy": "2025-12-03T16:14:00.377500Z", "iopub.status.idle": "2025-12-03T16:14:00.409530Z", "shell.execute_reply": "2025-12-03T16:14:00.409094Z" } }, "outputs": [ { "data": { "text/plain": [ "Lets-Plot Kotlin API v.4.12.0. Frontend: Notebook with dynamically loaded JS. Lets-Plot JS v.4.8.1.\n", "Outputs: Web (HTML+JS), Kotlin Notebook (Swing), Static SVG (hidden)" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "LetsPlot.getInfo()" ] }, { "cell_type": "code", "execution_count": 3, "id": "4cc8902f-7761-43ef-9fa9-26c72c2b8f00", "metadata": { "execution": { "iopub.execute_input": "2025-12-03T16:14:00.412421Z", "iopub.status.busy": "2025-12-03T16:14:00.411635Z", "iopub.status.idle": "2025-12-03T16:14:00.939262Z", "shell.execute_reply": "2025-12-03T16:14:00.938999Z" } }, "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 |