{ "cells": [ { "cell_type": "markdown", "id": "5ac0bf77", "metadata": {}, "source": [ "# Imports" ] }, { "cell_type": "code", "execution_count": 8, "id": "b66c8c8e", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "package 'ggplot2' successfully unpacked and MD5 sums checked\n", "\n", "The downloaded binary packages are in\n", "\tC:\\Users\\pkopy\\AppData\\Local\\Temp\\Rtmpecxsl2\\downloaded_packages\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "also installing the dependencies 'glue', 'rlang', 'tibble', 'tidyselect'\n", "\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "package 'glue' successfully unpacked and MD5 sums checked\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Warning message:\n", "\"cannot remove prior installation of package 'glue'\"Warning message in file.copy(savedcopy, lib, recursive = TRUE):\n", "\"problem z kopiowaniem D:\\anaconda3\\envs\\R\\Lib\\R\\library\\00LOCK\\glue\\libs\\x64\\glue.dll do D:\\anaconda3\\envs\\R\\Lib\\R\\library\\glue\\libs\\x64\\glue.dll: Permission denied\"Warning message:\n", "\"restored 'glue'\"" ] }, { "name": "stdout", "output_type": "stream", "text": [ "package 'rlang' successfully unpacked and MD5 sums checked\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Warning message:\n", "\"cannot remove prior installation of package 'rlang'\"Warning message in file.copy(savedcopy, lib, recursive = TRUE):\n", "\"problem z kopiowaniem D:\\anaconda3\\envs\\R\\Lib\\R\\library\\00LOCK\\rlang\\libs\\x64\\rlang.dll do D:\\anaconda3\\envs\\R\\Lib\\R\\library\\rlang\\libs\\x64\\rlang.dll: Permission denied\"Warning message:\n", "\"restored 'rlang'\"" ] }, { "name": "stdout", "output_type": "stream", "text": [ "package 'tibble' successfully unpacked and MD5 sums checked\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Warning message:\n", "\"cannot remove prior installation of package 'tibble'\"Warning message in file.copy(savedcopy, lib, recursive = TRUE):\n", "\"problem z kopiowaniem D:\\anaconda3\\envs\\R\\Lib\\R\\library\\00LOCK\\tibble\\libs\\x64\\tibble.dll do D:\\anaconda3\\envs\\R\\Lib\\R\\library\\tibble\\libs\\x64\\tibble.dll: Permission denied\"Warning message:\n", "\"restored 'tibble'\"" ] }, { "name": "stdout", "output_type": "stream", "text": [ "package 'tidyselect' successfully unpacked and MD5 sums checked\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Warning message:\n", "\"cannot remove prior installation of package 'tidyselect'\"Warning message in file.copy(savedcopy, lib, recursive = TRUE):\n", "\"problem z kopiowaniem D:\\anaconda3\\envs\\R\\Lib\\R\\library\\00LOCK\\tidyselect\\libs\\x64\\tidyselect.dll do D:\\anaconda3\\envs\\R\\Lib\\R\\library\\tidyselect\\libs\\x64\\tidyselect.dll: Permission denied\"Warning message:\n", "\"restored 'tidyselect'\"" ] }, { "name": "stdout", "output_type": "stream", "text": [ "package 'dplyr' successfully unpacked and MD5 sums checked\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Warning message:\n", "\"cannot remove prior installation of package 'dplyr'\"Warning message in file.copy(savedcopy, lib, recursive = TRUE):\n", "\"problem z kopiowaniem D:\\anaconda3\\envs\\R\\Lib\\R\\library\\00LOCK\\dplyr\\libs\\x64\\dplyr.dll do D:\\anaconda3\\envs\\R\\Lib\\R\\library\\dplyr\\libs\\x64\\dplyr.dll: Permission denied\"Warning message:\n", "\"restored 'dplyr'\"" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "The downloaded binary packages are in\n", "\tC:\\Users\\pkopy\\AppData\\Local\\Temp\\Rtmpecxsl2\\downloaded_packages\n", "package 'magrittr' successfully unpacked and MD5 sums checked\n", "\n", "The downloaded binary packages are in\n", "\tC:\\Users\\pkopy\\AppData\\Local\\Temp\\Rtmpecxsl2\\downloaded_packages\n", "package 'treemap' successfully unpacked and MD5 sums checked\n", "\n", "The downloaded binary packages are in\n", "\tC:\\Users\\pkopy\\AppData\\Local\\Temp\\Rtmpecxsl2\\downloaded_packages\n" ] }, { "ename": "ERROR", "evalue": "Error: package or namespace load failed for 'dplyr' in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):\n namespace 'rlang' 0.3.4 is already loaded, but >= 0.4.10 is required\n", "output_type": "error", "traceback": [ "Error: package or namespace load failed for 'dplyr' in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):\n namespace 'rlang' 0.3.4 is already loaded, but >= 0.4.10 is required\nTraceback:\n", "1. library(dplyr)", "2. tryCatch({\n . attr(package, \"LibPath\") <- which.lib.loc\n . ns <- loadNamespace(package, lib.loc)\n . env <- attachNamespace(ns, pos = pos, deps, exclude, include.only)\n . }, error = function(e) {\n . P <- if (!is.null(cc <- conditionCall(e))) \n . paste(\" in\", deparse(cc)[1L])\n . else \"\"\n . msg <- gettextf(\"package or namespace load failed for %s%s:\\n %s\", \n . sQuote(package), P, conditionMessage(e))\n . if (logical.return) \n . message(paste(\"Error:\", msg), domain = NA)\n . else stop(msg, call. = FALSE, domain = NA)\n . })", "3. tryCatchList(expr, classes, parentenv, handlers)", "4. tryCatchOne(expr, names, parentenv, handlers[[1L]])", "5. value[[3L]](cond)", "6. stop(msg, call. = FALSE, domain = NA)" ] } ], "source": [ "install.packages(\"ggplot2\")\n", "install.packages(\"dplyr\") \n", "install.packages(\"magrittr\")\n", "install.packages(\"treemap\")\n", "library(dplyr)\n", "library(magrittr)\n", "library(treemap)\n", "library(ggplot2)" ] }, { "cell_type": "markdown", "id": "2b7d623a", "metadata": {}, "source": [ "# Dataset" ] }, { "cell_type": "code", "execution_count": 9, "id": "a2b1b3c9", "metadata": {}, "outputs": [], "source": [ "imdb_raw <- read.csv(\"imdb_top_1000.csv\", header=TRUE, sep=\",\")" ] }, { "cell_type": "code", "execution_count": 11, "id": "f3990501", "metadata": {}, "outputs": [ { "ename": "ERROR", "evalue": "Error in imdb_raw %>% select(Series_Title, Released_Year, Runtime, Genre, : nie udało się znaleźć funkcji '%>%'\n", "output_type": "error", "traceback": [ "Error in imdb_raw %>% select(Series_Title, Released_Year, Runtime, Genre, : nie udało się znaleźć funkcji '%>%'\nTraceback:\n" ] } ], "source": [ "imdb_raw %>%\n", " select(Series_Title, Released_Year, Runtime, Genre, IMDB_Rating, Meta_score, Director, Star1, Star2, Star3, Star4, No_of_Votes, Gross) -> imdb" ] }, { "cell_type": "code", "execution_count": null, "id": "d7fee283", "metadata": {}, "outputs": [], "source": [ "imdb" ] }, { "cell_type": "markdown", "id": "2d17ceac", "metadata": {}, "source": [ "# Plot 2" ] }, { "cell_type": "code", "execution_count": null, "id": "faf1f5d9", "metadata": {}, "outputs": [], "source": [ "# Plot\n", "imdb %>%\n", " select(Genre, Gross) -> imdb_p2_raw\n", "imdb_p2_raw %>%\n", " aggregate(imdb_p2_raw, by=list(imdb_p2_raw$Genre), FUN=sum) -> imdb_p2\n", "treemap(imdb_p2,\n", " \n", " # data\n", " index=\"Genre\",\n", " vSize=\"Income\",\n", " type=\"index\",\n", " \n", " # Main\n", " title=\"\",\n", " palette=\"Dark2\",\n", "\n", " # Borders:\n", " border.col=c(\"black\"), \n", " border.lwds=1, \n", " \n", " # Labels\n", " fontsize.labels=0.5,\n", " fontcolor.labels=\"white\",\n", " fontface.labels=1, \n", " bg.labels=c(\"transparent\"), \n", " align.labels=c(\"left\", \"top\"), \n", " overlap.labels=0.5,\n", " inflate.labels=T # If true, labels are bigger when rectangle is bigger.\n", "\n", " \n", " )" ] }, { "cell_type": "code", "execution_count": null, "id": "d5fb0625", "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.6.1" } }, "nbformat": 4, "nbformat_minor": 5 }