Analysis in R: Different Colors, Different Colors, Different Colors! The “randomcoloR” package

RAnalytics
スポンサーリンク

Color not only affects the quality of materials, but is also profound, expressing feelings such as liking, disliking, and melancholy. We would like to introduce a package that allows you to create such “colors” randomly.

The following is an introduction to the “scales” package used in the “Execute command”. This package is recommended for expressing colors.

・Analysis in R: “sales” package
 https://www.karada-good.net/analyticsr/r-109/

Package version is 1.1.01. R version 4.2.2 is confirmed.

スポンサーリンク

Install Package

Run the following command.

#Install Package
install.packages("randomcoloR")

Execute command

See the command and package help for details.

#Loading the library
library("randomcoloR")

#Needed to plot colors
#Install the scales package if not already present
if(!require("scales", quietly = TRUE)){
  install.packages("scales");require("scales")
}

#Getting a random color: distinctColorPalette command
#See also:http://tools.medialab.sciences-po.fr/iwanthue/theory.php
#Set the number of acquisitions:k option
CleateCol <- distinctColorPalette(k = 81)
#plot
show_col(CleateCol, labels = FALSE, borders = "#a87963")

#Random color acquisition:randomColor command
#Number of colors to create:count option
#Specify the hue of the color:hue option;"random","red","orange","yellow",
#"green","blue","purple","pink","monochrome"
#Specify the luminosity of the color:luminosity option;"random","light","bright","dark"
RandomCol <- randomColor(count = 6, hue = "blue", luminosity = "light")
#check
RandomCol
[1] "#80abed" "#a9e7fc" "#84e9f4" "#78d3ed" "#8a8aea" "#96ddea"
#plot
show_col(RandomCol, labels = TRUE, borders = "#a87963")

Output Examples

・distinctColorPalette command

distinctColorPalette

・randomColor command

randomColor

I hope this makes your analysis a little easier !!

Amazon audibleの登録の紹介

プライム会員限定で2024年7月22日まで3か月無料体験キャンペーン開催中です。無料体験後は月額1,500円で聞き放題です。なお、聞き放題対象外の本はAudible会員であれば非会員価格の30%引きで購入することが可能です。

Amazon audibleはプロのナレーターが朗読した本をアプリで聞くことができるサービスで、オフライン再生も可能です。通勤や作業のお供にAmazon audibleのご登録はいかがでしょうか。

・AmazonのAudible

https://amzn.to/3L4FI5o

Copied title and URL