WIZ-IMDB-Project-1/WIZ_Project1.ipynb
2021-04-12 16:07:00 +02:00

9.2 KiB

Imports

install.packages("ggplot2")
install.packages("dplyr") 
install.packages("magrittr")
install.packages("treemap")
library(dplyr)
library(magrittr)
library(treemap)
library(ggplot2)
package 'ggplot2' successfully unpacked and MD5 sums checked

The downloaded binary packages are in
	C:\Users\pkopy\AppData\Local\Temp\Rtmpecxsl2\downloaded_packages
also installing the dependencies 'glue', 'rlang', 'tibble', 'tidyselect'

package 'glue' successfully unpacked and MD5 sums checked
Warning message:
"cannot remove prior installation of package 'glue'"Warning message in file.copy(savedcopy, lib, recursive = TRUE):
"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:
"restored 'glue'"
package 'rlang' successfully unpacked and MD5 sums checked
Warning message:
"cannot remove prior installation of package 'rlang'"Warning message in file.copy(savedcopy, lib, recursive = TRUE):
"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:
"restored 'rlang'"
package 'tibble' successfully unpacked and MD5 sums checked
Warning message:
"cannot remove prior installation of package 'tibble'"Warning message in file.copy(savedcopy, lib, recursive = TRUE):
"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:
"restored 'tibble'"
package 'tidyselect' successfully unpacked and MD5 sums checked
Warning message:
"cannot remove prior installation of package 'tidyselect'"Warning message in file.copy(savedcopy, lib, recursive = TRUE):
"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:
"restored 'tidyselect'"
package 'dplyr' successfully unpacked and MD5 sums checked
Warning message:
"cannot remove prior installation of package 'dplyr'"Warning message in file.copy(savedcopy, lib, recursive = TRUE):
"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:
"restored 'dplyr'"
The downloaded binary packages are in
	C:\Users\pkopy\AppData\Local\Temp\Rtmpecxsl2\downloaded_packages
package 'magrittr' successfully unpacked and MD5 sums checked

The downloaded binary packages are in
	C:\Users\pkopy\AppData\Local\Temp\Rtmpecxsl2\downloaded_packages
package 'treemap' successfully unpacked and MD5 sums checked

The downloaded binary packages are in
	C:\Users\pkopy\AppData\Local\Temp\Rtmpecxsl2\downloaded_packages
Error: package or namespace load failed for 'dplyr' in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
 namespace 'rlang' 0.3.4 is already loaded, but >= 0.4.10 is required
Traceback:

1. library(dplyr)
2. tryCatch({
 .     attr(package, "LibPath") <- which.lib.loc
 .     ns <- loadNamespace(package, lib.loc)
 .     env <- attachNamespace(ns, pos = pos, deps, exclude, include.only)
 . }, error = function(e) {
 .     P <- if (!is.null(cc <- conditionCall(e))) 
 .         paste(" in", deparse(cc)[1L])
 .     else ""
 .     msg <- gettextf("package or namespace load failed for %s%s:\n %s", 
 .         sQuote(package), P, conditionMessage(e))
 .     if (logical.return) 
 .         message(paste("Error:", msg), domain = NA)
 .     else stop(msg, call. = FALSE, domain = NA)
 . })
3. tryCatchList(expr, classes, parentenv, handlers)
4. tryCatchOne(expr, names, parentenv, handlers[[1L]])
5. value[[3L]](cond)
6. stop(msg, call. = FALSE, domain = NA)

Dataset

imdb_raw <- read.csv("imdb_top_1000.csv", header=TRUE, sep=",")
imdb_raw %>%
  select(Series_Title, Released_Year, Runtime, Genre, IMDB_Rating, Meta_score, Director, Star1, Star2, Star3, Star4, No_of_Votes, Gross) -> imdb
Error in imdb_raw %>% select(Series_Title, Released_Year, Runtime, Genre, : nie udało się znaleźć funkcji '%>%'
Traceback:
imdb

Plot 2

# Plot
imdb %>%
    select(Genre, Gross) -> imdb_p2_raw
imdb_p2_raw %>%
    aggregate(imdb_p2_raw, by=list(imdb_p2_raw$Genre), FUN=sum) -> imdb_p2
treemap(imdb_p2,
            
            # data
            index="Genre",
            vSize="Income",
            type="index",
            
            # Main
            title="",
            palette="Dark2",

            # Borders:
            border.col=c("black"),             
            border.lwds=1,                         
        
            # Labels
            fontsize.labels=0.5,
            fontcolor.labels="white",
            fontface.labels=1,            
            bg.labels=c("transparent"),              
            align.labels=c("left", "top"),                                  
            overlap.labels=0.5,
            inflate.labels=T                        # If true, labels are bigger when rectangle is bigger.

            
            )