Agregando Taller 1

This commit is contained in:
2025-09-26 15:30:39 +00:00
parent 528d53a70a
commit 7ee7f5cca2
16 changed files with 4501 additions and 1 deletions

View File

@@ -5,4 +5,5 @@ services:
image: aleleba/vscode
volumes:
- ./extensions.json:/home/extensions.json
- ./custom-scripts:/usr/bin/custom-scripts
- ./custom-scripts:/usr/bin/custom-scripts
- ./proyectos:/home/vscode/proyectos

View File

@@ -0,0 +1,23 @@
# Try Jupyter, powered by JupyterLite
[![lite-badge](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://jupyter.org/try-jupyter)
A tour of Jupyter and IPython, powered by JupyterLite.
## ✨ Try it in your browser ✨
➡️ **https://jupyter.org/try-jupyter**
Clicking the link above should load a JupyterLab environment running in your browser. Open the Introductory notebook at `notebooks/Intro.ipynb` to get started.
## About this repository
This is a demonstration repository meant for use at `try.jupyter.org`. It uses the [JupyterLite project](https://jupyterlite.readthedocs.io/en/latest/) to embed a self-contained Jupyter environment in the browser, along with many popular packages in scientific computing.
It uses GitHub pages to serve the JupyterLite bundle, and is accessible at https://jupyter.org/try-jupyter.
### How to edit these notebooks
The notebooks in this repository are written with [JupyterLite kernels](https://jupyterlite.readthedocs.io/en/latest/kernels/index.html), so if you edit them locally, you will likely over-write the kernel information with your local kernels.
As such, the easiest way to make edits to them is to do so [**via the Try Jupyter Page**](https://jupyter.org/try-jupyter).
Make the edits you wish at that URL, then download the notebook and replace the one in a repository locally.

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@@ -0,0 +1,54 @@
{
"data": {
"values": [
{
"a": "A",
"b": 28
},
{
"a": "B",
"b": 55
},
{
"a": "C",
"b": 43
},
{
"a": "D",
"b": 91
},
{
"a": "E",
"b": 81
},
{
"a": "F",
"b": 53
},
{
"a": "G",
"b": 19
},
{
"a": "H",
"b": 87
},
{
"a": "I",
"b": 52
}
]
},
"description": "A simple bar chart with embedded data.",
"encoding": {
"x": {
"field": "a",
"type": "ordinal"
},
"y": {
"field": "b",
"type": "quantitative"
}
},
"mark": "bar"
}

View File

@@ -0,0 +1,8 @@
>SEQUENCE_1
MTEITAAMVKELRESTGAGMMDCKNALSETNGDFDKAVQLLREKGLGKAAKKADRLAAEG
LVSVKVSDDFTIAAMRPSYLSYEDLDMTFVENEYKALVAELEKENEERRRLKDPNKPEHK
IPQFASRKQLSDAILKEAEEKIKEELKAQGKPEKIWDNIIPGKMNSFIADNSQLDSKLTL
MGQFYVMDDKKTVEQVIAEKEKEFGGKIKIVEFICFEVGEGLEKKTEDFAAEVAAQL
>SEQUENCE_2
SATVSEINSETDFVAKNDQFIALTKDTTAHIQSNSLQSVEELHSSTINGVKFEEYLKSQI
ATIGENLVVRRFATLKAGANGVVNGYIHTNGRVGVVIAAACDSAEVASKSRDLLRQICMH

View File

@@ -0,0 +1,151 @@
sepal_length,sepal_width,petal_length,petal_width,species
5.1,3.5,1.4,0.2,se
4.9,3,1.4,0.2,setosa
4.7,3.2,1.3,0.2,setosa
4.6,3.1,1.5,0.2,setosa
5,3.6,1.4,0.2,setosa
5.4,3.9,1.7,0.4,setosa
4.6,3.4,1.4,0.3,setosa
5,3.4,1.5,0.2,setosa
4.4,2.9,1.4,0.2,setosa
4.9,3.1,1.5,0.1,setosa
5.4,3.7,1.5,0.2,setosa
4.8,3.4,1.6,0.2,setosa
4.8,3,1.4,0.1,setosa
4.3,3,1.1,0.1,setosa
5.8,4,1.2,0.2,setosa
5.7,4.4,1.5,0.4,setosa
5.4,3.9,1.3,0.4,setosa
5.1,3.5,1.4,0.3,setosa
5.7,3.8,1.7,0.3,setosa
5.1,3.8,1.5,0.3,setosa
5.4,3.4,1.7,0.2,setosa
5.1,3.7,1.5,0.4,setosa
4.6,3.6,1,0.2,setosa
5.1,3.3,1.7,0.5,setosa
4.8,3.4,1.9,0.2,setosa
5,3,1.6,0.2,setosa
5,3.4,1.6,0.4,setosa
5.2,3.5,1.5,0.2,setosa
5.2,3.4,1.4,0.2,setosa
4.7,3.2,1.6,0.2,setosa
4.8,3.1,1.6,0.2,setosa
5.4,3.4,1.5,0.4,setosa
5.2,4.1,1.5,0.1,setosa
5.5,4.2,1.4,0.2,setosa
4.9,3.1,1.5,0.1,setosa
5,3.2,1.2,0.2,setosa
5.5,3.5,1.3,0.2,setosa
4.9,3.1,1.5,0.1,setosa
4.4,3,1.3,0.2,setosa
5.1,3.4,1.5,0.2,setosa
5,3.5,1.3,0.3,setosa
4.5,2.3,1.3,0.3,setosa
4.4,3.2,1.3,0.2,setosa
5,3.5,1.6,0.6,setosa
5.1,3.8,1.9,0.4,setosa
4.8,3,1.4,0.3,setosa
5.1,3.8,1.6,0.2,setosa
4.6,3.2,1.4,0.2,setosa
5.3,3.7,1.5,0.2,setosa
5,3.3,1.4,0.2,setosa
7,3.2,4.7,1.4,versicolor
6.4,3.2,4.5,1.5,versicolor
6.9,3.1,4.9,1.5,versicolor
5.5,2.3,4,1.3,versicolor
6.5,2.8,4.6,1.5,versicolor
5.7,2.8,4.5,1.3,versicolor
6.3,3.3,4.7,1.6,versicolor
4.9,2.4,3.3,1,versicolor
6.6,2.9,4.6,1.3,versicolor
5.2,2.7,3.9,1.4,versicolor
5,2,3.5,1,versicolor
5.9,3,4.2,1.5,versicolor
6,2.2,4,1,versicolor
6.1,2.9,4.7,1.4,versicolor
5.6,2.9,3.6,1.3,versicolor
6.7,3.1,4.4,1.4,versicolor
5.6,3,4.5,1.5,versicolor
5.8,2.7,4.1,1,versicolor
6.2,2.2,4.5,1.5,versicolor
5.6,2.5,3.9,1.1,versicolor
5.9,3.2,4.8,1.8,versicolor
6.1,2.8,4,1.3,versicolor
6.3,2.5,4.9,1.5,versicolor
6.1,2.8,4.7,1.2,versicolor
6.4,2.9,4.3,1.3,versicolor
6.6,3,4.4,1.4,versicolor
6.8,2.8,4.8,1.4,versicolor
6.7,3,5,1.7,versicolor
6,2.9,4.5,1.5,versicolor
5.7,2.6,3.5,1,versicolor
5.5,2.4,3.8,1.1,versicolor
5.5,2.4,3.7,1,versicolor
5.8,2.7,3.9,1.2,versicolor
6,2.7,5.1,1.6,versicolor
5.4,3,4.5,1.5,versicolor
6,3.4,4.5,1.6,versicolor
6.7,3.1,4.7,1.5,versicolor
6.3,2.3,4.4,1.3,versicolor
5.6,3,4.1,1.3,versicolor
5.5,2.5,4,1.3,versicolor
5.5,2.6,4.4,1.2,versicolor
6.1,3,4.6,1.4,versicolor
5.8,2.6,4,1.2,versicolor
5,2.3,3.3,1,versicolor
5.6,2.7,4.2,1.3,versicolor
5.7,3,4.2,1.2,versicolor
5.7,2.9,4.2,1.3,versicolor
6.2,2.9,4.3,1.3,versicolor
5.1,2.5,3,1.1,versicolor
5.7,2.8,4.1,1.3,versicolor
6.3,3.3,6,2.5,virginica
5.8,2.7,5.1,1.9,virginica
7.1,3,5.9,2.1,virginica
6.3,2.9,5.6,1.8,virginica
6.5,3,5.8,2.2,virginica
7.6,3,6.6,2.1,virginica
4.9,2.5,4.5,1.7,virginica
7.3,2.9,6.3,1.8,virginica
6.7,2.5,5.8,1.8,virginica
7.2,3.6,6.1,2.5,virginica
6.5,3.2,5.1,2,virginica
6.4,2.7,5.3,1.9,virginica
6.8,3,5.5,2.1,virginica
5.7,2.5,5,2,virginica
5.8,2.8,5.1,2.4,virginica
6.4,3.2,5.3,2.3,virginica
6.5,3,5.5,1.8,virginica
7.7,3.8,6.7,2.2,virginica
7.7,2.6,6.9,2.3,virginica
6,2.2,5,1.5,virginica
6.9,3.2,5.7,2.3,virginica
5.6,2.8,4.9,2,virginica
7.7,2.8,6.7,2,virginica
6.3,2.7,4.9,1.8,virginica
6.7,3.3,5.7,2.1,virginica
7.2,3.2,6,1.8,virginica
6.2,2.8,4.8,1.8,virginica
6.1,3,4.9,1.8,virginica
6.4,2.8,5.6,2.1,virginica
7.2,3,5.8,1.6,virginica
7.4,2.8,6.1,1.9,virginica
7.9,3.8,6.4,2,virginica
6.4,2.8,5.6,2.2,virginica
6.3,2.8,5.1,1.5,virginica
6.1,2.6,5.6,1.4,virginica
7.7,3,6.1,2.3,virginica
6.3,3.4,5.6,2.4,virginica
6.4,3.1,5.5,1.8,virginica
6,3,4.8,1.8,virginica
6.9,3.1,5.4,2.1,virginica
6.7,3.1,5.6,2.4,virginica
6.9,3.1,5.1,2.3,virginica
5.8,2.7,5.1,1.9,virginica
6.8,3.2,5.9,2.3,virginica
6.7,3.3,5.7,2.5,virginica
6.7,3,5.2,2.3,virginica
6.3,2.5,5,1.9,virginica
6.5,3,5.2,2,virginica
6.2,3.4,5.4,2.3,virginica
5.9,3,5.1,1.8,virginica
1 sepal_length sepal_width petal_length petal_width species
2 5.1 3.5 1.4 0.2 se
3 4.9 3 1.4 0.2 setosa
4 4.7 3.2 1.3 0.2 setosa
5 4.6 3.1 1.5 0.2 setosa
6 5 3.6 1.4 0.2 setosa
7 5.4 3.9 1.7 0.4 setosa
8 4.6 3.4 1.4 0.3 setosa
9 5 3.4 1.5 0.2 setosa
10 4.4 2.9 1.4 0.2 setosa
11 4.9 3.1 1.5 0.1 setosa
12 5.4 3.7 1.5 0.2 setosa
13 4.8 3.4 1.6 0.2 setosa
14 4.8 3 1.4 0.1 setosa
15 4.3 3 1.1 0.1 setosa
16 5.8 4 1.2 0.2 setosa
17 5.7 4.4 1.5 0.4 setosa
18 5.4 3.9 1.3 0.4 setosa
19 5.1 3.5 1.4 0.3 setosa
20 5.7 3.8 1.7 0.3 setosa
21 5.1 3.8 1.5 0.3 setosa
22 5.4 3.4 1.7 0.2 setosa
23 5.1 3.7 1.5 0.4 setosa
24 4.6 3.6 1 0.2 setosa
25 5.1 3.3 1.7 0.5 setosa
26 4.8 3.4 1.9 0.2 setosa
27 5 3 1.6 0.2 setosa
28 5 3.4 1.6 0.4 setosa
29 5.2 3.5 1.5 0.2 setosa
30 5.2 3.4 1.4 0.2 setosa
31 4.7 3.2 1.6 0.2 setosa
32 4.8 3.1 1.6 0.2 setosa
33 5.4 3.4 1.5 0.4 setosa
34 5.2 4.1 1.5 0.1 setosa
35 5.5 4.2 1.4 0.2 setosa
36 4.9 3.1 1.5 0.1 setosa
37 5 3.2 1.2 0.2 setosa
38 5.5 3.5 1.3 0.2 setosa
39 4.9 3.1 1.5 0.1 setosa
40 4.4 3 1.3 0.2 setosa
41 5.1 3.4 1.5 0.2 setosa
42 5 3.5 1.3 0.3 setosa
43 4.5 2.3 1.3 0.3 setosa
44 4.4 3.2 1.3 0.2 setosa
45 5 3.5 1.6 0.6 setosa
46 5.1 3.8 1.9 0.4 setosa
47 4.8 3 1.4 0.3 setosa
48 5.1 3.8 1.6 0.2 setosa
49 4.6 3.2 1.4 0.2 setosa
50 5.3 3.7 1.5 0.2 setosa
51 5 3.3 1.4 0.2 setosa
52 7 3.2 4.7 1.4 versicolor
53 6.4 3.2 4.5 1.5 versicolor
54 6.9 3.1 4.9 1.5 versicolor
55 5.5 2.3 4 1.3 versicolor
56 6.5 2.8 4.6 1.5 versicolor
57 5.7 2.8 4.5 1.3 versicolor
58 6.3 3.3 4.7 1.6 versicolor
59 4.9 2.4 3.3 1 versicolor
60 6.6 2.9 4.6 1.3 versicolor
61 5.2 2.7 3.9 1.4 versicolor
62 5 2 3.5 1 versicolor
63 5.9 3 4.2 1.5 versicolor
64 6 2.2 4 1 versicolor
65 6.1 2.9 4.7 1.4 versicolor
66 5.6 2.9 3.6 1.3 versicolor
67 6.7 3.1 4.4 1.4 versicolor
68 5.6 3 4.5 1.5 versicolor
69 5.8 2.7 4.1 1 versicolor
70 6.2 2.2 4.5 1.5 versicolor
71 5.6 2.5 3.9 1.1 versicolor
72 5.9 3.2 4.8 1.8 versicolor
73 6.1 2.8 4 1.3 versicolor
74 6.3 2.5 4.9 1.5 versicolor
75 6.1 2.8 4.7 1.2 versicolor
76 6.4 2.9 4.3 1.3 versicolor
77 6.6 3 4.4 1.4 versicolor
78 6.8 2.8 4.8 1.4 versicolor
79 6.7 3 5 1.7 versicolor
80 6 2.9 4.5 1.5 versicolor
81 5.7 2.6 3.5 1 versicolor
82 5.5 2.4 3.8 1.1 versicolor
83 5.5 2.4 3.7 1 versicolor
84 5.8 2.7 3.9 1.2 versicolor
85 6 2.7 5.1 1.6 versicolor
86 5.4 3 4.5 1.5 versicolor
87 6 3.4 4.5 1.6 versicolor
88 6.7 3.1 4.7 1.5 versicolor
89 6.3 2.3 4.4 1.3 versicolor
90 5.6 3 4.1 1.3 versicolor
91 5.5 2.5 4 1.3 versicolor
92 5.5 2.6 4.4 1.2 versicolor
93 6.1 3 4.6 1.4 versicolor
94 5.8 2.6 4 1.2 versicolor
95 5 2.3 3.3 1 versicolor
96 5.6 2.7 4.2 1.3 versicolor
97 5.7 3 4.2 1.2 versicolor
98 5.7 2.9 4.2 1.3 versicolor
99 6.2 2.9 4.3 1.3 versicolor
100 5.1 2.5 3 1.1 versicolor
101 5.7 2.8 4.1 1.3 versicolor
102 6.3 3.3 6 2.5 virginica
103 5.8 2.7 5.1 1.9 virginica
104 7.1 3 5.9 2.1 virginica
105 6.3 2.9 5.6 1.8 virginica
106 6.5 3 5.8 2.2 virginica
107 7.6 3 6.6 2.1 virginica
108 4.9 2.5 4.5 1.7 virginica
109 7.3 2.9 6.3 1.8 virginica
110 6.7 2.5 5.8 1.8 virginica
111 7.2 3.6 6.1 2.5 virginica
112 6.5 3.2 5.1 2 virginica
113 6.4 2.7 5.3 1.9 virginica
114 6.8 3 5.5 2.1 virginica
115 5.7 2.5 5 2 virginica
116 5.8 2.8 5.1 2.4 virginica
117 6.4 3.2 5.3 2.3 virginica
118 6.5 3 5.5 1.8 virginica
119 7.7 3.8 6.7 2.2 virginica
120 7.7 2.6 6.9 2.3 virginica
121 6 2.2 5 1.5 virginica
122 6.9 3.2 5.7 2.3 virginica
123 5.6 2.8 4.9 2 virginica
124 7.7 2.8 6.7 2 virginica
125 6.3 2.7 4.9 1.8 virginica
126 6.7 3.3 5.7 2.1 virginica
127 7.2 3.2 6 1.8 virginica
128 6.2 2.8 4.8 1.8 virginica
129 6.1 3 4.9 1.8 virginica
130 6.4 2.8 5.6 2.1 virginica
131 7.2 3 5.8 1.6 virginica
132 7.4 2.8 6.1 1.9 virginica
133 7.9 3.8 6.4 2 virginica
134 6.4 2.8 5.6 2.2 virginica
135 6.3 2.8 5.1 1.5 virginica
136 6.1 2.6 5.6 1.4 virginica
137 7.7 3 6.1 2.3 virginica
138 6.3 3.4 5.6 2.4 virginica
139 6.4 3.1 5.5 1.8 virginica
140 6 3 4.8 1.8 virginica
141 6.9 3.1 5.4 2.1 virginica
142 6.7 3.1 5.6 2.4 virginica
143 6.9 3.1 5.1 2.3 virginica
144 5.8 2.7 5.1 1.9 virginica
145 6.8 3.2 5.9 2.3 virginica
146 6.7 3.3 5.7 2.5 virginica
147 6.7 3 5.2 2.3 virginica
148 6.3 2.5 5 1.9 virginica
149 6.5 3 5.2 2 virginica
150 6.2 3.4 5.4 2.3 virginica
151 5.9 3 5.1 1.8 virginica

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,249 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# The Lorenz Differential Equations"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Before we start, we import some preliminary libraries."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"trusted": true
},
"outputs": [],
"source": [
"import numpy as np\n",
"from matplotlib import pyplot as plt\n",
"from scipy import integrate\n",
"\n",
"from ipywidgets import interactive"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We will also define the actual solver and plotting routine."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"trusted": true
},
"outputs": [],
"source": [
"def solve_lorenz(sigma=10.0, beta=8./3, rho=28.0):\n",
" \"\"\"Plot a solution to the Lorenz differential equations.\"\"\"\n",
"\n",
" max_time = 4.0\n",
" N = 30\n",
"\n",
" fig = plt.figure(1)\n",
" ax = fig.add_axes([0, 0, 1, 1], projection='3d')\n",
" ax.axis('off')\n",
"\n",
" # prepare the axes limits\n",
" ax.set_xlim((-25, 25))\n",
" ax.set_ylim((-35, 35))\n",
" ax.set_zlim((5, 55))\n",
"\n",
" def lorenz_deriv(x_y_z, t0, sigma=sigma, beta=beta, rho=rho):\n",
" \"\"\"Compute the time-derivative of a Lorenz system.\"\"\"\n",
" x, y, z = x_y_z\n",
" return [sigma * (y - x), x * (rho - z) - y, x * y - beta * z]\n",
"\n",
" # Choose random starting points, uniformly distributed from -15 to 15\n",
" np.random.seed(1)\n",
" x0 = -15 + 30 * np.random.random((N, 3))\n",
"\n",
" # Solve for the trajectories\n",
" t = np.linspace(0, max_time, int(250*max_time))\n",
" x_t = np.asarray([integrate.odeint(lorenz_deriv, x0i, t)\n",
" for x0i in x0])\n",
"\n",
" # choose a different color for each trajectory\n",
" colors = plt.cm.viridis(np.linspace(0, 1, N))\n",
"\n",
" for i in range(N):\n",
" x, y, z = x_t[i,:,:].T\n",
" lines = ax.plot(x, y, z, '-', c=colors[i])\n",
" plt.setp(lines, linewidth=2)\n",
" angle = 104\n",
" ax.view_init(30, angle)\n",
" plt.show()\n",
"\n",
" return t, x_t"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We explore the Lorenz system of differential equations:\n",
"\n",
"$$\n",
"\\begin{aligned}\n",
"\\dot{x} & = \\sigma(y-x) \\\\\n",
"\\dot{y} & = \\rho x - y - xz \\\\\n",
"\\dot{z} & = -\\beta z + xy\n",
"\\end{aligned}\n",
"$$\n",
"\n",
"Let's change (\\\\(\\sigma\\\\), \\\\(\\beta\\\\), \\\\(\\rho\\\\)) with ipywidgets and examine the trajectories."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"trusted": true
},
"outputs": [],
"source": [
"w=interactive(solve_lorenz,sigma=(0.0,50.0),rho=(0.0,50.0))\n",
"w"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For the default set of parameters, we see the trajectories swirling around two points, called attractors. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The object returned by `interactive` is a `Widget` object and it has attributes that contain the current result and arguments:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"trusted": true
},
"outputs": [],
"source": [
"t, x_t = w.result"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"trusted": true
},
"outputs": [],
"source": [
"w.kwargs"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"After interacting with the system, we can take the result and perform further computations. In this case, we compute the average positions in \\\\(x\\\\), \\\\(y\\\\) and \\\\(z\\\\)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"trusted": true
},
"outputs": [],
"source": [
"xyz_avg = x_t.mean(axis=1)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"trusted": true
},
"outputs": [],
"source": [
"xyz_avg.shape"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Creating histograms of the average positions (across different trajectories) show that, on average, the trajectories swirl about the attractors."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"trusted": true
},
"outputs": [],
"source": [
"from matplotlib import pyplot as plt\n",
"%matplotlib inline"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"trusted": true
},
"outputs": [],
"source": [
"plt.hist(xyz_avg[:,0])\n",
"plt.title('Average $x(t)$');"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"trusted": true
},
"outputs": [],
"source": [
"plt.hist(xyz_avg[:,1])\n",
"plt.title('Average $y(t)$');"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python (XPython)",
"language": "python",
"name": "xpython"
},
"language_info": {
"codemirror_mode": {
"name": "python",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,588 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "472d1671-a068-4ce5-afae-076586f0b1b3",
"metadata": {},
"source": [
"<center>\n",
" <h1>Interactive Demos of C++ Libraries in the Browser</h1>\n",
" <h3>Powered by Xeus-Cpp-Lite and WebAssembly</h3>\n",
"</center>\n",
"\n",
"This notebook demonstrates several powerful C++ libraries running entirely in the browser using **xeus-cpp-lite**. The examples span symbolic computation, numerical analysis, interactive visualization, and more — all compiled to WebAssembly and ready to run in a JupyterLite environment.\n",
"\n",
"**Featured libraries:**\n",
"\n",
"1. **Scientific Computation (Symbolic & Numeric)**: `boost`, `symengine`, `openblas`\n",
"2. **Array based Computation through Xtensor-stack**: `xtl`, `xtensor`, `xsimd`, `xtensor-blas`\n",
"3. **Utilities & Miscellaneous**: `nlohmann_json`, and others"
]
},
{
"cell_type": "markdown",
"id": "c5f00d53-7cc9-43fb-82c7-c69b631e7b92",
"metadata": {},
"source": [
"## Scientific Computation (Symbolic & Numeric)\n",
"\n",
"Lets begin with powerful C++ libraries for symbolic math, high-precision arithmetic, and efficient numerical computation using BLAS and LAPACK routines."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "7ef2ba09-bcc8-41e2-b503-3b21e60fdd3e",
"metadata": {
"trusted": true,
"vscode": {
"languageId": "c++"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Product of 98745636214564698 * 7459874565236544789 = \n",
"736630060025131838840151335215258722"
]
}
],
"source": [
"#include <boost/multiprecision/cpp_int.hpp>\n",
"using namespace boost::multiprecision;\n",
"using namespace std;\n",
"\n",
"int128_t boost_product(long long A, long long B)\n",
"{\n",
" int128_t ans = (int128_t)A * B;\n",
" return ans;\n",
"}\n",
"\n",
"long long first = 98745636214564698;\n",
"long long second = 7459874565236544789;\n",
"cout << \"Product of \" << first << \" * \" << second << \" = \\n\"\n",
" << boost_product(first, second);"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "d8e235a1-5d41-43f8-8908-9f76b4c6c1d7",
"metadata": {
"trusted": true,
"vscode": {
"languageId": "c++"
}
},
"outputs": [],
"source": [
"#include <symengine/expression.h>\n",
"\n",
"using namespace SymEngine;\n",
"\n",
"Expression x(\"x\");\n",
"auto ex = pow(x + sqrt(Expression(2)), 6);"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "82912670-8abf-4364-8bfb-b55e206fb153",
"metadata": {
"trusted": true,
"vscode": {
"languageId": "c++"
}
},
"outputs": [
{
"data": {
"text/latex": [
"$\\left(x + \\sqrt{2}\\right)^6$"
],
"text/plain": [
"(x + sqrt(2))**6"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"#include <xcpp/xdisplay.hpp>\n",
"xcpp::display(ex);"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "f738315b-f1ed-48b8-ae71-250b3667c694",
"metadata": {
"trusted": true,
"vscode": {
"languageId": "c++"
}
},
"outputs": [
{
"data": {
"text/latex": [
"$8 + 24 \\sqrt{2} x + 40 \\sqrt{2} x^3 + 6 \\sqrt{2} x^5 + 60 x^2 + 30 x^4 + x^6$"
],
"text/plain": [
"8 + 24*sqrt(2)*x + 40*sqrt(2)*x**3 + 6*sqrt(2)*x**5 + 60*x**2 + 30*x**4 + x**6"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"auto expanded_ex = expand(ex);\n",
"xcpp::display(expanded_ex);"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "f25ec9b7-951e-4494-b932-64d71a601127",
"metadata": {
"trusted": true,
"vscode": {
"languageId": "c++"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"LU Decomposition (OpenBLAS dgetrf_)\n",
"info: 0\n",
"\n",
"Factorized Matrix (A after dgetrf_):\n",
" 3.000000 6.000000 10.000000\n",
" 0.333333 2.000000 3.666667\n",
" 0.666667 0.500000 -0.500000\n",
"\n",
"Pivot Indices:\n",
"3 3 3 \n"
]
}
],
"source": [
"#include <iostream>\n",
"#include <iomanip>\n",
"\n",
"typedef int INTEGER;\n",
"typedef double DOUBLE;\n",
"\n",
"extern \"C\" {\n",
" int dgetrf_(const INTEGER* m, const INTEGER* n, DOUBLE* a,\n",
" const INTEGER* lda, INTEGER* ipiv, INTEGER* info);\n",
"}\n",
"\n",
"const INTEGER m = 3, n = 3, lda = 3;\n",
"DOUBLE A[9] = {\n",
" 1.0, 2.0, 3.0,\n",
" 4.0, 5.0, 6.0,\n",
" 7.0, 8.0, 10.0\n",
"}; // Column-major layout\n",
"\n",
"INTEGER ipiv[3];\n",
"INTEGER info;\n",
"\n",
"dgetrf_(&m, &n, A, &lda, ipiv, &info);\n",
"\n",
"// Output\n",
"std::cout << std::fixed << std::setprecision(6);\n",
"std::cout << \"LU Decomposition (OpenBLAS dgetrf_)\\n\";\n",
"std::cout << \"info: \" << info << \"\\n\\n\";\n",
"\n",
"std::cout << \"Factorized Matrix (A after dgetrf_):\\n\";\n",
"for (int i = 0; i < m; ++i) {\n",
" for (int j = 0; j < n; ++j)\n",
" std::cout << std::setw(10) << A[i + j * lda];\n",
" std::cout << \"\\n\";\n",
"}\n",
"\n",
"std::cout << \"\\nPivot Indices:\\n\";\n",
"for (int i = 0; i < std::min(m, n); ++i)\n",
" std::cout << ipiv[i] << \" \";\n",
"std::cout << \"\\n\";\n"
]
},
{
"cell_type": "markdown",
"id": "6b7e64a2-546c-47a7-b4ed-95e98febd785",
"metadata": {},
"source": [
"## Array based Computation through Xtensor-stack\n",
"\n",
"Explore NumPy-style array computing in C++ with Xtensor, Xtensor-BLAS, and Xsimd — enabling high-performance numerical and SIMD-accelerated workflows."
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "6496d5e7-d1e5-4437-be87-bb26b48ce735",
"metadata": {
"trusted": true,
"vscode": {
"languageId": "c++"
}
},
"outputs": [
{
"data": {
"text/html": [
"<table style='border-style:solid;border-width:1px;'><tbody><tr><td style='font-family:monospace;' title='0'><pre> 7.</pre></td></tr><tr><td style='font-family:monospace;' title='1'><pre> 11.</pre></td></tr><tr><td style='font-family:monospace;' title='2'><pre> 14.</pre></td></tr></tbody></table>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"#include \"xtensor/containers/xarray.hpp\"\n",
"#include \"xtensor/io/xio.hpp\"\n",
"#include \"xtensor/views/xview.hpp\"\n",
"\n",
"xt::xarray<double> arr1 = {{1.0, 2.0, 3.0}, {2.0, 5.0, 7.0}, {2.0, 5.0, 7.0}};\n",
"xt::xarray<double> arr2{5.0, 6.0, 7.0};\n",
"\n",
"xcpp::display(xt::view(arr1, 1) + arr2);"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "c748227d-4083-4c19-8f07-a449d41e67fe",
"metadata": {
"trusted": true,
"vscode": {
"languageId": "c++"
}
},
"outputs": [
{
"data": {
"text/html": [
"<table style='border-style:solid;border-width:1px;'><tbody><tr><td style='font-family:monospace;' title='(0, 0)'><pre>1</pre></td><td style='font-family:monospace;' title='(0, 1)'><pre>2</pre></td><td style='font-family:monospace;' title='(0, 2)'><pre>3</pre></td></tr><tr><td style='font-family:monospace;' title='(1, 0)'><pre>4</pre></td><td style='font-family:monospace;' title='(1, 1)'><pre>5</pre></td><td style='font-family:monospace;' title='(1, 2)'><pre>6</pre></td></tr><tr><td style='font-family:monospace;' title='(2, 0)'><pre>7</pre></td><td style='font-family:monospace;' title='(2, 1)'><pre>8</pre></td><td style='font-family:monospace;' title='(2, 2)'><pre>9</pre></td></tr></tbody></table>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"xt::xarray<int> arr = {1, 2, 3, 4, 5, 6, 7, 8, 9};\n",
"arr.reshape({3, 3});\n",
"\n",
"xcpp::display(arr);"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "74298554-9964-4633-bff3-e67d03a1797d",
"metadata": {
"trusted": true,
"vscode": {
"languageId": "c++"
}
},
"outputs": [],
"source": [
"#include <iostream>\n",
"#include \"xtensor-blas/xlinalg.hpp\"\n",
"\n",
"xt::xtensor<double, 2> M = {{1.5, 0.5}, {0.7, 1.0}};"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "22dadb84-d39e-4028-a919-febd64f4a60d",
"metadata": {
"trusted": true,
"vscode": {
"languageId": "c++"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Matrix rank: 2\n",
"Matrix inverse: \n"
]
},
{
"data": {
"text/html": [
"<table style='border-style:solid;border-width:1px;'><tbody><tr><td style='font-family:monospace;' title='(0, 0)'><pre> 0.869565</pre></td><td style='font-family:monospace;' title='(0, 1)'><pre>-0.434783</pre></td></tr><tr><td style='font-family:monospace;' title='(1, 0)'><pre>-0.608696</pre></td><td style='font-family:monospace;' title='(1, 1)'><pre> 1.304348</pre></td></tr></tbody></table>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Eigen values: \n"
]
},
{
"data": {
"text/html": [
"<table style='border-style:solid;border-width:1px;'><tbody><tr><td style='font-family:monospace;' title='0'><pre> 1.892262+0.i</pre></td></tr><tr><td style='font-family:monospace;' title='1'><pre> 0.607738+0.i</pre></td></tr></tbody></table>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"std::cout << \"Matrix rank: \" << xt::linalg::matrix_rank(M) << std::endl;\n",
"std::cout << \"Matrix inverse: \" << std::endl;\n",
"xcpp::display(xt::linalg::inv(M));\n",
"std::cout << \"Eigen values: \" << std::endl;\n",
"xcpp::display(xt::linalg::eigvals(M));"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "d8e9e9e7-5def-4d77-b459-afb8002282ae",
"metadata": {
"trusted": true,
"vscode": {
"languageId": "c++"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(3.300000, 7.700000, 12.100000, 16.500000)\n"
]
}
],
"source": [
"#include <xsimd/xsimd.hpp>\n",
"\n",
"namespace xs = xsimd;\n",
"\n",
"// Define two SIMD float vectors using the wasm backend\n",
"xs::batch<float, xs::wasm> X = {1.2f, 3.4f, 5.6f, 7.8f};\n",
"xs::batch<float, xs::wasm> Y = {2.1f, 4.3f, 6.5f, 8.7f};\n",
"\n",
"// Perform SIMD addition\n",
"xs::batch<float, xs::wasm> Z = X + Y;\n",
"\n",
"// Print the result\n",
"std::cout << Z << std::endl;"
]
},
{
"cell_type": "markdown",
"id": "0f0978c4-7ec4-4615-894a-c6558503d851",
"metadata": {},
"source": [
"## Miscallaneous\n",
"\n",
"Feel free to explore other useful C++ libraries in the browser, like nlohmann_json, pugixml, xtl etc"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "2ce27d4d-43f7-464c-a611-5400c3cdb735",
"metadata": {
"trusted": true,
"vscode": {
"languageId": "c++"
}
},
"outputs": [],
"source": [
"#include \"nlohmann/json.hpp\"\n",
"\n",
"nlohmann::json jsonObject;\n",
"\n",
"jsonObject[\"name\"] = \"John Doe\";\n",
"jsonObject[\"age\"] = 30;\n",
"jsonObject[\"is_student\"] = false;\n",
"jsonObject[\"skills\"] = {\"C++\", \"Python\", \"JavaScript\"};\n",
"\n",
"std::cout << jsonObject.dump(4) << std::endl;"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "36b1b0f7-00d9-47bf-8543-985e27088d07",
"metadata": {
"trusted": true,
"vscode": {
"languageId": "c++"
}
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 13,
"id": "b2647bb5-0c2e-4f12-b0ed-0c0f5c7ed65c",
"metadata": {
"trusted": true,
"vscode": {
"languageId": "c++"
}
},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "07f19b34aac74f97947e4e9b068ebe5f",
"version_major": 2,
"version_minor": 1
},
"text/plain": [
"A Jupyter widget with unique id: 07f19b34aac74f97947e4e9b068ebe5f"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": []
},
{
"cell_type": "code",
"execution_count": 14,
"id": "0f3e4dcb-5d9f-479b-b568-8d7625683946",
"metadata": {
"trusted": true,
"vscode": {
"languageId": "c++"
}
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 15,
"id": "1eed2b39-b632-440c-9d3d-c8d377bc504c",
"metadata": {
"trusted": true,
"vscode": {
"languageId": "c++"
}
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 16,
"id": "4d1797e5-3ce1-4737-9561-a87a7e82cce1",
"metadata": {
"trusted": true,
"vscode": {
"languageId": "c++"
}
},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "e34c45cc453240cebac33426cd7c448d",
"version_major": 2,
"version_minor": 1
},
"text/plain": [
"A Jupyter widget with unique id: e34c45cc453240cebac33426cd7c448d"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": []
},
{
"cell_type": "markdown",
"id": "d26a70d2-9dc6-4ca0-b974-2cfd4249a8a7",
"metadata": {},
"source": []
},
{
"cell_type": "code",
"execution_count": 17,
"id": "e1fdb4b5-384a-42a1-80c1-ba2bcd515e01",
"metadata": {
"trusted": true,
"vscode": {
"languageId": "c++"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{\n",
" \"age\": 30,\n",
" \"is_student\": false,\n",
" \"name\": \"John Doe\",\n",
" \"skills\": [\n",
" \"C++\",\n",
" \"Python\",\n",
" \"JavaScript\"\n",
" ]\n",
"}\n"
]
}
],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "ed69c0cd-c65a-47d7-9ee2-13502953e876",
"metadata": {
"trusted": true,
"vscode": {
"languageId": "c++"
}
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "C++23",
"language": "cpp",
"name": "xcpp23"
},
"language_info": {
"codemirror_mode": "text/x-c++src",
"file_extension": ".cpp",
"mimetype": "text/x-c++src",
"name": "C++",
"version": "23"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,276 @@
{
"metadata": {
"kernelspec": {
"name": "xr",
"display_name": "R 4.4.3 (xr)",
"language": "R"
},
"language_info": {
"codemirror_mode": "",
"file_extension": "R",
"mimetype": "text/x-R",
"name": "R",
"nbconvert_exporter": "",
"pygments_lexer": "",
"version": "4.4.3"
}
},
"nbformat_minor": 4,
"nbformat": 4,
"cells": [
{
"cell_type": "markdown",
"source": "# XEUS-R",
"metadata": {}
},
{
"cell_type": "code",
"source": "R.version",
"metadata": {
"trusted": true,
"vscode": {
"languageId": "r"
}
},
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
"source": "## Internal packages",
"metadata": {}
},
{
"cell_type": "code",
"source": "library(stats)\n\nset.seed(123)\nx <- rnorm(100)\ny <- 2 * x + rnorm(100)\n\n# Linear regression\nmodel <- lm(y ~ x)\nsummary(model)",
"metadata": {
"trusted": true,
"vscode": {
"languageId": "r"
}
},
"outputs": [],
"execution_count": null
},
{
"cell_type": "code",
"source": "A <- matrix(c(1, 2, 3, 4, 5, 6), nrow = 3, ncol = 2)\n\n# Singular value decomposition\nsvd_result <- La.svd(A)\n\nprint(svd_result)",
"metadata": {
"trusted": true,
"vscode": {
"languageId": "r"
}
},
"outputs": [],
"execution_count": null
},
{
"cell_type": "code",
"source": "A <- matrix(c(4, 1, 1, 3), nrow = 2, byrow = TRUE)\n\n# Eigen decomposition\neigen_result <- eigen(A)\n\nprint(eigen_result$values)\n\nprint(eigen_result$vectors)",
"metadata": {
"trusted": true,
"vscode": {
"languageId": "r"
}
},
"outputs": [],
"execution_count": null
},
{
"cell_type": "code",
"source": "# Example positive-definite matrix\nA <- matrix(c(4, 1, 1, 3), nrow = 2, byrow = TRUE)\n\n# Cholesky decomposition\nchol_result <- chol(A)\n\nprint(chol_result)",
"metadata": {
"trusted": true,
"vscode": {
"languageId": "r"
}
},
"outputs": [],
"execution_count": null
},
{
"cell_type": "code",
"source": "B <- matrix(c(1, 2, 3, 4, 5, 6), nrow = 3, ncol = 2)\nC <- matrix(c(7, 8, 9, 10, 11, 12), nrow = 3, ncol = 2)\n\n# Perform matrix multiplication using BLAS\nresult <- crossprod(B, C)\n\nprint(result)",
"metadata": {
"trusted": true,
"vscode": {
"languageId": "r"
}
},
"outputs": [],
"execution_count": null
},
{
"cell_type": "code",
"source": "# Fibonacci sequence\nfibonacci_loop <- function(n) {\n a <- 0\n b <- 1\n\n for (i in 1:n) {\n fib <- a\n cat(fib, \"\\n\")\n a <- b\n b <- fib + b\n }\n return(a)\n}\n\nfibonacci_loop(10)",
"metadata": {
"trusted": true,
"vscode": {
"languageId": "r"
}
},
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
"source": "## Plotting",
"metadata": {}
},
{
"cell_type": "markdown",
"source": "Some of the following R Code was pulled from https://www.statmethods.net/advgraphs/ggplot2.html, and updated to use newer `ggplot2` APIs.",
"metadata": {}
},
{
"cell_type": "code",
"source": "# ggplot2 examples\nlibrary(ggplot2)",
"metadata": {
"vscode": {
"languageId": "r"
},
"trusted": true
},
"outputs": [],
"execution_count": null
},
{
"cell_type": "code",
"source": "# create factors with value labels\nmtcars$gear <- factor(mtcars$gear,levels=c(3,4,5),\n \tlabels=c(\"3gears\",\"4gears\",\"5gears\"))\nmtcars$am <- factor(mtcars$am,levels=c(0,1),\n \tlabels=c(\"Automatic\",\"Manual\"))\nmtcars$cyl <- factor(mtcars$cyl,levels=c(4,6,8),\n labels=c(\"4cyl\",\"6cyl\",\"8cyl\"))",
"metadata": {
"vscode": {
"languageId": "r"
},
"trusted": true
},
"outputs": [],
"execution_count": null
},
{
"cell_type": "code",
"source": "# Kernel density plots for mpg\n# grouped by number of gears (indicated by color)\nggplot(mtcars, aes(x = mpg, fill = gear)) +\n geom_density(alpha = 0.5) +\n labs(\n title = \"Distribution of Gas Milage\",\n x = \"Miles Per Gallon\",\n y = \"Density\",\n fill = \"Gears\"\n )",
"metadata": {
"vscode": {
"languageId": "r"
},
"trusted": true
},
"outputs": [],
"execution_count": null
},
{
"cell_type": "code",
"source": "# Scatterplot of mpg vs. hp for each combination of gears and cylinders\n# in each facet, transmission type is represented by shape and color\nggplot(mtcars, aes(x = hp, y = mpg, shape = am, color = am)) +\n geom_point(size = 3) +\n facet_grid(gear ~ cyl) +\n labs(\n x = \"Horsepower\",\n y = \"Miles per Gallon\",\n shape = \"Transmission\",\n color = \"Transmission\"\n )",
"metadata": {
"vscode": {
"languageId": "r"
},
"trusted": true
},
"outputs": [],
"execution_count": null
},
{
"cell_type": "code",
"source": "# Separate regressions of mpg on weight for each number of cylinders\nggplot(mtcars, aes(x = wt, y = mpg, color = cyl)) +\n geom_point() +\n geom_smooth(method = \"lm\", formula = y ~ x) +\n labs(\n title = \"Regression of MPG on Weight\",\n x = \"Weight\",\n y = \"Miles per Gallon\",\n color = \"Cylinders\"\n )",
"metadata": {
"vscode": {
"languageId": "r"
},
"trusted": true
},
"outputs": [],
"execution_count": null
},
{
"cell_type": "code",
"source": "# Boxplots of mpg by number of gears\n# observations (points) are overlayed and jittered\nggplot(mtcars, aes(x = gear, y = mpg, fill = gear)) +\n geom_boxplot() +\n geom_jitter(width = 0.2) +\n labs(\n title = \"Mileage by Gear Number\",\n x = \"\",\n y = \"Miles per Gallon\",\n fill = \"Gears\"\n )",
"metadata": {
"vscode": {
"languageId": "r"
},
"trusted": true
},
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
"source": "## Other R Packages",
"metadata": {
"vscode": {
"languageId": "plaintext"
}
}
},
{
"cell_type": "code",
"source": "library(RColorBrewer)\npalette <- brewer.pal(8, \"Set3\")\nprint(palette)",
"metadata": {
"trusted": true,
"vscode": {
"languageId": "r"
}
},
"outputs": [],
"execution_count": null
},
{
"cell_type": "code",
"source": "library(crayon)\n\n# Create colorful text\nred_text <- red(\"This is red text\")\ngreen_text <- green(\"This is green text\")\nblue_text <- blue(\"This is blue text\")\nbold_text <- bold(\"This is bold text\")\nunderline_text <- underline(\"This is underlined text\")\n\ncat(red_text, \"\\n\")\ncat(green_text, \"\\n\")\ncat(blue_text, \"\\n\")\ncat(bold_text, \"\\n\")\ncat(underline_text, \"\\n\")",
"metadata": {
"trusted": true,
"vscode": {
"languageId": "r"
}
},
"outputs": [],
"execution_count": null
},
{
"cell_type": "code",
"source": "library(htmltools)\n\n# Create HMTL elements\ntitle <- tags$title(\"My HTML Page\")\nheader <- tags$h1(\"Hello there!\")\nparagraph <- tags$p(\"This is a paragraph created using htmltools.\")\nlist_items <- tags$ul(tags$li(\"Item 1\"), tags$li(\"Item 2\"), tags$li(\"Item 3\"))\n\n# Combine elements into an HTML document\nhtml_doc <- tags$html(\n tags$head(title),\n tags$body(\n header,\n paragraph,\n list_items\n )\n)\n\nprint(html_doc)",
"metadata": {
"trusted": true,
"vscode": {
"languageId": "r"
}
},
"outputs": [],
"execution_count": null
},
{
"cell_type": "code",
"source": "library(farver)\n\n# Define a color in RBG space\nrgb_color <- matrix(c(255, 0, 0), ncol = 3)\n\n# Convert RGB to HSV\nhsv_color <- convert_colour(rgb_color, \"rgb\", \"hsv\")\n\n# Convert RGB to LAB\nlab_color <- convert_colour(rgb_color, \"rgb\", \"lab\")\n\nprint(rgb_color)\nprint(hsv_color)\nprint(lab_color)",
"metadata": {
"trusted": true,
"vscode": {
"languageId": "r"
}
},
"outputs": [],
"execution_count": null
},
{
"cell_type": "code",
"source": "",
"metadata": {
"vscode": {
"languageId": "r"
},
"trusted": true
},
"outputs": [],
"execution_count": null
},
{
"cell_type": "code",
"source": "",
"metadata": {
"trusted": true
},
"outputs": [],
"execution_count": null
}
]
}

File diff suppressed because one or more lines are too long