Analysis in R: More than, Less than! Manipulation of data “fancycut” package

RAnalytics
スポンサーリンク

This is an introduction to a package that is useful for creating a specified range of data from the parent data. After manipulation, the data may need to be processed with “unique” commands, but in most cases the range of this package will solve the problem.

Package version is 0.1.2. Checked with R version 4.2.2.

スポンサーリンク

Install Package

Run the following command.

#Install Package
install.packages("fancycut")

Example

See the command and package help for details.

#Loading the library
library("fancycut")

###Creating Data#####
TestData <- sample(1:10, 100, replace = TRUE)
########

#Process with specified data range and label:fancycut command
#"(";not including
#"[";including
FcData <- fancycut(TestData,
                   Small = "[1, 3]", Medium = "(4, 6)", Large = "[8, 10]",
                   na.bucket = "Test", unmatched.bucket = "Test")

#Combine with original data
TeFcData <- data.frame(TestData, FcData)

#Check
#table command 
table(TeFcData)
FcData
TestData Small Medium Large Test
1      6      0     0      0
2     10      0     0      0
3      8      0     0      0
4      0      0     0     11
5      0     10     0      0
6      0      0     0     13
7      0      0     0      9
8      0      0    11      0
9      0      0    13      0
10     0      0     9      0

#xtabs command
xtabs(~TeFcData[, 2])
TeFcData[, 2]
Small Medium  Large Test 
24     10     33     33 

#Plot
barplot(xtabs(~TeFcData[, 2]), ylab = "Frequency",
        col = c("#4b61ba", "#deb7a0", "#a87963", "black"))

Output Example


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