no commit message

parent 06556317
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Création d'un vecteur"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"liste <- c(14.0, 7.6, 11.2, 12.8, 12.5, 9.9, 14.9, 9.4, 16.9, 10.2, 14.9, 18.1, 7.3, 9.8, 10.9,12.2, 9.9, 2.9, 2.8, 15.4, 15.7, 9.7, 13.1, 13.2, 12.3, 11.7, 16.0, 12.4, 17.9, 12.2, 16.2, 18.7, 8.9, 11.9, 12.1, 14.6, 12.1, 4.7, 3.9, 16.9, 16.8, 11.3, 14.4, 15.7, 14.0, 13.6, 18.0, 13.6, 19.9, 13.7, 17.0, 20.5, 9.9, 12.5, 13.2, 16.1, 13.5, 6.3, 6.4, 17.6, 19.1, 12.8, 15.5, 16.3, 15.2, 14.6, 19.1, 14.4, 21.4, 15.1, 19.6, 21.7, 11.3, 15.0, 14.3, 16.8, 14.0, 6.8, 8.2, 19.9, 20.4, 14.6, 16.4, 18.7, 16.8, 15.8, 20.4, 15.8, 22.4, 16.2, 20.3, 23.4, 12.1, 15.5, 15.4, 18.4, 15.7, 10.2, 8.9, 21.0)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"14.113"
],
"text/latex": [
"14.113"
],
"text/markdown": [
"14.113"
],
"text/plain": [
"[1] 14.113"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"mean(liste)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"2.8"
],
"text/latex": [
"2.8"
],
"text/markdown": [
"2.8"
],
"text/plain": [
"[1] 2.8"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"min(liste)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"23.4"
],
"text/latex": [
"23.4"
],
"text/markdown": [
"23.4"
],
"text/plain": [
"[1] 23.4"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"max(liste)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"14.5"
],
"text/latex": [
"14.5"
],
"text/markdown": [
"14.5"
],
"text/plain": [
"[1] 14.5"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"median(liste)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"4.33409445530145"
],
"text/latex": [
"4.33409445530145"
],
"text/markdown": [
"4.33409445530145"
],
"text/plain": [
"[1] 4.334094"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sd(liste)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
" Min. 1st Qu. Median Mean 3rd Qu. Max. \n",
" 2.80 11.85 14.50 14.11 16.80 23.40 "
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"summary(liste)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"100"
],
"text/latex": [
"100"
],
"text/markdown": [
"100"
],
"text/plain": [
"[1] 100"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"length(liste)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "R",
"language": "R",
"name": "ir"
},
"language_info": {
"codemirror_mode": "r",
"file_extension": ".r",
"mimetype": "text/x-r-source",
"name": "R",
"pygments_lexer": "r",
"version": "3.4.1"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
{ {
"cells": [], "cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"liste <- c(14.0, 7.6, 11.2, 12.8, 12.5, 9.9, 14.9, 9.4, 16.9, 10.2, 14.9, 18.1, 7.3, 9.8, 10.9,12.2, 9.9, 2.9, 2.8, 15.4, 15.7, 9.7, 13.1, 13.2, 12.3, 11.7, 16.0, 12.4, 17.9, 12.2, 16.2, 18.7, 8.9, 11.9, 12.1, 14.6, 12.1, 4.7, 3.9, 16.9, 16.8, 11.3, 14.4, 15.7, 14.0, 13.6, 18.0, 13.6, 19.9, 13.7, 17.0, 20.5, 9.9, 12.5, 13.2, 16.1, 13.5, 6.3, 6.4, 17.6, 19.1, 12.8, 15.5, 16.3, 15.2, 14.6, 19.1, 14.4, 21.4, 15.1, 19.6, 21.7, 11.3, 15.0, 14.3, 16.8, 14.0, 6.8, 8.2, 19.9, 20.4, 14.6, 16.4, 18.7, 16.8, 15.8, 20.4, 15.8, 22.4, 16.2, 20.3, 23.4, 12.1, 15.5, 15.4, 18.4, 15.7, 10.2, 8.9, 21.0)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"14.113"
],
"text/latex": [
"14.113"
],
"text/markdown": [
"14.113"
],
"text/plain": [
"[1] 14.113"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"mean(liste)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"2.8"
],
"text/latex": [
"2.8"
],
"text/markdown": [
"2.8"
],
"text/plain": [
"[1] 2.8"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"min(liste)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"23.4"
],
"text/latex": [
"23.4"
],
"text/markdown": [
"23.4"
],
"text/plain": [
"[1] 23.4"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"max(liste)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"14.5"
],
"text/latex": [
"14.5"
],
"text/markdown": [
"14.5"
],
"text/plain": [
"[1] 14.5"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"median(liste)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"4.33409445530145"
],
"text/latex": [
"4.33409445530145"
],
"text/markdown": [
"4.33409445530145"
],
"text/plain": [
"[1] 4.334094"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sd(liste)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
" Min. 1st Qu. Median Mean 3rd Qu. Max. \n",
" 2.80 11.85 14.50 14.11 16.80 23.40 "
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"summary(liste)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"100"
],
"text/latex": [
"100"
],
"text/markdown": [
"100"
],
"text/plain": [
"[1] 100"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"length(liste)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": { "metadata": {
"kernelspec": { "kernelspec": {
"display_name": "Python 3", "display_name": "R",
"language": "python", "language": "R",
"name": "python3" "name": "ir"
}, },
"language_info": { "language_info": {
"codemirror_mode": { "codemirror_mode": "r",
"name": "ipython", "file_extension": ".r",
"version": 3 "mimetype": "text/x-r-source",
}, "name": "R",
"file_extension": ".py", "pygments_lexer": "r",
"mimetype": "text/x-python", "version": "3.4.1"
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.3"
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 2 "nbformat_minor": 2
} }
This diff is collapsed.
{ {
"cells": [], "cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Analyse des données de FAO"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Installation du kernel SAS"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: saspy in /opt/conda/lib/python3.6/site-packages (5.100.2)\n",
"Note: you may need to restart the kernel to use updated packages.\n"
]
}
],
"source": [
"pip install saspy"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: sas_kernel in /opt/conda/lib/python3.6/site-packages (2.4.13)\n",
"Requirement already satisfied: metakernel>=0.27.5 in /opt/conda/lib/python3.6/site-packages (from sas_kernel) (0.28.2)\n",
"Requirement already satisfied: saspy>=3.6 in /opt/conda/lib/python3.6/site-packages (from sas_kernel) (5.100.2)\n",
"Requirement already satisfied: ipython>=7 in /opt/conda/lib/python3.6/site-packages (from sas_kernel) (7.12.0)\n",
"Requirement already satisfied: jupyter-client>=6 in /opt/conda/lib/python3.6/site-packages (from sas_kernel) (6.0.0)\n",
"Requirement already satisfied: jupyter-core in /opt/conda/lib/python3.6/site-packages (from metakernel>=0.27.5->sas_kernel) (4.6.3)\n",
"Requirement already satisfied: pexpect>=4.2 in /opt/conda/lib/python3.6/site-packages (from metakernel>=0.27.5->sas_kernel) (4.8.0)\n",
"Requirement already satisfied: jedi<0.18; python_version <= \"3.6\" in /opt/conda/lib/python3.6/site-packages (from metakernel>=0.27.5->sas_kernel) (0.16.0)\n",
"Requirement already satisfied: ipykernel in /opt/conda/lib/python3.6/site-packages (from metakernel>=0.27.5->sas_kernel) (5.1.4)\n",
"Requirement already satisfied: traitlets>=4.2 in /opt/conda/lib/python3.6/site-packages (from ipython>=7->sas_kernel) (4.3.3)\n",
"Requirement already satisfied: decorator in /opt/conda/lib/python3.6/site-packages (from ipython>=7->sas_kernel) (4.4.1)\n",
"Requirement already satisfied: setuptools>=18.5 in /opt/conda/lib/python3.6/site-packages (from ipython>=7->sas_kernel) (45.2.0.post20200209)\n",
"Requirement already satisfied: prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0 in /opt/conda/lib/python3.6/site-packages (from ipython>=7->sas_kernel) (3.0.3)\n",
"Requirement already satisfied: backcall in /opt/conda/lib/python3.6/site-packages (from ipython>=7->sas_kernel) (0.1.0)\n",
"Requirement already satisfied: pygments in /opt/conda/lib/python3.6/site-packages (from ipython>=7->sas_kernel) (2.5.2)\n",
"Requirement already satisfied: pickleshare in /opt/conda/lib/python3.6/site-packages (from ipython>=7->sas_kernel) (0.7.5)\n",
"Requirement already satisfied: tornado>=4.1 in /opt/conda/lib/python3.6/site-packages (from jupyter-client>=6->sas_kernel) (6.0.3)\n",
"Requirement already satisfied: pyzmq>=13 in /opt/conda/lib/python3.6/site-packages (from jupyter-client>=6->sas_kernel) (17.1.2)\n",
"Requirement already satisfied: python-dateutil>=2.1 in /opt/conda/lib/python3.6/site-packages (from jupyter-client>=6->sas_kernel) (2.8.1)\n",
"Requirement already satisfied: ptyprocess>=0.5 in /opt/conda/lib/python3.6/site-packages (from pexpect>=4.2->metakernel>=0.27.5->sas_kernel) (0.6.0)\n",
"Requirement already satisfied: parso>=0.5.2 in /opt/conda/lib/python3.6/site-packages (from jedi<0.18; python_version <= \"3.6\"->metakernel>=0.27.5->sas_kernel) (0.6.0)\n",
"Requirement already satisfied: ipython-genutils in /opt/conda/lib/python3.6/site-packages (from traitlets>=4.2->ipython>=7->sas_kernel) (0.2.0)\n",
"Requirement already satisfied: six in /opt/conda/lib/python3.6/site-packages (from traitlets>=4.2->ipython>=7->sas_kernel) (1.14.0)\n",
"Requirement already satisfied: wcwidth in /opt/conda/lib/python3.6/site-packages (from prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0->ipython>=7->sas_kernel) (0.1.8)\n",
"Note: you may need to restart the kernel to use updated packages.\n"
]
}
],
"source": [
"pip install sas_kernel"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Une fois les deux commandes lancées, il faut enregistrer et quitter (et restart the kernel ?). Mais quand on revient on a bien SAS proposé dans les kernel (Kernel > Change kernel)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[0;31m[<class 'saspy.sasexceptions.SASIOConnectionTerminated'>, SASIOConnectionTerminated(<class 'Exception'>,), <traceback object at 0x7fe1cf696688>]\n",
"\u001b[0m"
]
}
],
"source": [
"%load_ext saspy.ipython\n",
"%%SAS\n",
"proc import out=table\n",
"datafile='module2/exo4/cdu_ba_pied.csv' \n",
"dbms=dlm replace;\n",
"delimiter=';'; /*csv*/\n",
"getnames=yes; /*la première ligne donne les noms des variables*/\n",
"guessingrows=max; /*utilisation du max de lignes pour déterminer le type de variable (numérique / nombre de caractères, etc*/\n",
"run;\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"ça ne marche pas parce qu'il faut réussir à connecter Jupyter avec SAS (pour la licence je pense) donc j'abandonne (pas sûre que ça vale le coût de passer du temps dessus, mais à voir) et je reste en R."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Retour au kernel R"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Je change le Kernel (dans Kernel > Change Kernel > R)."
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"library(readr)"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"ename": "ERROR",
"evalue": "Error: '/cdu_ba_pied.csv' does not exist.\n",
"output_type": "error",
"traceback": [
"Error: '/cdu_ba_pied.csv' does not exist.\nTraceback:\n",
"1. read_csv(\"/cdu_ba_pied.csv\")",
"2. read_delimited(file, tokenizer, col_names = col_names, col_types = col_types, \n . locale = locale, skip = skip, comment = comment, n_max = n_max, \n . guess_max = guess_max, progress = progress)",
"3. standardise_path(file)",
"4. check_path(path)",
"5. stop(\"'\", path, \"' does not exist\", if (!is_absolute_path(path)) paste0(\" in current working directory ('\", \n . getwd(), \"')\"), \".\", call. = FALSE)"
]
}
],
"source": [
"data1 <- read_csv('/cdu_ba_pied.csv')\n",
"head(data1)"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Classes ‘tbl_df’, ‘tbl’ and 'data.frame':\t1 obs. of 1 variable:\n",
" $ /home/3f624f2cce5b76d09dcee501242941ad/: chr \"mooc-rr/module2/exo4/cdu_ba_pied.csv\"\n",
" - attr(*, \"spec\")=List of 2\n",
" ..$ cols :List of 1\n",
" .. ..$ /home/3f624f2cce5b76d09dcee501242941ad/: list()\n",
" .. .. ..- attr(*, \"class\")= chr \"collector_character\" \"collector\"\n",
" ..$ default: list()\n",
" .. ..- attr(*, \"class\")= chr \"collector_guess\" \"collector\"\n",
" ..- attr(*, \"class\")= chr \"col_spec\"\n"
]
}
],
"source": [
"str(data1)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": { "metadata": {
"kernelspec": { "kernelspec": {
"display_name": "Python 3", "display_name": "R",
"language": "python", "language": "R",
"name": "python3" "name": "ir"
}, },
"language_info": { "language_info": {
"codemirror_mode": { "codemirror_mode": "r",
"name": "ipython", "file_extension": ".r",
"version": 3 "mimetype": "text/x-r-source",
}, "name": "R",
"file_extension": ".py", "pygments_lexer": "r",
"mimetype": "text/x-python", "version": "3.4.1"
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.3"
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 2 "nbformat_minor": 2
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment