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

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によって提供されています。このコンテンツは、現状のまま提供され、変更または削除される場合があります。
Amazonのアソシエイトとして、からだにいいものは適格販売により収入を得ています。
Copied title and URL