{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "name": "ir",
      "display_name": "R"
    },
    "language_info": {
      "name": "R"
    }
  },
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "i5jkFFHYgrtn"
      },
      "outputs": [],
      "source": [
        "#Matrices\n",
        "A<-matrix(c(1,5,3,2,1,1),nrow=2,ncol=3,byrow=TRUE)"
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "A"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 132
        },
        "id": "xZYKM5-Tg7v-",
        "outputId": "dd5c2644-0551-40f9-99b2-39826696f082"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<table class=\"dataframe\">\n",
              "<caption>A matrix: 2 × 3 of type dbl</caption>\n",
              "<tbody>\n",
              "\t<tr><td>1</td><td>5</td><td>3</td></tr>\n",
              "\t<tr><td>2</td><td>1</td><td>1</td></tr>\n",
              "</tbody>\n",
              "</table>\n"
            ],
            "text/markdown": "\nA matrix: 2 × 3 of type dbl\n\n| 1 | 5 | 3 |\n| 2 | 1 | 1 |\n\n",
            "text/latex": "A matrix: 2 × 3 of type dbl\n\\begin{tabular}{lll}\n\t 1 & 5 & 3\\\\\n\t 2 & 1 & 1\\\\\n\\end{tabular}\n",
            "text/plain": [
              "     [,1] [,2] [,3]\n",
              "[1,] 1    5    3   \n",
              "[2,] 2    1    1   "
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "c1<-c(9,10)\n",
        "f1<-c(7,8,9)\n",
        "c1;f1"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 52
        },
        "id": "zF1LAKw1hFbl",
        "outputId": "4b23f1ea-28b1-4bc4-9616-2245b6fc481a"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<style>\n",
              ".list-inline {list-style: none; margin:0; padding: 0}\n",
              ".list-inline>li {display: inline-block}\n",
              ".list-inline>li:not(:last-child)::after {content: \"\\00b7\"; padding: 0 .5ex}\n",
              "</style>\n",
              "<ol class=list-inline><li>9</li><li>10</li></ol>\n"
            ],
            "text/markdown": "1. 9\n2. 10\n\n\n",
            "text/latex": "\\begin{enumerate*}\n\\item 9\n\\item 10\n\\end{enumerate*}\n",
            "text/plain": [
              "[1]  9 10"
            ]
          },
          "metadata": {}
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<style>\n",
              ".list-inline {list-style: none; margin:0; padding: 0}\n",
              ".list-inline>li {display: inline-block}\n",
              ".list-inline>li:not(:last-child)::after {content: \"\\00b7\"; padding: 0 .5ex}\n",
              "</style>\n",
              "<ol class=list-inline><li>7</li><li>8</li><li>9</li></ol>\n"
            ],
            "text/markdown": "1. 7\n2. 8\n3. 9\n\n\n",
            "text/latex": "\\begin{enumerate*}\n\\item 7\n\\item 8\n\\item 9\n\\end{enumerate*}\n",
            "text/plain": [
              "[1] 7 8 9"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "c1<-c(9,10)\n",
        "f1<-c(7,8,9)\n",
        "c1\n",
        "f1"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 52
        },
        "id": "uc4iXA76mHis",
        "outputId": "fbb13e35-ccc3-4256-e626-739ef4c69009"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<style>\n",
              ".list-inline {list-style: none; margin:0; padding: 0}\n",
              ".list-inline>li {display: inline-block}\n",
              ".list-inline>li:not(:last-child)::after {content: \"\\00b7\"; padding: 0 .5ex}\n",
              "</style>\n",
              "<ol class=list-inline><li>9</li><li>10</li></ol>\n"
            ],
            "text/markdown": "1. 9\n2. 10\n\n\n",
            "text/latex": "\\begin{enumerate*}\n\\item 9\n\\item 10\n\\end{enumerate*}\n",
            "text/plain": [
              "[1]  9 10"
            ]
          },
          "metadata": {}
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<style>\n",
              ".list-inline {list-style: none; margin:0; padding: 0}\n",
              ".list-inline>li {display: inline-block}\n",
              ".list-inline>li:not(:last-child)::after {content: \"\\00b7\"; padding: 0 .5ex}\n",
              "</style>\n",
              "<ol class=list-inline><li>7</li><li>8</li><li>9</li></ol>\n"
            ],
            "text/markdown": "1. 7\n2. 8\n3. 9\n\n\n",
            "text/latex": "\\begin{enumerate*}\n\\item 7\n\\item 8\n\\item 9\n\\end{enumerate*}\n",
            "text/plain": [
              "[1] 7 8 9"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "A;c1\n",
        "#Concatena por columnas\n",
        "cbind(A,c1)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 279
        },
        "id": "SPEAMQEAhOIi",
        "outputId": "b0fc1454-33f4-40e9-bd8b-8b984b29965b"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<table class=\"dataframe\">\n",
              "<caption>A matrix: 2 × 3 of type dbl</caption>\n",
              "<tbody>\n",
              "\t<tr><td>1</td><td>5</td><td>3</td></tr>\n",
              "\t<tr><td>2</td><td>1</td><td>1</td></tr>\n",
              "</tbody>\n",
              "</table>\n"
            ],
            "text/markdown": "\nA matrix: 2 × 3 of type dbl\n\n| 1 | 5 | 3 |\n| 2 | 1 | 1 |\n\n",
            "text/latex": "A matrix: 2 × 3 of type dbl\n\\begin{tabular}{lll}\n\t 1 & 5 & 3\\\\\n\t 2 & 1 & 1\\\\\n\\end{tabular}\n",
            "text/plain": [
              "     [,1] [,2] [,3]\n",
              "[1,] 1    5    3   \n",
              "[2,] 2    1    1   "
            ]
          },
          "metadata": {}
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<style>\n",
              ".list-inline {list-style: none; margin:0; padding: 0}\n",
              ".list-inline>li {display: inline-block}\n",
              ".list-inline>li:not(:last-child)::after {content: \"\\00b7\"; padding: 0 .5ex}\n",
              "</style>\n",
              "<ol class=list-inline><li>9</li><li>10</li></ol>\n"
            ],
            "text/markdown": "1. 9\n2. 10\n\n\n",
            "text/latex": "\\begin{enumerate*}\n\\item 9\n\\item 10\n\\end{enumerate*}\n",
            "text/plain": [
              "[1]  9 10"
            ]
          },
          "metadata": {}
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<table class=\"dataframe\">\n",
              "<caption>A matrix: 2 × 4 of type dbl</caption>\n",
              "<thead>\n",
              "\t<tr><th scope=col></th><th scope=col></th><th scope=col></th><th scope=col>c1</th></tr>\n",
              "</thead>\n",
              "<tbody>\n",
              "\t<tr><td>1</td><td>5</td><td>3</td><td> 9</td></tr>\n",
              "\t<tr><td>2</td><td>1</td><td>1</td><td>10</td></tr>\n",
              "</tbody>\n",
              "</table>\n"
            ],
            "text/markdown": "\nA matrix: 2 × 4 of type dbl\n\n| <!----> | <!----> | <!----> | c1 |\n|---|---|---|---|\n| 1 | 5 | 3 |  9 |\n| 2 | 1 | 1 | 10 |\n\n",
            "text/latex": "A matrix: 2 × 4 of type dbl\n\\begin{tabular}{llll}\n  &  &  & c1\\\\\n\\hline\n\t 1 & 5 & 3 &  9\\\\\n\t 2 & 1 & 1 & 10\\\\\n\\end{tabular}\n",
            "text/plain": [
              "           c1\n",
              "[1,] 1 5 3  9\n",
              "[2,] 2 1 1 10"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "A"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 132
        },
        "id": "N3JyqDabhZlP",
        "outputId": "b920680b-7a66-4fbf-ae69-f9dbfc1ca8c6"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<table class=\"dataframe\">\n",
              "<caption>A matrix: 2 × 3 of type dbl</caption>\n",
              "<tbody>\n",
              "\t<tr><td>1</td><td>5</td><td>3</td></tr>\n",
              "\t<tr><td>2</td><td>1</td><td>1</td></tr>\n",
              "</tbody>\n",
              "</table>\n"
            ],
            "text/markdown": "\nA matrix: 2 × 3 of type dbl\n\n| 1 | 5 | 3 |\n| 2 | 1 | 1 |\n\n",
            "text/latex": "A matrix: 2 × 3 of type dbl\n\\begin{tabular}{lll}\n\t 1 & 5 & 3\\\\\n\t 2 & 1 & 1\\\\\n\\end{tabular}\n",
            "text/plain": [
              "     [,1] [,2] [,3]\n",
              "[1,] 1    5    3   \n",
              "[2,] 2    1    1   "
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "A<-cbind(A,c1)"
      ],
      "metadata": {
        "id": "VvC1ZPTGhbXR"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "A"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 146
        },
        "id": "mT3qIQdLhibu",
        "outputId": "6200152c-3443-4c42-8e62-31c2ae2ad66a"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<table class=\"dataframe\">\n",
              "<caption>A matrix: 2 × 4 of type dbl</caption>\n",
              "<thead>\n",
              "\t<tr><th scope=col></th><th scope=col></th><th scope=col></th><th scope=col>c1</th></tr>\n",
              "</thead>\n",
              "<tbody>\n",
              "\t<tr><td>1</td><td>5</td><td>3</td><td> 9</td></tr>\n",
              "\t<tr><td>2</td><td>1</td><td>1</td><td>10</td></tr>\n",
              "</tbody>\n",
              "</table>\n"
            ],
            "text/markdown": "\nA matrix: 2 × 4 of type dbl\n\n| <!----> | <!----> | <!----> | c1 |\n|---|---|---|---|\n| 1 | 5 | 3 |  9 |\n| 2 | 1 | 1 | 10 |\n\n",
            "text/latex": "A matrix: 2 × 4 of type dbl\n\\begin{tabular}{llll}\n  &  &  & c1\\\\\n\\hline\n\t 1 & 5 & 3 &  9\\\\\n\t 2 & 1 & 1 & 10\\\\\n\\end{tabular}\n",
            "text/plain": [
              "           c1\n",
              "[1,] 1 5 3  9\n",
              "[2,] 2 1 1 10"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "f1\n",
        "#Concatena por filas\n",
        "rbind(A,c1)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 195
        },
        "id": "46QUId_khktE",
        "outputId": "6108f6a9-353f-4583-c8c4-64ea1045808f"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<style>\n",
              ".list-inline {list-style: none; margin:0; padding: 0}\n",
              ".list-inline>li {display: inline-block}\n",
              ".list-inline>li:not(:last-child)::after {content: \"\\00b7\"; padding: 0 .5ex}\n",
              "</style>\n",
              "<ol class=list-inline><li>7</li><li>8</li><li>9</li></ol>\n"
            ],
            "text/markdown": "1. 7\n2. 8\n3. 9\n\n\n",
            "text/latex": "\\begin{enumerate*}\n\\item 7\n\\item 8\n\\item 9\n\\end{enumerate*}\n",
            "text/plain": [
              "[1] 7 8 9"
            ]
          },
          "metadata": {}
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<table class=\"dataframe\">\n",
              "<caption>A matrix: 3 × 4 of type dbl</caption>\n",
              "<thead>\n",
              "\t<tr><th></th><th scope=col></th><th scope=col></th><th scope=col></th><th scope=col>c1</th></tr>\n",
              "</thead>\n",
              "<tbody>\n",
              "\t<tr><th scope=row></th><td>1</td><td> 5</td><td>3</td><td> 9</td></tr>\n",
              "\t<tr><th scope=row></th><td>2</td><td> 1</td><td>1</td><td>10</td></tr>\n",
              "\t<tr><th scope=row>c1</th><td>9</td><td>10</td><td>9</td><td>10</td></tr>\n",
              "</tbody>\n",
              "</table>\n"
            ],
            "text/markdown": "\nA matrix: 3 × 4 of type dbl\n\n| <!--/--> | <!----> | <!----> | <!----> | c1 |\n|---|---|---|---|---|\n| <!----> | 1 |  5 | 3 |  9 |\n| <!----> | 2 |  1 | 1 | 10 |\n| c1 | 9 | 10 | 9 | 10 |\n\n",
            "text/latex": "A matrix: 3 × 4 of type dbl\n\\begin{tabular}{r|llll}\n  &  &  &  & c1\\\\\n\\hline\n\t & 1 &  5 & 3 &  9\\\\\n\t & 2 &  1 & 1 & 10\\\\\n\tc1 & 9 & 10 & 9 & 10\\\\\n\\end{tabular}\n",
            "text/plain": [
              "          c1\n",
              "   1  5 3  9\n",
              "   2  1 1 10\n",
              "c1 9 10 9 10"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "c1;f1\n",
        "rbind(cbind(A,c1,c1,c1,c1),f1)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 230
        },
        "id": "tNf3aB_qh14I",
        "outputId": "3484dc3d-483d-4e23-fefb-3b2b6da1572e"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<style>\n",
              ".list-inline {list-style: none; margin:0; padding: 0}\n",
              ".list-inline>li {display: inline-block}\n",
              ".list-inline>li:not(:last-child)::after {content: \"\\00b7\"; padding: 0 .5ex}\n",
              "</style>\n",
              "<ol class=list-inline><li>9</li><li>10</li></ol>\n"
            ],
            "text/markdown": "1. 9\n2. 10\n\n\n",
            "text/latex": "\\begin{enumerate*}\n\\item 9\n\\item 10\n\\end{enumerate*}\n",
            "text/plain": [
              "[1]  9 10"
            ]
          },
          "metadata": {}
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<style>\n",
              ".list-inline {list-style: none; margin:0; padding: 0}\n",
              ".list-inline>li {display: inline-block}\n",
              ".list-inline>li:not(:last-child)::after {content: \"\\00b7\"; padding: 0 .5ex}\n",
              "</style>\n",
              "<ol class=list-inline><li>7</li><li>8</li><li>9</li></ol>\n"
            ],
            "text/markdown": "1. 7\n2. 8\n3. 9\n\n\n",
            "text/latex": "\\begin{enumerate*}\n\\item 7\n\\item 8\n\\item 9\n\\end{enumerate*}\n",
            "text/plain": [
              "[1] 7 8 9"
            ]
          },
          "metadata": {}
        },
        {
          "output_type": "stream",
          "name": "stderr",
          "text": [
            "Warning message in rbind(cbind(A, c1, c1, c1, c1), f1):\n",
            "“number of columns of result is not a multiple of vector length (arg 2)”\n"
          ]
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<table class=\"dataframe\">\n",
              "<caption>A matrix: 3 × 7 of type dbl</caption>\n",
              "<thead>\n",
              "\t<tr><th></th><th scope=col></th><th scope=col></th><th scope=col></th><th scope=col>c1</th><th scope=col>c1</th><th scope=col>c1</th><th scope=col>c1</th></tr>\n",
              "</thead>\n",
              "<tbody>\n",
              "\t<tr><th scope=row></th><td>1</td><td>3</td><td>1</td><td> 9</td><td> 9</td><td> 9</td><td> 9</td></tr>\n",
              "\t<tr><th scope=row></th><td>5</td><td>2</td><td>1</td><td>10</td><td>10</td><td>10</td><td>10</td></tr>\n",
              "\t<tr><th scope=row>f1</th><td>7</td><td>8</td><td>9</td><td> 7</td><td> 8</td><td> 9</td><td> 7</td></tr>\n",
              "</tbody>\n",
              "</table>\n"
            ],
            "text/markdown": "\nA matrix: 3 × 7 of type dbl\n\n| <!--/--> | <!----> | <!----> | <!----> | c1 | c1 | c1 | c1 |\n|---|---|---|---|---|---|---|---|\n| <!----> | 1 | 3 | 1 |  9 |  9 |  9 |  9 |\n| <!----> | 5 | 2 | 1 | 10 | 10 | 10 | 10 |\n| f1 | 7 | 8 | 9 |  7 |  8 |  9 |  7 |\n\n",
            "text/latex": "A matrix: 3 × 7 of type dbl\n\\begin{tabular}{r|lllllll}\n  &  &  &  & c1 & c1 & c1 & c1\\\\\n\\hline\n\t & 1 & 3 & 1 &  9 &  9 &  9 &  9\\\\\n\t & 5 & 2 & 1 & 10 & 10 & 10 & 10\\\\\n\tf1 & 7 & 8 & 9 &  7 &  8 &  9 &  7\\\\\n\\end{tabular}\n",
            "text/plain": [
              "         c1 c1 c1 c1\n",
              "   1 3 1  9  9  9  9\n",
              "   5 2 1 10 10 10 10\n",
              "f1 7 8 9  7  8  9  7"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "u1<-cbind(A,c1) #2x4\n",
        "u2<-rbind(A,f1) #3x3\n",
        "u1;u2"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 275
        },
        "id": "3aRFskCOiK79",
        "outputId": "fb043b98-9c39-4b6c-a047-dba4f57deebc"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<table class=\"dataframe\">\n",
              "<caption>A matrix: 2 × 4 of type dbl</caption>\n",
              "<thead>\n",
              "\t<tr><th scope=col></th><th scope=col></th><th scope=col></th><th scope=col>c1</th></tr>\n",
              "</thead>\n",
              "<tbody>\n",
              "\t<tr><td>1</td><td>3</td><td>1</td><td> 9</td></tr>\n",
              "\t<tr><td>5</td><td>2</td><td>1</td><td>10</td></tr>\n",
              "</tbody>\n",
              "</table>\n"
            ],
            "text/markdown": "\nA matrix: 2 × 4 of type dbl\n\n| <!----> | <!----> | <!----> | c1 |\n|---|---|---|---|\n| 1 | 3 | 1 |  9 |\n| 5 | 2 | 1 | 10 |\n\n",
            "text/latex": "A matrix: 2 × 4 of type dbl\n\\begin{tabular}{llll}\n  &  &  & c1\\\\\n\\hline\n\t 1 & 3 & 1 &  9\\\\\n\t 5 & 2 & 1 & 10\\\\\n\\end{tabular}\n",
            "text/plain": [
              "           c1\n",
              "[1,] 1 3 1  9\n",
              "[2,] 5 2 1 10"
            ]
          },
          "metadata": {}
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<table class=\"dataframe\">\n",
              "<caption>A matrix: 3 × 3 of type dbl</caption>\n",
              "<tbody>\n",
              "\t<tr><th scope=row></th><td>1</td><td>3</td><td>1</td></tr>\n",
              "\t<tr><th scope=row></th><td>5</td><td>2</td><td>1</td></tr>\n",
              "\t<tr><th scope=row>f1</th><td>7</td><td>8</td><td>9</td></tr>\n",
              "</tbody>\n",
              "</table>\n"
            ],
            "text/markdown": "\nA matrix: 3 × 3 of type dbl\n\n| <!----> | 1 | 3 | 1 |\n| <!----> | 5 | 2 | 1 |\n| f1 | 7 | 8 | 9 |\n\n",
            "text/latex": "A matrix: 3 × 3 of type dbl\n\\begin{tabular}{r|lll}\n\t & 1 & 3 & 1\\\\\n\t & 5 & 2 & 1\\\\\n\tf1 & 7 & 8 & 9\\\\\n\\end{tabular}\n",
            "text/plain": [
              "   [,1] [,2] [,3]\n",
              "   1    3    1   \n",
              "   5    2    1   \n",
              "f1 7    8    9   "
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "rbind(u1,u2)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 141
        },
        "id": "r1LhQP35iWws",
        "outputId": "a50b2f3a-a175-4f87-9237-b7b610d1e753"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "error",
          "ename": "ERROR",
          "evalue": "ignored",
          "traceback": [
            "Error in rbind(u1, u2): number of columns of matrices must match (see arg 2)\nTraceback:\n",
            "1. rbind(u1, u2)"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "#matriz diagonal\n",
        "diag(c(1,2,3,4,5))"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 209
        },
        "id": "PUYzzTc5ieK9",
        "outputId": "57e69ff4-8cd3-473a-a3c4-c8a9d70e56be"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<table class=\"dataframe\">\n",
              "<caption>A matrix: 5 × 5 of type dbl</caption>\n",
              "<tbody>\n",
              "\t<tr><td>1</td><td>0</td><td>0</td><td>0</td><td>0</td></tr>\n",
              "\t<tr><td>0</td><td>2</td><td>0</td><td>0</td><td>0</td></tr>\n",
              "\t<tr><td>0</td><td>0</td><td>3</td><td>0</td><td>0</td></tr>\n",
              "\t<tr><td>0</td><td>0</td><td>0</td><td>4</td><td>0</td></tr>\n",
              "\t<tr><td>0</td><td>0</td><td>0</td><td>0</td><td>5</td></tr>\n",
              "</tbody>\n",
              "</table>\n"
            ],
            "text/markdown": "\nA matrix: 5 × 5 of type dbl\n\n| 1 | 0 | 0 | 0 | 0 |\n| 0 | 2 | 0 | 0 | 0 |\n| 0 | 0 | 3 | 0 | 0 |\n| 0 | 0 | 0 | 4 | 0 |\n| 0 | 0 | 0 | 0 | 5 |\n\n",
            "text/latex": "A matrix: 5 × 5 of type dbl\n\\begin{tabular}{lllll}\n\t 1 & 0 & 0 & 0 & 0\\\\\n\t 0 & 2 & 0 & 0 & 0\\\\\n\t 0 & 0 & 3 & 0 & 0\\\\\n\t 0 & 0 & 0 & 4 & 0\\\\\n\t 0 & 0 & 0 & 0 & 5\\\\\n\\end{tabular}\n",
            "text/plain": [
              "     [,1] [,2] [,3] [,4] [,5]\n",
              "[1,] 1    0    0    0    0   \n",
              "[2,] 0    2    0    0    0   \n",
              "[3,] 0    0    3    0    0   \n",
              "[4,] 0    0    0    4    0   \n",
              "[5,] 0    0    0    0    5   "
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "A"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 132
        },
        "id": "PPrLQBN6ir1M",
        "outputId": "9468cd42-06c7-4c68-ee62-f1a80956344e"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<table class=\"dataframe\">\n",
              "<caption>A matrix: 2 × 3 of type dbl</caption>\n",
              "<tbody>\n",
              "\t<tr><td>1</td><td>3</td><td>1</td></tr>\n",
              "\t<tr><td>5</td><td>2</td><td>1</td></tr>\n",
              "</tbody>\n",
              "</table>\n"
            ],
            "text/markdown": "\nA matrix: 2 × 3 of type dbl\n\n| 1 | 3 | 1 |\n| 5 | 2 | 1 |\n\n",
            "text/latex": "A matrix: 2 × 3 of type dbl\n\\begin{tabular}{lll}\n\t 1 & 3 & 1\\\\\n\t 5 & 2 & 1\\\\\n\\end{tabular}\n",
            "text/plain": [
              "     [,1] [,2] [,3]\n",
              "[1,] 1    3    1   \n",
              "[2,] 5    2    1   "
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "#Cantidad de filas y columnas\n",
        "dim(A)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "tE_ebpEjitsS",
        "outputId": "f26bf882-0077-4cf9-e3a6-4aacccaf93b7"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<style>\n",
              ".list-inline {list-style: none; margin:0; padding: 0}\n",
              ".list-inline>li {display: inline-block}\n",
              ".list-inline>li:not(:last-child)::after {content: \"\\00b7\"; padding: 0 .5ex}\n",
              "</style>\n",
              "<ol class=list-inline><li>2</li><li>3</li></ol>\n"
            ],
            "text/markdown": "1. 2\n2. 3\n\n\n",
            "text/latex": "\\begin{enumerate*}\n\\item 2\n\\item 3\n\\end{enumerate*}\n",
            "text/plain": [
              "[1] 2 3"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "dim(A)[1]"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "-4Wc0ceQiwOj",
        "outputId": "eb221f18-53e6-4bca-9dc1-9f84b605c440"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "2"
            ],
            "text/markdown": "2",
            "text/latex": "2",
            "text/plain": [
              "[1] 2"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "dim(A)[2]"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "mCcyYjXYi0mh",
        "outputId": "c00ff803-4e5a-4e69-8021-c090a992c6e0"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "3"
            ],
            "text/markdown": "3",
            "text/latex": "3",
            "text/plain": [
              "[1] 3"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "class(A)\n",
        "typeof(A)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 52
        },
        "id": "TZoC2ZSbi5oo",
        "outputId": "e062a9e1-e31c-4fa9-c671-68e844eb82c1"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<style>\n",
              ".list-inline {list-style: none; margin:0; padding: 0}\n",
              ".list-inline>li {display: inline-block}\n",
              ".list-inline>li:not(:last-child)::after {content: \"\\00b7\"; padding: 0 .5ex}\n",
              "</style>\n",
              "<ol class=list-inline><li>'matrix'</li><li>'array'</li></ol>\n"
            ],
            "text/markdown": "1. 'matrix'\n2. 'array'\n\n\n",
            "text/latex": "\\begin{enumerate*}\n\\item 'matrix'\n\\item 'array'\n\\end{enumerate*}\n",
            "text/plain": [
              "[1] \"matrix\" \"array\" "
            ]
          },
          "metadata": {}
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "'double'"
            ],
            "text/markdown": "'double'",
            "text/latex": "'double'",
            "text/plain": [
              "[1] \"double\""
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "A"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 132
        },
        "id": "wDWXbfVVi_Oo",
        "outputId": "48119234-6e10-4a94-fb91-5d8033876aa9"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<table class=\"dataframe\">\n",
              "<caption>A matrix: 2 × 3 of type dbl</caption>\n",
              "<tbody>\n",
              "\t<tr><td>1</td><td>3</td><td>1</td></tr>\n",
              "\t<tr><td>5</td><td>2</td><td>1</td></tr>\n",
              "</tbody>\n",
              "</table>\n"
            ],
            "text/markdown": "\nA matrix: 2 × 3 of type dbl\n\n| 1 | 3 | 1 |\n| 5 | 2 | 1 |\n\n",
            "text/latex": "A matrix: 2 × 3 of type dbl\n\\begin{tabular}{lll}\n\t 1 & 3 & 1\\\\\n\t 5 & 2 & 1\\\\\n\\end{tabular}\n",
            "text/plain": [
              "     [,1] [,2] [,3]\n",
              "[1,] 1    3    1   \n",
              "[2,] 5    2    1   "
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "A[2]"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "sIZkezgRjAZU",
        "outputId": "e9f5c4b6-5cc0-4da4-ca56-0a35d5c43cdc"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "2"
            ],
            "text/markdown": "2",
            "text/latex": "2",
            "text/plain": [
              "[1] 2"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "B<-matrix(c(1,2,3,4,5,6,7,8,9),nrow=3,ncol=3)\n",
        "#matrix(c(1,5,3,2,1,1),nrow=2,ncol=3,byrow=FALSE)"
      ],
      "metadata": {
        "id": "CkvKdS_Qjl5V"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "B"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 163
        },
        "id": "SN9763DTj7To",
        "outputId": "e10bcdc0-fa50-4c37-a82a-c4a2cc0336b2"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<table class=\"dataframe\">\n",
              "<caption>A matrix: 3 × 3 of type dbl</caption>\n",
              "<tbody>\n",
              "\t<tr><td>1</td><td>4</td><td>7</td></tr>\n",
              "\t<tr><td>2</td><td>5</td><td>8</td></tr>\n",
              "\t<tr><td>3</td><td>6</td><td>9</td></tr>\n",
              "</tbody>\n",
              "</table>\n"
            ],
            "text/markdown": "\nA matrix: 3 × 3 of type dbl\n\n| 1 | 4 | 7 |\n| 2 | 5 | 8 |\n| 3 | 6 | 9 |\n\n",
            "text/latex": "A matrix: 3 × 3 of type dbl\n\\begin{tabular}{lll}\n\t 1 & 4 & 7\\\\\n\t 2 & 5 & 8\\\\\n\t 3 & 6 & 9\\\\\n\\end{tabular}\n",
            "text/plain": [
              "     [,1] [,2] [,3]\n",
              "[1,] 1    4    7   \n",
              "[2,] 2    5    8   \n",
              "[3,] 3    6    9   "
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "B[4]"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "FKuH1m1Xj9AP",
        "outputId": "b8466590-6ddd-4eb0-d7e8-29616cfbf7cd"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "4"
            ],
            "text/markdown": "4",
            "text/latex": "4",
            "text/plain": [
              "[1] 4"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "#Busca un elemento en la matriz indicando la fila y la columna\n",
        "A[1,2]"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "vgzDOmhhjIgm",
        "outputId": "ea18c03e-7bf3-492f-d7aa-8fe4fe653e53"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "3"
            ],
            "text/markdown": "3",
            "text/latex": "3",
            "text/plain": [
              "[1] 3"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "A[2,]"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "1NQhn0CGjPtu",
        "outputId": "27027a41-9135-411e-f0ce-653279303c4b"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<style>\n",
              ".list-inline {list-style: none; margin:0; padding: 0}\n",
              ".list-inline>li {display: inline-block}\n",
              ".list-inline>li:not(:last-child)::after {content: \"\\00b7\"; padding: 0 .5ex}\n",
              "</style>\n",
              "<ol class=list-inline><li>5</li><li>2</li><li>1</li></ol>\n"
            ],
            "text/markdown": "1. 5\n2. 2\n3. 1\n\n\n",
            "text/latex": "\\begin{enumerate*}\n\\item 5\n\\item 2\n\\item 1\n\\end{enumerate*}\n",
            "text/plain": [
              "[1] 5 2 1"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "A"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 132
        },
        "id": "RUO4FTBQkCrb",
        "outputId": "38c347ba-4547-442b-b887-086390f7522c"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<table class=\"dataframe\">\n",
              "<caption>A matrix: 2 × 3 of type dbl</caption>\n",
              "<tbody>\n",
              "\t<tr><td>1</td><td>3</td><td>1</td></tr>\n",
              "\t<tr><td>5</td><td>2</td><td>1</td></tr>\n",
              "</tbody>\n",
              "</table>\n"
            ],
            "text/markdown": "\nA matrix: 2 × 3 of type dbl\n\n| 1 | 3 | 1 |\n| 5 | 2 | 1 |\n\n",
            "text/latex": "A matrix: 2 × 3 of type dbl\n\\begin{tabular}{lll}\n\t 1 & 3 & 1\\\\\n\t 5 & 2 & 1\\\\\n\\end{tabular}\n",
            "text/plain": [
              "     [,1] [,2] [,3]\n",
              "[1,] 1    3    1   \n",
              "[2,] 5    2    1   "
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "A[2,3]<-9"
      ],
      "metadata": {
        "id": "znqTjq3bjUva"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "A"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 132
        },
        "id": "8EBMoqFEkFRS",
        "outputId": "43c87be4-6e2c-4bd9-fc12-141afd643ae2"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<table class=\"dataframe\">\n",
              "<caption>A matrix: 2 × 3 of type dbl</caption>\n",
              "<tbody>\n",
              "\t<tr><td>1</td><td>3</td><td>1</td></tr>\n",
              "\t<tr><td>5</td><td>2</td><td>9</td></tr>\n",
              "</tbody>\n",
              "</table>\n"
            ],
            "text/markdown": "\nA matrix: 2 × 3 of type dbl\n\n| 1 | 3 | 1 |\n| 5 | 2 | 9 |\n\n",
            "text/latex": "A matrix: 2 × 3 of type dbl\n\\begin{tabular}{lll}\n\t 1 & 3 & 1\\\\\n\t 5 & 2 & 9\\\\\n\\end{tabular}\n",
            "text/plain": [
              "     [,1] [,2] [,3]\n",
              "[1,] 1    3    1   \n",
              "[2,] 5    2    9   "
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "A>5"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 97
        },
        "id": "hbKSPkEVkOZt",
        "outputId": "817e1e8b-bc5e-4bfa-f994-4e66f174446c"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<table class=\"dataframe\">\n",
              "<caption>A matrix: 2 × 3 of type lgl</caption>\n",
              "<tbody>\n",
              "\t<tr><td>FALSE</td><td>FALSE</td><td>FALSE</td></tr>\n",
              "\t<tr><td>FALSE</td><td>FALSE</td><td> TRUE</td></tr>\n",
              "</tbody>\n",
              "</table>\n"
            ],
            "text/markdown": "\nA matrix: 2 × 3 of type lgl\n\n| FALSE | FALSE | FALSE |\n| FALSE | FALSE |  TRUE |\n\n",
            "text/latex": "A matrix: 2 × 3 of type lgl\n\\begin{tabular}{lll}\n\t FALSE & FALSE & FALSE\\\\\n\t FALSE & FALSE &  TRUE\\\\\n\\end{tabular}\n",
            "text/plain": [
              "     [,1]  [,2]  [,3] \n",
              "[1,] FALSE FALSE FALSE\n",
              "[2,] FALSE FALSE  TRUE"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "A+2"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 132
        },
        "id": "Mr1QnsjlkSmI",
        "outputId": "886c35c3-a0a5-4774-9b45-9b3f822f9555"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<table class=\"dataframe\">\n",
              "<caption>A matrix: 2 × 3 of type dbl</caption>\n",
              "<tbody>\n",
              "\t<tr><td>3</td><td>5</td><td> 3</td></tr>\n",
              "\t<tr><td>7</td><td>4</td><td>11</td></tr>\n",
              "</tbody>\n",
              "</table>\n"
            ],
            "text/markdown": "\nA matrix: 2 × 3 of type dbl\n\n| 3 | 5 |  3 |\n| 7 | 4 | 11 |\n\n",
            "text/latex": "A matrix: 2 × 3 of type dbl\n\\begin{tabular}{lll}\n\t 3 & 5 &  3\\\\\n\t 7 & 4 & 11\\\\\n\\end{tabular}\n",
            "text/plain": [
              "     [,1] [,2] [,3]\n",
              "[1,] 3    5     3  \n",
              "[2,] 7    4    11  "
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "A;B"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 278
        },
        "id": "EcTqw71rkZys",
        "outputId": "02ff53f2-28e0-4beb-cb44-f86b63ed85fe"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<table class=\"dataframe\">\n",
              "<caption>A matrix: 2 × 3 of type dbl</caption>\n",
              "<tbody>\n",
              "\t<tr><td>1</td><td>3</td><td>1</td></tr>\n",
              "\t<tr><td>5</td><td>2</td><td>9</td></tr>\n",
              "</tbody>\n",
              "</table>\n"
            ],
            "text/markdown": "\nA matrix: 2 × 3 of type dbl\n\n| 1 | 3 | 1 |\n| 5 | 2 | 9 |\n\n",
            "text/latex": "A matrix: 2 × 3 of type dbl\n\\begin{tabular}{lll}\n\t 1 & 3 & 1\\\\\n\t 5 & 2 & 9\\\\\n\\end{tabular}\n",
            "text/plain": [
              "     [,1] [,2] [,3]\n",
              "[1,] 1    3    1   \n",
              "[2,] 5    2    9   "
            ]
          },
          "metadata": {}
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<table class=\"dataframe\">\n",
              "<caption>A matrix: 3 × 3 of type dbl</caption>\n",
              "<tbody>\n",
              "\t<tr><td>1</td><td>4</td><td>7</td></tr>\n",
              "\t<tr><td>2</td><td>5</td><td>8</td></tr>\n",
              "\t<tr><td>3</td><td>6</td><td>9</td></tr>\n",
              "</tbody>\n",
              "</table>\n"
            ],
            "text/markdown": "\nA matrix: 3 × 3 of type dbl\n\n| 1 | 4 | 7 |\n| 2 | 5 | 8 |\n| 3 | 6 | 9 |\n\n",
            "text/latex": "A matrix: 3 × 3 of type dbl\n\\begin{tabular}{lll}\n\t 1 & 4 & 7\\\\\n\t 2 & 5 & 8\\\\\n\t 3 & 6 & 9\\\\\n\\end{tabular}\n",
            "text/plain": [
              "     [,1] [,2] [,3]\n",
              "[1,] 1    4    7   \n",
              "[2,] 2    5    8   \n",
              "[3,] 3    6    9   "
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "#Multiplicación matricial\n",
        "M1<-A%*%B"
      ],
      "metadata": {
        "id": "o6tCcE7kke4X"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "M1"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 114
        },
        "id": "YgDAGaptkmqe",
        "outputId": "067ed7a6-f8e6-4202-994c-d4d9c34642aa"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<table class=\"dataframe\">\n",
              "<caption>A matrix: 2 × 3 of type dbl</caption>\n",
              "<tbody>\n",
              "\t<tr><td>10</td><td>25</td><td> 40</td></tr>\n",
              "\t<tr><td>36</td><td>84</td><td>132</td></tr>\n",
              "</tbody>\n",
              "</table>\n"
            ],
            "text/markdown": "\nA matrix: 2 × 3 of type dbl\n\n| 10 | 25 |  40 |\n| 36 | 84 | 132 |\n\n",
            "text/latex": "A matrix: 2 × 3 of type dbl\n\\begin{tabular}{lll}\n\t 10 & 25 &  40\\\\\n\t 36 & 84 & 132\\\\\n\\end{tabular}\n",
            "text/plain": [
              "     [,1] [,2] [,3]\n",
              "[1,] 10   25    40 \n",
              "[2,] 36   84   132 "
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "A"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 132
        },
        "id": "0DlhGNXKkqSS",
        "outputId": "a705fe22-8675-414d-cb3e-0bff74667c56"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<table class=\"dataframe\">\n",
              "<caption>A matrix: 2 × 3 of type dbl</caption>\n",
              "<tbody>\n",
              "\t<tr><td>1</td><td>3</td><td>1</td></tr>\n",
              "\t<tr><td>5</td><td>2</td><td>9</td></tr>\n",
              "</tbody>\n",
              "</table>\n"
            ],
            "text/markdown": "\nA matrix: 2 × 3 of type dbl\n\n| 1 | 3 | 1 |\n| 5 | 2 | 9 |\n\n",
            "text/latex": "A matrix: 2 × 3 of type dbl\n\\begin{tabular}{lll}\n\t 1 & 3 & 1\\\\\n\t 5 & 2 & 9\\\\\n\\end{tabular}\n",
            "text/plain": [
              "     [,1] [,2] [,3]\n",
              "[1,] 1    3    1   \n",
              "[2,] 5    2    9   "
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "A*A"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 114
        },
        "id": "e_z8PBgPkrjQ",
        "outputId": "27921aaa-75bb-4cb0-c82c-39268e43131c"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<table class=\"dataframe\">\n",
              "<caption>A matrix: 2 × 3 of type dbl</caption>\n",
              "<tbody>\n",
              "\t<tr><td> 1</td><td>9</td><td> 1</td></tr>\n",
              "\t<tr><td>25</td><td>4</td><td>81</td></tr>\n",
              "</tbody>\n",
              "</table>\n"
            ],
            "text/markdown": "\nA matrix: 2 × 3 of type dbl\n\n|  1 | 9 |  1 |\n| 25 | 4 | 81 |\n\n",
            "text/latex": "A matrix: 2 × 3 of type dbl\n\\begin{tabular}{lll}\n\t  1 & 9 &  1\\\\\n\t 25 & 4 & 81\\\\\n\\end{tabular}\n",
            "text/plain": [
              "     [,1] [,2] [,3]\n",
              "[1,]  1   9     1  \n",
              "[2,] 25   4    81  "
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "A%*%A"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 106
        },
        "id": "xrDACrogkxhM",
        "outputId": "5774423e-ec77-40ee-b35a-b046035ccc4e"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "error",
          "ename": "ERROR",
          "evalue": "ignored",
          "traceback": [
            "Error in A %*% A: non-conformable arguments\nTraceback:\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "A;t(A)\n",
        "#Traspuesta de la matriz"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 313
        },
        "id": "aLNgFZ8Yk-Sg",
        "outputId": "6794e9f0-9574-4f28-8f78-729eec0e3dc8"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<table class=\"dataframe\">\n",
              "<caption>A matrix: 2 × 3 of type dbl</caption>\n",
              "<tbody>\n",
              "\t<tr><td>1</td><td>3</td><td>1</td></tr>\n",
              "\t<tr><td>5</td><td>2</td><td>9</td></tr>\n",
              "</tbody>\n",
              "</table>\n"
            ],
            "text/markdown": "\nA matrix: 2 × 3 of type dbl\n\n| 1 | 3 | 1 |\n| 5 | 2 | 9 |\n\n",
            "text/latex": "A matrix: 2 × 3 of type dbl\n\\begin{tabular}{lll}\n\t 1 & 3 & 1\\\\\n\t 5 & 2 & 9\\\\\n\\end{tabular}\n",
            "text/plain": [
              "     [,1] [,2] [,3]\n",
              "[1,] 1    3    1   \n",
              "[2,] 5    2    9   "
            ]
          },
          "metadata": {}
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<table class=\"dataframe\">\n",
              "<caption>A matrix: 3 × 2 of type dbl</caption>\n",
              "<tbody>\n",
              "\t<tr><td>1</td><td>5</td></tr>\n",
              "\t<tr><td>3</td><td>2</td></tr>\n",
              "\t<tr><td>1</td><td>9</td></tr>\n",
              "</tbody>\n",
              "</table>\n"
            ],
            "text/markdown": "\nA matrix: 3 × 2 of type dbl\n\n| 1 | 5 |\n| 3 | 2 |\n| 1 | 9 |\n\n",
            "text/latex": "A matrix: 3 × 2 of type dbl\n\\begin{tabular}{ll}\n\t 1 & 5\\\\\n\t 3 & 2\\\\\n\t 1 & 9\\\\\n\\end{tabular}\n",
            "text/plain": [
              "     [,1] [,2]\n",
              "[1,] 1    5   \n",
              "[2,] 3    2   \n",
              "[3,] 1    9   "
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "det(A)\n",
        "#Deteminante d ela matriz"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 193
        },
        "id": "UEgRJUBilDZc",
        "outputId": "16399795-930d-4f13-ed4b-5e810a4a4eea"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "error",
          "ename": "ERROR",
          "evalue": "ignored",
          "traceback": [
            "Error in determinant.matrix(x, logarithm = TRUE, ...): 'x' must be a square matrix\nTraceback:\n",
            "1. det(A)",
            "2. determinant(x, logarithm = TRUE, ...)",
            "3. determinant.matrix(x, logarithm = TRUE, ...)",
            "4. stop(\"'x' must be a square matrix\")"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "C<-matrix(c(1,2,3,4),nrow=2,ncol=2)"
      ],
      "metadata": {
        "id": "3qJSFDiSlI8m"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "C;det(C)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 184
        },
        "id": "H7HrHXlIlSY4",
        "outputId": "81f9cbfd-0075-440b-b04a-6806de049c47"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<table class=\"dataframe\">\n",
              "<caption>A matrix: 2 × 2 of type dbl</caption>\n",
              "<tbody>\n",
              "\t<tr><td>1</td><td>3</td></tr>\n",
              "\t<tr><td>2</td><td>4</td></tr>\n",
              "</tbody>\n",
              "</table>\n"
            ],
            "text/markdown": "\nA matrix: 2 × 2 of type dbl\n\n| 1 | 3 |\n| 2 | 4 |\n\n",
            "text/latex": "A matrix: 2 × 2 of type dbl\n\\begin{tabular}{ll}\n\t 1 & 3\\\\\n\t 2 & 4\\\\\n\\end{tabular}\n",
            "text/plain": [
              "     [,1] [,2]\n",
              "[1,] 1    3   \n",
              "[2,] 2    4   "
            ]
          },
          "metadata": {}
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "-2"
            ],
            "text/markdown": "-2",
            "text/latex": "-2",
            "text/plain": [
              "[1] -2"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "c2_inv<-solve(C)\n",
        "#Inversa de la matriz\n",
        "c2_inv"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 132
        },
        "id": "IKJGTEnSlX66",
        "outputId": "bb7d6f97-7d35-46a1-9ff1-1191b8785e30"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<table class=\"dataframe\">\n",
              "<caption>A matrix: 2 × 2 of type dbl</caption>\n",
              "<tbody>\n",
              "\t<tr><td>-2</td><td> 1.5</td></tr>\n",
              "\t<tr><td> 1</td><td>-0.5</td></tr>\n",
              "</tbody>\n",
              "</table>\n"
            ],
            "text/markdown": "\nA matrix: 2 × 2 of type dbl\n\n| -2 |  1.5 |\n|  1 | -0.5 |\n\n",
            "text/latex": "A matrix: 2 × 2 of type dbl\n\\begin{tabular}{ll}\n\t -2 &  1.5\\\\\n\t  1 & -0.5\\\\\n\\end{tabular}\n",
            "text/plain": [
              "     [,1] [,2]\n",
              "[1,] -2    1.5\n",
              "[2,]  1   -0.5"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "C%*%c2_inv"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 166
        },
        "id": "8Z6RdiNxljb4",
        "outputId": "c443c4c3-1f2d-468d-ba8e-dab48c62e58e"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<table class=\"dataframe\">\n",
              "<caption>A matrix: 2 × 2 of type dbl</caption>\n",
              "<tbody>\n",
              "\t<tr><td>1</td><td>0</td></tr>\n",
              "\t<tr><td>0</td><td>1</td></tr>\n",
              "</tbody>\n",
              "</table>\n"
            ],
            "text/markdown": "\nA matrix: 2 × 2 of type dbl\n\n| 1 | 0 |\n| 0 | 1 |\n\n",
            "text/latex": "A matrix: 2 × 2 of type dbl\n\\begin{tabular}{ll}\n\t 1 & 0\\\\\n\t 0 & 1\\\\\n\\end{tabular}\n",
            "text/plain": [
              "     [,1] [,2]\n",
              "[1,] 1    0   \n",
              "[2,] 0    1   "
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "3>4"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "s_QU7OPilo80",
        "outputId": "25e12fd5-4405-43fc-af26-17a88ed35233"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "FALSE"
            ],
            "text/markdown": "FALSE",
            "text/latex": "FALSE",
            "text/plain": [
              "[1] FALSE"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "3==3"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "N3bjtsjNlrPe",
        "outputId": "67d09615-afb3-4bbc-c4bf-ee91ce11e786"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "TRUE"
            ],
            "text/markdown": "TRUE",
            "text/latex": "TRUE",
            "text/plain": [
              "[1] TRUE"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "3==\"a\""
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "cVIv0G0UltSk",
        "outputId": "47ac9730-f780-4130-a5e7-2d4d00a99d09"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "FALSE"
            ],
            "text/markdown": "FALSE",
            "text/latex": "FALSE",
            "text/plain": [
              "[1] FALSE"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "3==NA"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "KkjZxitRlvio",
        "outputId": "bc6e9891-f997-4782-d61c-393cb4962196"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "&lt;NA&gt;"
            ],
            "text/markdown": "&lt;NA&gt;",
            "text/latex": "<NA>",
            "text/plain": [
              "[1] NA"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "NA==NA"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "rP_X4VIKlydk",
        "outputId": "dd8d6af7-431e-40b6-d6ed-1dc65a93ae64"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "&lt;NA&gt;"
            ],
            "text/markdown": "&lt;NA&gt;",
            "text/latex": "<NA>",
            "text/plain": [
              "[1] NA"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "#Pregunta si es nulo\n",
        "is.na(3)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "3SqhCv6zl1Z8",
        "outputId": "e782413d-2033-49f8-c2b2-b7472498d8fd"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "FALSE"
            ],
            "text/markdown": "FALSE",
            "text/latex": "FALSE",
            "text/plain": [
              "[1] FALSE"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "is.na(NA)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "ej4ketQFl4Hs",
        "outputId": "3b4803cc-08b6-4f8d-d376-cf09e63378b0"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "TRUE"
            ],
            "text/markdown": "TRUE",
            "text/latex": "TRUE",
            "text/plain": [
              "[1] TRUE"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "is.na(NaN)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "xp8Yj3Nxl6eN",
        "outputId": "a77f339d-a718-4005-bc4d-998f49249487"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "TRUE"
            ],
            "text/markdown": "TRUE",
            "text/latex": "TRUE",
            "text/plain": [
              "[1] TRUE"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "is.na(Inf)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "I2BO4z82l9lL",
        "outputId": "963a93a7-f702-45fd-dacf-6a2a9f67639d"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "FALSE"
            ],
            "text/markdown": "FALSE",
            "text/latex": "FALSE",
            "text/plain": [
              "[1] FALSE"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "Inf>10000000000"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "6OIs18jdmBiv",
        "outputId": "84f60eb2-a9ea-4ad3-c23f-ca225e211aa6"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "TRUE"
            ],
            "text/markdown": "TRUE",
            "text/latex": "TRUE",
            "text/plain": [
              "[1] TRUE"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "1/0"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "IC0JWvifmGFQ",
        "outputId": "b545f9ca-b989-4e70-f248-71a6d59c3c05"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "Inf"
            ],
            "text/markdown": "Inf",
            "text/latex": "Inf",
            "text/plain": [
              "[1] Inf"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "-1/0"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "BZfpaiP_mIS3",
        "outputId": "a77e6899-0b6e-4e7d-b201-a27c4457278e"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "-Inf"
            ],
            "text/markdown": "-Inf",
            "text/latex": "-Inf",
            "text/plain": [
              "[1] -Inf"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "0/NA"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "MSxQ_bUrmLpq",
        "outputId": "08f04df1-9fad-4fbb-a75b-671137431454"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "&lt;NA&gt;"
            ],
            "text/markdown": "&lt;NA&gt;",
            "text/latex": "<NA>",
            "text/plain": [
              "[1] NA"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "Inf+Inf"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "jvrVb-nAmNtK",
        "outputId": "3acbcd8f-87fd-4fd9-ff9a-a792fd0333d1"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "Inf"
            ],
            "text/markdown": "Inf",
            "text/latex": "Inf",
            "text/plain": [
              "[1] Inf"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "0/0"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "H1C2TYTQmQ5v",
        "outputId": "dba2b58b-bc70-4fb7-9a4a-548e02404eee"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "NaN"
            ],
            "text/markdown": "NaN",
            "text/latex": "NaN",
            "text/plain": [
              "[1] NaN"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "Inf*0"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "r1-rL1KnmSpK",
        "outputId": "d8d2893b-62f7-48a0-ce2f-40ef5f1ae191"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "NaN"
            ],
            "text/markdown": "NaN",
            "text/latex": "NaN",
            "text/plain": [
              "[1] NaN"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "x<-c(4,16,9)\n",
        "c(1,2,3)+c(1,1,4)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "N_DDhThfmpQp",
        "outputId": "1297ca4b-05ff-4ac7-a9de-8193906f74e3"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<style>\n",
              ".list-inline {list-style: none; margin:0; padding: 0}\n",
              ".list-inline>li {display: inline-block}\n",
              ".list-inline>li:not(:last-child)::after {content: \"\\00b7\"; padding: 0 .5ex}\n",
              "</style>\n",
              "<ol class=list-inline><li>2</li><li>3</li><li>7</li></ol>\n"
            ],
            "text/markdown": "1. 2\n2. 3\n3. 7\n\n\n",
            "text/latex": "\\begin{enumerate*}\n\\item 2\n\\item 3\n\\item 7\n\\end{enumerate*}\n",
            "text/plain": [
              "[1] 2 3 7"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "sqrt(x)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "35Rt_rPwm3-_",
        "outputId": "eccc313a-4310-4aac-86fc-cfd963496af1"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<style>\n",
              ".list-inline {list-style: none; margin:0; padding: 0}\n",
              ".list-inline>li {display: inline-block}\n",
              ".list-inline>li:not(:last-child)::after {content: \"\\00b7\"; padding: 0 .5ex}\n",
              "</style>\n",
              "<ol class=list-inline><li>2</li><li>4</li><li>3</li></ol>\n"
            ],
            "text/markdown": "1. 2\n2. 4\n3. 3\n\n\n",
            "text/latex": "\\begin{enumerate*}\n\\item 2\n\\item 4\n\\item 3\n\\end{enumerate*}\n",
            "text/plain": [
              "[1] 2 4 3"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "#Cuenta los caracteres\n",
        "nchar(\"hola\")"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "z7gmuxMQm8Pv",
        "outputId": "c3c4b285-12f8-45eb-a341-67f36b8553c1"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "4"
            ],
            "text/markdown": "4",
            "text/latex": "4",
            "text/plain": [
              "[1] 4"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "#Extrae un grupo de caracteres\n",
        "substr(\"Hola soy miguel\",star=2,stop=6)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "-q6YhI1dm_pH",
        "outputId": "aaf6e072-13ad-4a5a-e02d-d03ff723f3e6"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "'ola s'"
            ],
            "text/markdown": "'ola s'",
            "text/latex": "'ola s'",
            "text/plain": [
              "[1] \"ola s\""
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "#Convierte a número\n",
        "as.numeric(nchar(substr(\"02_miguel\",1,2)))"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "w7a28nJNnK7W",
        "outputId": "61db7b8c-fde7-410e-c150-3557878a6d06"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "2"
            ],
            "text/markdown": "2",
            "text/latex": "2",
            "text/plain": [
              "[1] 2"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "#Busca caracteres\n",
        "grepl(\"ab\",\"sabcdf\")"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "SIcfXBtZnXhd",
        "outputId": "9bf83659-cac0-4b67-f648-2b48e752076b"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "TRUE"
            ],
            "text/markdown": "TRUE",
            "text/latex": "TRUE",
            "text/plain": [
              "[1] TRUE"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "#busca y cambia un caracter\n",
        "fecha<-gsub(\"-\",\"\",c(\"2019-05-15\",\"2019-05-09\"))\n",
        "fecha"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "sPOq3z1un48M",
        "outputId": "6e6a3f50-c07d-42e7-bd55-e44db7c26aba"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<style>\n",
              ".list-inline {list-style: none; margin:0; padding: 0}\n",
              ".list-inline>li {display: inline-block}\n",
              ".list-inline>li:not(:last-child)::after {content: \"\\00b7\"; padding: 0 .5ex}\n",
              "</style>\n",
              "<ol class=list-inline><li>'20190515'</li><li>'20190509'</li></ol>\n"
            ],
            "text/markdown": "1. '20190515'\n2. '20190509'\n\n\n",
            "text/latex": "\\begin{enumerate*}\n\\item '20190515'\n\\item '20190509'\n\\end{enumerate*}\n",
            "text/plain": [
              "[1] \"20190515\" \"20190509\""
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "typeof(fecha)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "14WsND5eoNsB",
        "outputId": "14ccaf2c-a88b-41c9-9234-ca2427ef7026"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "'character'"
            ],
            "text/markdown": "'character'",
            "text/latex": "'character'",
            "text/plain": [
              "[1] \"character\""
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "c(\"1\",\"2\",\"3\")\n",
        "P<-matrix(c(\"1\",\"2\",\"3\"),nrow=1,ncol=3)\n",
        "P"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 118
        },
        "id": "wAoo5n1aoTSa",
        "outputId": "b08048b3-e744-4ae8-8165-dc13ae0ab99e"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<style>\n",
              ".list-inline {list-style: none; margin:0; padding: 0}\n",
              ".list-inline>li {display: inline-block}\n",
              ".list-inline>li:not(:last-child)::after {content: \"\\00b7\"; padding: 0 .5ex}\n",
              "</style>\n",
              "<ol class=list-inline><li>'1'</li><li>'2'</li><li>'3'</li></ol>\n"
            ],
            "text/markdown": "1. '1'\n2. '2'\n3. '3'\n\n\n",
            "text/latex": "\\begin{enumerate*}\n\\item '1'\n\\item '2'\n\\item '3'\n\\end{enumerate*}\n",
            "text/plain": [
              "[1] \"1\" \"2\" \"3\""
            ]
          },
          "metadata": {}
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<table class=\"dataframe\">\n",
              "<caption>A matrix: 1 × 3 of type chr</caption>\n",
              "<tbody>\n",
              "\t<tr><td>1</td><td>2</td><td>3</td></tr>\n",
              "</tbody>\n",
              "</table>\n"
            ],
            "text/markdown": "\nA matrix: 1 × 3 of type chr\n\n| 1 | 2 | 3 |\n\n",
            "text/latex": "A matrix: 1 × 3 of type chr\n\\begin{tabular}{lll}\n\t 1 & 2 & 3\\\\\n\\end{tabular}\n",
            "text/plain": [
              "     [,1] [,2] [,3]\n",
              "[1,] 1    2    3   "
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "P[1,3]<-7"
      ],
      "metadata": {
        "id": "feJub_HpovCi"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "P"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 100
        },
        "id": "75fkAw0vo21W",
        "outputId": "33160553-a694-428c-fc0e-8ff247cba91d"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<table class=\"dataframe\">\n",
              "<caption>A matrix: 1 × 3 of type chr</caption>\n",
              "<tbody>\n",
              "\t<tr><td>1</td><td>2</td><td>7</td></tr>\n",
              "</tbody>\n",
              "</table>\n"
            ],
            "text/markdown": "\nA matrix: 1 × 3 of type chr\n\n| 1 | 2 | 7 |\n\n",
            "text/latex": "A matrix: 1 × 3 of type chr\n\\begin{tabular}{lll}\n\t 1 & 2 & 7\\\\\n\\end{tabular}\n",
            "text/plain": [
              "     [,1] [,2] [,3]\n",
              "[1,] 1    2    7   "
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "length(P)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "e7ZNW_-oo7hd",
        "outputId": "b2b46b26-9638-4412-fe0a-bdea993f3328"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "3"
            ],
            "text/markdown": "3",
            "text/latex": "3",
            "text/plain": [
              "[1] 3"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "dim(P)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "tqbrExXMpCzW",
        "outputId": "01df5a9c-bb4c-4ad4-b9f8-474390523cc2"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<style>\n",
              ".list-inline {list-style: none; margin:0; padding: 0}\n",
              ".list-inline>li {display: inline-block}\n",
              ".list-inline>li:not(:last-child)::after {content: \"\\00b7\"; padding: 0 .5ex}\n",
              "</style>\n",
              "<ol class=list-inline><li>1</li><li>3</li></ol>\n"
            ],
            "text/markdown": "1. 1\n2. 3\n\n\n",
            "text/latex": "\\begin{enumerate*}\n\\item 1\n\\item 3\n\\end{enumerate*}\n",
            "text/plain": [
              "[1] 1 3"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "sqrt(5)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "TuJE48KOpHoi",
        "outputId": "c43335bf-a4fe-49a2-b121-0392f4b5e7ad"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "2.23606797749979"
            ],
            "text/markdown": "2.23606797749979",
            "text/latex": "2.23606797749979",
            "text/plain": [
              "[1] 2.236068"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "factorial(7)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "bxBlHFDapKLE",
        "outputId": "c18408ef-a76c-46fe-8fa0-d289d06ad4fa"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "5040"
            ],
            "text/markdown": "5040",
            "text/latex": "5040",
            "text/plain": [
              "[1] 5040"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "abs(-4)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "L594s2t2pME-",
        "outputId": "5f29c1d9-f33a-4835-f8c9-0152f73d5161"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "4"
            ],
            "text/markdown": "4",
            "text/latex": "4",
            "text/plain": [
              "[1] 4"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "f<-TRUE"
      ],
      "metadata": {
        "id": "AaGubJnUpPkf"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "rm(f)"
      ],
      "metadata": {
        "id": "dAhrAMJ1pUEE"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "y<-c(1,2)\n",
        "names(y)<-c(4,6)\n",
        "y"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "jRszGlyepX-U",
        "outputId": "d8502a08-04a8-4fa8-8037-ecf0222ce291"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<style>\n",
              ".dl-inline {width: auto; margin:0; padding: 0}\n",
              ".dl-inline>dt, .dl-inline>dd {float: none; width: auto; display: inline-block}\n",
              ".dl-inline>dt::after {content: \":\\0020\"; padding-right: .5ex}\n",
              ".dl-inline>dt:not(:first-of-type) {padding-left: .5ex}\n",
              "</style><dl class=dl-inline><dt>4</dt><dd>1</dd><dt>6</dt><dd>2</dd></dl>\n"
            ],
            "text/markdown": "4\n:   16\n:   2\n\n",
            "text/latex": "\\begin{description*}\n\\item[4] 1\n\\item[6] 2\n\\end{description*}\n",
            "text/plain": [
              "4 6 \n",
              "1 2 "
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "which.max(y)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "zNJTPxxjppWe",
        "outputId": "bac31a13-359b-45d2-ebc3-d2ed809df296"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<strong>6:</strong> 2"
            ],
            "text/markdown": "**6:** 2",
            "text/latex": "\\textbf{6:} 2",
            "text/plain": [
              "6 \n",
              "2 "
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "2 %in% y"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "ESDCKKI6pvJF",
        "outputId": "ff54307f-804b-4234-cac3-83103aad7e70"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "TRUE"
            ],
            "text/markdown": "TRUE",
            "text/latex": "TRUE",
            "text/plain": [
              "[1] TRUE"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "rep(\"lala\",20)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "id": "keQy8h7yp0JI",
        "outputId": "b35efd5b-bb23-4279-fdac-1286a2dba330"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<style>\n",
              ".list-inline {list-style: none; margin:0; padding: 0}\n",
              ".list-inline>li {display: inline-block}\n",
              ".list-inline>li:not(:last-child)::after {content: \"\\00b7\"; padding: 0 .5ex}\n",
              "</style>\n",
              "<ol class=list-inline><li>'lala'</li><li>'lala'</li><li>'lala'</li><li>'lala'</li><li>'lala'</li><li>'lala'</li><li>'lala'</li><li>'lala'</li><li>'lala'</li><li>'lala'</li><li>'lala'</li><li>'lala'</li><li>'lala'</li><li>'lala'</li><li>'lala'</li><li>'lala'</li><li>'lala'</li><li>'lala'</li><li>'lala'</li><li>'lala'</li></ol>\n"
            ],
            "text/markdown": "1. 'lala'\n2. 'lala'\n3. 'lala'\n4. 'lala'\n5. 'lala'\n6. 'lala'\n7. 'lala'\n8. 'lala'\n9. 'lala'\n10. 'lala'\n11. 'lala'\n12. 'lala'\n13. 'lala'\n14. 'lala'\n15. 'lala'\n16. 'lala'\n17. 'lala'\n18. 'lala'\n19. 'lala'\n20. 'lala'\n\n\n",
            "text/latex": "\\begin{enumerate*}\n\\item 'lala'\n\\item 'lala'\n\\item 'lala'\n\\item 'lala'\n\\item 'lala'\n\\item 'lala'\n\\item 'lala'\n\\item 'lala'\n\\item 'lala'\n\\item 'lala'\n\\item 'lala'\n\\item 'lala'\n\\item 'lala'\n\\item 'lala'\n\\item 'lala'\n\\item 'lala'\n\\item 'lala'\n\\item 'lala'\n\\item 'lala'\n\\item 'lala'\n\\end{enumerate*}\n",
            "text/plain": [
              " [1] \"lala\" \"lala\" \"lala\" \"lala\" \"lala\" \"lala\" \"lala\" \"lala\" \"lala\" \"lala\"\n",
              "[11] \"lala\" \"lala\" \"lala\" \"lala\" \"lala\" \"lala\" \"lala\" \"lala\" \"lala\" \"lala\""
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "seq(1,10,1)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 176
        },
        "id": "FZqtVRu9p5_G",
        "outputId": "db5118dd-623b-414d-f204-6bdcfc400364"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "error",
          "ename": "ERROR",
          "evalue": "ignored",
          "traceback": [
            "Error in seq.default(1, 10, -1): wrong sign in 'by' argument\nTraceback:\n",
            "1. seq(1, 10, -1)",
            "2. seq.default(1, 10, -1)",
            "3. stop(\"wrong sign in 'by' argument\")"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "w1<-runif(n=10,min=0,max=100)\n",
        "w1"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 52
        },
        "id": "T-_LD6mTqCJF",
        "outputId": "192cf4a2-0e19-46d3-b192-6e77b351a2ac"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<style>\n",
              ".list-inline {list-style: none; margin:0; padding: 0}\n",
              ".list-inline>li {display: inline-block}\n",
              ".list-inline>li:not(:last-child)::after {content: \"\\00b7\"; padding: 0 .5ex}\n",
              "</style>\n",
              "<ol class=list-inline><li>23.1084278551862</li><li>58.3909652661532</li><li>89.9402573471889</li><li>37.809561076574</li><li>87.7140215830877</li><li>13.2353741908446</li><li>93.3433275436983</li><li>23.5235759755597</li><li>24.4854027405381</li><li>31.9879616377875</li></ol>\n"
            ],
            "text/markdown": "1. 23.1084278551862\n2. 58.3909652661532\n3. 89.9402573471889\n4. 37.809561076574\n5. 87.7140215830877\n6. 13.2353741908446\n7. 93.3433275436983\n8. 23.5235759755597\n9. 24.4854027405381\n10. 31.9879616377875\n\n\n",
            "text/latex": "\\begin{enumerate*}\n\\item 23.1084278551862\n\\item 58.3909652661532\n\\item 89.9402573471889\n\\item 37.809561076574\n\\item 87.7140215830877\n\\item 13.2353741908446\n\\item 93.3433275436983\n\\item 23.5235759755597\n\\item 24.4854027405381\n\\item 31.9879616377875\n\\end{enumerate*}\n",
            "text/plain": [
              " [1] 23.10843 58.39097 89.94026 37.80956 87.71402 13.23537 93.34333 23.52358\n",
              " [9] 24.48540 31.98796"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "mean(w1);median(w1)"
      ],
      "metadata": {
        "id": "qUYGy5dDqO4K",
        "outputId": "4c406f9e-e3e3-472c-adbf-da7492fc8ba5",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 52
        }
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "48.3538875216618"
            ],
            "text/markdown": "48.3538875216618",
            "text/latex": "48.3538875216618",
            "text/plain": [
              "[1] 48.35389"
            ]
          },
          "metadata": {}
        },
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "34.8987613571808"
            ],
            "text/markdown": "34.8987613571808",
            "text/latex": "34.8987613571808",
            "text/plain": [
              "[1] 34.89876"
            ]
          },
          "metadata": {}
        }
      ]
    }
  ]
}