{ "cells": [ { "cell_type": "markdown", "id": "3fe9124c-7364-44b4-90ba-30f2759ae143", "metadata": {}, "source": [ "# Test GDSL courses" ] }, { "cell_type": "markdown", "id": "efb47674-3ee0-4197-9910-f46ba73c4ad9", "metadata": {}, "source": [ "## Download" ] }, { "cell_type": "markdown", "id": "53b22e85-7a06-4105-87f5-219348bae97a", "metadata": {}, "source": [ "- [Web Mapping & Analysis](https://github.com/GDSL-UL/wma)" ] }, { "cell_type": "code", "execution_count": null, "id": "30023233-7506-4171-abad-255f4e53a131", "metadata": {}, "outputs": [], "source": [ "! wget https://github.com/GDSL-UL/wma/archive/refs/heads/main.zip \\\n", " && unzip main.zip \\\n", " && rm main.zip" ] }, { "cell_type": "markdown", "id": "ba2eef6e-d179-4664-9f3f-bb9f59aa4bf7", "metadata": {}, "source": [ "- [Spatial Modelling for Data Scientists](https://github.com/GDSL-UL/san)" ] }, { "cell_type": "code", "execution_count": null, "id": "c86a2322-605a-4c46-a28e-1178c329524a", "metadata": {}, "outputs": [], "source": [ "! wget https://github.com/GDSL-UL/san/archive/refs/heads/master.zip \\\n", " && unzip master.zip \\\n", " && rm master.zip" ] }, { "cell_type": "markdown", "id": "7028e018-f847-41f0-ac29-34862311addb", "metadata": {}, "source": [ "- [R for Population Science](https://github.com/fcorowe/r4ps)" ] }, { "cell_type": "code", "execution_count": null, "id": "681e8b3c-f5bf-4a0e-809e-0bf0ab28589f", "metadata": {}, "outputs": [], "source": [ "! wget https://github.com/fcorowe/r4ps/archive/refs/heads/main.zip \\\n", " && unzip main.zip \\\n", " && rm main.zip" ] }, { "cell_type": "markdown", "id": "5846b86e-3416-4b60-965c-ca5258d611c1", "metadata": {}, "source": [ "## Test SMDS" ] }, { "cell_type": "code", "execution_count": 4, "id": "75f1ad6d-6be9-4d62-aa64-fc0970e770ae", "metadata": { "collapsed": true, "jupyter": { "outputs_hidden": true }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[ 1/13] index.qmd\u001b[39m\u001b[22m\n", "[ 2/13] 01-overview.qmd\u001b[39m\u001b[22m\n", "\u001b[31m\n", "\n", "processing file: 01-overview.qmd\n", " \n", "\u001b[31moutput file: 01-overview.knit.md\n", "\n", "\u001b[39m\u001b[31m\n", "\n", "processing file: 01-overview.qmd\n", " \n", "\u001b[31moutput file: 01-overview.knit.md\n", "\n", "[ 3/13] 02-spatial_data.qmd\u001b[39m\u001b[22m\n", "\u001b[31m\n", "\n", "processing file: 02-spatial_data.qmd\n", " \n", "\u001b[31moutput file: 02-spatial_data.knit.md\n", "\n", "\u001b[39m\u001b[31m\n", "\n", "processing file: 02-spatial_data.qmd\n", " \n", "\u001b[31moutput file: 02-spatial_data.knit.md\n", "\n", "[ 4/13] 03-data-wrangling.qmd\u001b[39m\u001b[22m\n", "\u001b[31m\n", "\n", "processing file: 03-data-wrangling.qmd\n", " |. | 2% (unnamed-chunk-1) \u001b[31mSystem has not been booted with systemd as init system (PID 1). Can't operate.\n", "Failed to connect to bus: Host is down\n", " \n", "\u001b[31moutput file: 03-data-wrangling.knit.md\n", "\n", "\u001b[39m\u001b[31m\n", "\n", "processing file: 03-data-wrangling.qmd\n", " |. | 2% (unnamed-chunk-1) \u001b[31mSystem has not been booted with systemd as init system (PID 1). Can't operate.\n", "Failed to connect to bus: Host is down\n", " \n", "\u001b[31moutput file: 03-data-wrangling.knit.md\n", "\n", "[ 5/13] 04-points.qmd\u001b[39m\u001b[22m\n", "\u001b[31m\n", "\n", "processing file: 04-points.qmd\n", " \n", "\u001b[31moutput file: 04-points.knit.md\n", "\n", "\u001b[39m\u001b[31m\n", "\n", "processing file: 04-points.qmd\n", " \n", "\u001b[31moutput file: 04-points.knit.md\n", "\n", "[ 6/13] 05-flows.qmd\u001b[39m\u001b[22m\n", "\u001b[31m\n", "\n", "processing file: 05-flows.qmd\n", " |. | 3% (unnamed-chunk-1) \u001b[31mSystem has not been booted with systemd as init system (PID 1). Can't operate.\n", "\u001b[39m\u001b[31mFailed to connect to bus: Host is down\n", " \n", "\u001b[31moutput file: 05-flows.knit.md\n", "\n", "\u001b[39m\u001b[31m\n", "\n", "processing file: 05-flows.qmd\n", " |. | 3% (unnamed-chunk-1) \u001b[31mSystem has not been booted with systemd as init system (PID 1). Can't operate.\n", "Failed to connect to bus: Host is down\n", " \n", "\u001b[31moutput file: 05-flows.knit.md\n", "\n", "[ 7/13] 06-spatial-econometrics.qmd\u001b[39m\u001b[22m\n", "\u001b[31m\n", "\n", "processing file: 06-spatial-econometrics.qmd\n", " \n", "\u001b[31moutput file: 06-spatial-econometrics.knit.md\n", "\n", "\u001b[39m\u001b[31m\n", "\n", "processing file: 06-spatial-econometrics.qmd\n", " \n", "\u001b[31moutput file: 06-spatial-econometrics.knit.md\n", "\n", "[ 8/13] 07-multilevel-01.qmd\u001b[39m\u001b[22m\n", "\u001b[31m\n", "\n", "processing file: 07-multilevel-01.qmd\n", " |. | 3% (unnamed-chunk-1) \u001b[31mSystem has not been booted with systemd as init system (PID 1). Can't operate.\n", "Failed to connect to bus: Host is down\n", " \n", "\u001b[31moutput file: 07-multilevel-01.knit.md\n", "\n", "\u001b[39m\u001b[31m\n", "\n", "processing file: 07-multilevel-01.qmd\n", " |. | 3% (unnamed-chunk-1) \u001b[31mSystem has not been booted with systemd as init system (PID 1). Can't operate.\n", "Failed to connect to bus: Host is down\n", " \n", "\u001b[31moutput file: 07-multilevel-01.knit.md\n", "\n", "[ 9/13] 08-multilevel-02.qmd\u001b[39m\u001b[22m\n", "\u001b[31m\n", "\n", "processing file: 08-multilevel-02.qmd\n", " |... | 6% (unnamed-chunk-1) \u001b[31mSystem has not been booted with systemd as init system (PID 1). Can't operate.\n", "Failed to connect to bus: Host is down\n", " \n", "\u001b[31moutput file: 08-multilevel-02.knit.md\n", "\n", "\u001b[39m\u001b[31m\n", "\n", "processing file: 08-multilevel-02.qmd\n", " |... | 6% (unnamed-chunk-1) \u001b[31mSystem has not been booted with systemd as init system (PID 1). Can't operate.\n", "Failed to connect to bus: Host is down\n", " \n", "\u001b[31moutput file: 08-multilevel-02.knit.md\n", "\n", "[10/13] 09-gwr.qmd\u001b[39m\u001b[22m\n", "\u001b[31m\n", "\n", "processing file: 09-gwr.qmd\n", " |... | 5% (unnamed-chunk-1) \u001b[31mSystem has not been booted with systemd as init system (PID 1). Can't operate.\n", "Failed to connect to bus: Host is down\n", " \n", "\u001b[31moutput file: 09-gwr.knit.md\n", "\n", "\u001b[39m\u001b[31m\n", "\n", "processing file: 09-gwr.qmd\n", " |... | 5% (unnamed-chunk-1) \u001b[31mSystem has not been booted with systemd as init system (PID 1). Can't operate.\n", "Failed to connect to bus: Host is down\n", " \n", "\u001b[31moutput file: 09-gwr.knit.md\n", "\n", "[11/13] 10-st_analysis.qmd\u001b[39m\u001b[22m\n", "\u001b[31m\n", "\n", "processing file: 10-st_analysis.qmd\n", " |.. | 3% (unnamed-chunk-1) \u001b[31mSystem has not been booted with systemd as init system (PID 1). Can't operate.\n", "Failed to connect to bus: Host is down\n", " \n", "\u001b[31moutput file: 10-st_analysis.knit.md\n", "\n", "\u001b[39m\u001b[31m\n", "\n", "processing file: 10-st_analysis.qmd\n", " |.. | 3% (unnamed-chunk-1) \u001b[31mSystem has not been booted with systemd as init system (PID 1). Can't operate.\n", "Failed to connect to bus: Host is down\n", " \n", "\u001b[31moutput file: 10-st_analysis.knit.md\n", "\n", "[12/13] 11-datasets.qmd\u001b[39m\u001b[22m\n", "\u001b[31m\n", "\n", "processing file: 11-datasets.qmd\n", " \n", "\u001b[31moutput file: 11-datasets.knit.md\n", "\n", "\u001b[39m\u001b[31m\n", "\n", "processing file: 11-datasets.qmd\n", " \n", "\u001b[31moutput file: 11-datasets.knit.md\n", "\n", "[13/13] references.qmd\u001b[39m\u001b[22m\n", "\n", "\u001b[1mpandoc \u001b[22m\n", " to: latex\n", " output-file: index.tex\n", " standalone: true\n", " toc: true\n", " number-sections: true\n", " top-level-division: chapter\n", " pdf-engine: xelatex\n", " variables:\n", " graphics: true\n", " tables: true\n", " default-image-extension: pdf\n", " \n", "\u001b[1mmetadata\u001b[22m\n", " crossref:\n", " chapters: true\n", " documentclass: scrreprt\n", " papersize: letter\n", " classoption:\n", " - DIV=11\n", " - numbers=noendperiod\n", " header-includes:\n", " - '\\KOMAoption{captions}{tableheading}'\n", " block-headings: true\n", " bibliography:\n", " - references.bib\n", " editor: visual\n", " title: Spatial Modelling for Data Scientists\n", " author: 'Francisco Rowe, Dani Arribas-Bel'\n", " date: '2023-04-05T00:00:00+00:00'\n", " \n", "\u001b[1mrunning xelatex - 1\u001b[22m\n", " This is XeTeX, Version 3.141592653-2.6-0.999993 (TeX Live 2022/dev/Debian) (preloaded format=xelatex)\n", " restricted \\write18 enabled.\n", " entering extended mode\n", " \n", "\u001b[1mrunning xelatex - 2\u001b[22m\n", " This is XeTeX, Version 3.141592653-2.6-0.999993 (TeX Live 2022/dev/Debian) (preloaded format=xelatex)\n", " restricted \\write18 enabled.\n", " entering extended mode\n", " \n", "\u001b[1mrunning xelatex - 3\u001b[22m\n", " This is XeTeX, Version 3.141592653-2.6-0.999993 (TeX Live 2022/dev/Debian) (preloaded format=xelatex)\n", " restricted \\write18 enabled.\n", " entering extended mode\n", " \n", "\n", "Output created: docs/index.html\n", "\n" ] } ], "source": [ "! cd san-master \\\n", " && quarto render" ] }, { "cell_type": "markdown", "id": "32588fdc-6f06-4c30-a6a2-69669eb9d2d3", "metadata": {}, "source": [ "## Test WMA" ] }, { "cell_type": "code", "execution_count": null, "id": "c8ae6719-8c87-4461-9725-70cac3603452", "metadata": { "tags": [] }, "outputs": [], "source": [ "! cd wma-main \\\n", " && quarto render" ] }, { "cell_type": "markdown", "id": "31d820af-ec00-4acd-9e56-eb070be9da76", "metadata": {}, "source": [ "## Test R4PS" ] }, { "cell_type": "code", "execution_count": 10, "id": "825c7d15-2cc1-4fd1-914d-7a2759da3e2c", "metadata": { "collapsed": true, "jupyter": { "outputs_hidden": true }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[ 1/13] index.qmd\u001b[39m\u001b[22m\n", "[ 2/13] intro.qmd\u001b[39m\u001b[22m\n", "[ 3/13] intro-population-science.qmd\u001b[39m\u001b[22m\n", "[ 4/13] geodemographics.qmd\u001b[39m\u001b[22m\n", "\u001b[31m\n", "\n", "processing file: geodemographics.qmd\n", " \n", "\u001b[31moutput file: geodemographics.knit.md\n", "\n", "\u001b[39m\u001b[31m\n", "\n", "processing file: geodemographics.qmd\n", " \n", "\u001b[31moutput file: geodemographics.knit.md\n", "\n", "[ 5/13] sequence-analysis.qmd\u001b[39m\u001b[22m\n", "\u001b[31m\n", "\n", "processing file: sequence-analysis.qmd\n", " |... | 6% (unnamed-chunk-2) \u001b[31mSystem has not been booted with systemd as init system (PID 1). Can't operate.\n", "Failed to connect to bus: Host is down\n", " \n", "\u001b[31moutput file: sequence-analysis.knit.md\n", "\n", "\u001b[39m\u001b[31m\n", "\n", "processing file: sequence-analysis.qmd\n", " |... | 6% (unnamed-chunk-2) \u001b[31mSystem has not been booted with systemd as init system (PID 1). Can't operate.\n", "Failed to connect to bus: Host is down\n", " \n", "\u001b[31moutput file: sequence-analysis.knit.md\n", "\n", "[ 6/13] network.qmd\u001b[39m\u001b[22m\n", "\u001b[31m\n", "\n", "processing file: network.qmd\n", " |................ | 32% (unnamed-chunk-16)as_data_frame package:igraph R Documentation\n", "\n", "Creating igraph graphs from data frames or vice-versa\n", "\n", "Description:\n", "\n", " This function creates an igraph graph from one or two data frames\n", " containing the (symbolic) edge list and edge/vertex attributes.\n", "\n", "Usage:\n", "\n", " as_data_frame(x, what = c(\"edges\", \"vertices\", \"both\"))\n", " \n", " graph_from_data_frame(d, directed = TRUE, vertices = NULL)\n", " \n", " from_data_frame(...)\n", " \n", "Arguments:\n", "\n", " x: An igraph object.\n", "\n", " what: Character constant, whether to return info about vertices,\n", " edges, or both. The default is 'edges'.\n", "\n", " d: A data frame containing a symbolic edge list in the first two\n", " columns. Additional columns are considered as edge\n", " attributes. Since version 0.7 this argument is coerced to a\n", " data frame with 'as.data.frame'.\n", "\n", "directed: Logical scalar, whether or not to create a directed graph.\n", "\n", "vertices: A data frame with vertex metadata, or 'NULL'. See details\n", " below. Since version 0.7 this argument is coerced to a data\n", " frame with 'as.data.frame', if not 'NULL'.\n", "\n", " ...: Passed to 'graph_from_data_frame()'.\n", "\n", "Details:\n", "\n", " 'graph_from_data_frame()' creates igraph graphs from one or two\n", " data frames. It has two modes of operation, depending whether the\n", " 'vertices' argument is 'NULL' or not.\n", "\n", " If 'vertices' is 'NULL', then the first two columns of 'd' are\n", " used as a symbolic edge list and additional columns as edge\n", " attributes. The names of the attributes are taken from the names\n", " of the columns.\n", "\n", " If 'vertices' is not 'NULL', then it must be a data frame giving\n", " vertex metadata. The first column of 'vertices' is assumed to\n", " contain symbolic vertex names, this will be added to the graphs as\n", " the ''name'' vertex attribute. Other columns will be added as\n", " additional vertex attributes. If 'vertices' is not 'NULL' then the\n", " symbolic edge list given in 'd' is checked to contain only vertex\n", " names listed in 'vertices'.\n", "\n", " Typically, the data frames are exported from some spreadsheet\n", " software like Excel and are imported into R via 'read.table()',\n", " 'read.delim()' or 'read.csv()'.\n", "\n", " All edges in the data frame are included in the graph, which may\n", " include multiple parallel edges and loops.\n", "\n", " 'as_data_frame()' converts the igraph graph into one or more data\n", " frames, depending on the 'what' argument.\n", "\n", " If the 'what' argument is 'edges' (the default), then the edges of\n", " the graph and also the edge attributes are returned. The edges\n", " will be in the first two columns, named 'from' and 'to'. (This\n", " also denotes edge direction for directed graphs.) For named\n", " graphs, the vertex names will be included in these columns, for\n", " other graphs, the numeric vertex ids. The edge attributes will be\n", " in the other columns. It is not a good idea to have an edge\n", " attribute named 'from' or 'to', because then the column named in\n", " the data frame will not be unique. The edges are listed in the\n", " order of their numeric ids.\n", "\n", " If the 'what' argument is 'vertices', then vertex attributes are\n", " returned. Vertices are listed in the order of their numeric vertex\n", " ids.\n", "\n", " If the 'what' argument is 'both', then both vertex and edge data\n", " is returned, in a list with named entries 'vertices' and 'edges'.\n", "\n", "Value:\n", "\n", " An igraph graph object for 'graph_from_data_frame()', and either a\n", " data frame or a list of two data frames named 'edges' and\n", " 'vertices' for 'as.data.frame'.\n", "\n", "Note:\n", "\n", " For 'graph_from_data_frame()' 'NA' elements in the first two\n", " columns 'd' are replaced by the string \"NA\" before creating the\n", " graph. This means that all 'NA's will correspond to a single\n", " vertex.\n", "\n", " 'NA' elements in the first column of 'vertices' are also replaced\n", " by the string \"NA\", but the rest of 'vertices' is not touched. In\n", " other words, vertex names (=the first column) cannot be 'NA', but\n", " other vertex attributes can.\n", "\n", "Author(s):\n", "\n", " Gabor Csardi \n", "\n", "See Also:\n", "\n", " 'graph_from_literal()' for another way to create graphs,\n", " 'read.table()' to read in tables from files.\n", "\n", " Other conversion: 'as.directed()', 'as.matrix.igraph()',\n", " 'as_adj_list()', 'as_adjacency_matrix()', 'as_edgelist()',\n", " 'as_graphnel()', 'as_incidence_matrix()', 'as_long_data_frame()',\n", " 'graph_from_adj_list()', 'graph_from_graphnel()'\n", "\n", "Examples:\n", "\n", " ## A simple example with a couple of actors\n", " ## The typical case is that these tables are read in from files....\n", " actors <- data.frame(\n", " name = c(\n", " \"Alice\", \"Bob\", \"Cecil\", \"David\",\n", " \"Esmeralda\"\n", " ),\n", " age = c(48, 33, 45, 34, 21),\n", " gender = c(\"F\", \"M\", \"F\", \"M\", \"F\")\n", " )\n", " relations <- data.frame(\n", " from = c(\n", " \"Bob\", \"Cecil\", \"Cecil\", \"David\",\n", " \"David\", \"Esmeralda\"\n", " ),\n", " to = c(\"Alice\", \"Bob\", \"Alice\", \"Alice\", \"Bob\", \"Alice\"),\n", " same.dept = c(FALSE, FALSE, TRUE, FALSE, FALSE, TRUE),\n", " friendship = c(4, 5, 5, 2, 1, 1), advice = c(4, 5, 5, 4, 2, 3)\n", " )\n", " g <- graph_from_data_frame(relations, directed = TRUE, vertices = actors)\n", " print(g, e = TRUE, v = TRUE)\n", " \n", " ## The opposite operation\n", " as_data_frame(g, what = \"vertices\")\n", " as_data_frame(g, what = \"edges\")\n", " \n", "\n", " \n", "\u001b[31moutput file: network.knit.md\n", "\n", "\u001b[39m\u001b[31m\n", "\n", "processing file: network.qmd\n", " |................ | 32% (unnamed-chunk-16)as_data_frame package:igraph R Documentation\n", "\n", "Creating igraph graphs from data frames or vice-versa\n", "\n", "Description:\n", "\n", " This function creates an igraph graph from one or two data frames\n", " containing the (symbolic) edge list and edge/vertex attributes.\n", "\n", "Usage:\n", "\n", " as_data_frame(x, what = c(\"edges\", \"vertices\", \"both\"))\n", " \n", " graph_from_data_frame(d, directed = TRUE, vertices = NULL)\n", " \n", " from_data_frame(...)\n", " \n", "Arguments:\n", "\n", " x: An igraph object.\n", "\n", " what: Character constant, whether to return info about vertices,\n", " edges, or both. The default is 'edges'.\n", "\n", " d: A data frame containing a symbolic edge list in the first two\n", " columns. Additional columns are considered as edge\n", " attributes. Since version 0.7 this argument is coerced to a\n", " data frame with 'as.data.frame'.\n", "\n", "directed: Logical scalar, whether or not to create a directed graph.\n", "\n", "vertices: A data frame with vertex metadata, or 'NULL'. See details\n", " below. Since version 0.7 this argument is coerced to a data\n", " frame with 'as.data.frame', if not 'NULL'.\n", "\n", " ...: Passed to 'graph_from_data_frame()'.\n", "\n", "Details:\n", "\n", " 'graph_from_data_frame()' creates igraph graphs from one or two\n", " data frames. It has two modes of operation, depending whether the\n", " 'vertices' argument is 'NULL' or not.\n", "\n", " If 'vertices' is 'NULL', then the first two columns of 'd' are\n", " used as a symbolic edge list and additional columns as edge\n", " attributes. The names of the attributes are taken from the names\n", " of the columns.\n", "\n", " If 'vertices' is not 'NULL', then it must be a data frame giving\n", " vertex metadata. The first column of 'vertices' is assumed to\n", " contain symbolic vertex names, this will be added to the graphs as\n", " the ''name'' vertex attribute. Other columns will be added as\n", " additional vertex attributes. If 'vertices' is not 'NULL' then the\n", " symbolic edge list given in 'd' is checked to contain only vertex\n", " names listed in 'vertices'.\n", "\n", " Typically, the data frames are exported from some spreadsheet\n", " software like Excel and are imported into R via 'read.table()',\n", " 'read.delim()' or 'read.csv()'.\n", "\n", " All edges in the data frame are included in the graph, which may\n", " include multiple parallel edges and loops.\n", "\n", " 'as_data_frame()' converts the igraph graph into one or more data\n", " frames, depending on the 'what' argument.\n", "\n", " If the 'what' argument is 'edges' (the default), then the edges of\n", " the graph and also the edge attributes are returned. The edges\n", " will be in the first two columns, named 'from' and 'to'. (This\n", " also denotes edge direction for directed graphs.) For named\n", " graphs, the vertex names will be included in these columns, for\n", " other graphs, the numeric vertex ids. The edge attributes will be\n", " in the other columns. It is not a good idea to have an edge\n", " attribute named 'from' or 'to', because then the column named in\n", " the data frame will not be unique. The edges are listed in the\n", " order of their numeric ids.\n", "\n", " If the 'what' argument is 'vertices', then vertex attributes are\n", " returned. Vertices are listed in the order of their numeric vertex\n", " ids.\n", "\n", " If the 'what' argument is 'both', then both vertex and edge data\n", " is returned, in a list with named entries 'vertices' and 'edges'.\n", "\n", "Value:\n", "\n", " An igraph graph object for 'graph_from_data_frame()', and either a\n", " data frame or a list of two data frames named 'edges' and\n", " 'vertices' for 'as.data.frame'.\n", "\n", "Note:\n", "\n", " For 'graph_from_data_frame()' 'NA' elements in the first two\n", " columns 'd' are replaced by the string \"NA\" before creating the\n", " graph. This means that all 'NA's will correspond to a single\n", " vertex.\n", "\n", " 'NA' elements in the first column of 'vertices' are also replaced\n", " by the string \"NA\", but the rest of 'vertices' is not touched. In\n", " other words, vertex names (=the first column) cannot be 'NA', but\n", " other vertex attributes can.\n", "\n", "Author(s):\n", "\n", " Gabor Csardi \n", "\n", "See Also:\n", "\n", " 'graph_from_literal()' for another way to create graphs,\n", " 'read.table()' to read in tables from files.\n", "\n", " Other conversion: 'as.directed()', 'as.matrix.igraph()',\n", " 'as_adj_list()', 'as_adjacency_matrix()', 'as_edgelist()',\n", " 'as_graphnel()', 'as_incidence_matrix()', 'as_long_data_frame()',\n", " 'graph_from_adj_list()', 'graph_from_graphnel()'\n", "\n", "Examples:\n", "\n", " ## A simple example with a couple of actors\n", " ## The typical case is that these tables are read in from files....\n", " actors <- data.frame(\n", " name = c(\n", " \"Alice\", \"Bob\", \"Cecil\", \"David\",\n", " \"Esmeralda\"\n", " ),\n", " age = c(48, 33, 45, 34, 21),\n", " gender = c(\"F\", \"M\", \"F\", \"M\", \"F\")\n", " )\n", " relations <- data.frame(\n", " from = c(\n", " \"Bob\", \"Cecil\", \"Cecil\", \"David\",\n", " \"David\", \"Esmeralda\"\n", " ),\n", " to = c(\"Alice\", \"Bob\", \"Alice\", \"Alice\", \"Bob\", \"Alice\"),\n", " same.dept = c(FALSE, FALSE, TRUE, FALSE, FALSE, TRUE),\n", " friendship = c(4, 5, 5, 2, 1, 1), advice = c(4, 5, 5, 4, 2, 3)\n", " )\n", " g <- graph_from_data_frame(relations, directed = TRUE, vertices = actors)\n", " print(g, e = TRUE, v = TRUE)\n", " \n", " ## The opposite operation\n", " as_data_frame(g, what = \"vertices\")\n", " as_data_frame(g, what = \"edges\")\n", " \n", "\n", " \n", "\u001b[31moutput file: network.knit.md\n", "\n", "[ 7/13] sentiment-analysis.qmd\u001b[39m\u001b[22m\n", "\u001b[31m\n", "\n", "processing file: sentiment-analysis.qmd\n", " |... | 6% (unnamed-chunk-2) \u001b[31mSystem has not been booted with systemd as init system (PID 1). Can't operate.\n", "Failed to connect to bus: Host is down\n", " |........................... | 54% (unnamed-chunk-19)\u001b[31mQuitting from lines 291-292 (sentiment-analysis.qmd) \n", "Error: The textdata package is required to download the NRC word-emotion association lexicon.\n", "Install the textdata package to access this dataset.\n", " \n", "\u001b[31mExecution halted\n", "\u001b[39m" ] } ], "source": [ "! cd r4ps-main \\\n", " && quarto render" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.10" } }, "nbformat": 4, "nbformat_minor": 5 }