Analysis in R: The “docore” package can be surprisingly useful

RAnalytics
スポンサーリンク

This is an introduction to a handy package for small operations in the vector and array class. It contains commands for moving dimensions, separating specified intervals, timers, etc.

Package version is 1.0. Checked with R version 4.2.2.

スポンサーリンク

Install Package

Run the following command.

#Install Package
install.packages("docore")

Example

See the command and package help for details.

#Loading the library
library("docore")

#Shift vector or array dimension: cshift command
#Data: x option
#Number of shifts: s option
#Vector
cshift(x = 1:3, s = 2)
[1] 2 3 1
#Array
cshift(x = array(1:12, dim = c(1, 4, 3)),
       s = 2:4)
     [,1] [,2] [,3]
[1,]   10    2    6
[2,]   11    3    7
[3,]   12    4    8
[4,]    9    1    5

#Display n-th in a vector: last command
#Specify n-th: n option
last(x = 1:3, n = 2)
[1] 2

#maintain a vector or array of vectors separate values
#in a specified range: lim command
#Vector
lim(x = c(1, 5, 7, 8, 9), min = 5, max = 8,
    clip = NULL, na = NULL)
[1] 5 5 7 8 8
#Array
lim(x = array(1:12, dim = c(1, 4, 3)),
    min = 5, max = 8,
    clip = NULL, na = NULL)
, , 1
[,1] [,2] [,3] [,4]
[1,]    5    5    5    5
, , 2
[,1] [,2] [,3] [,4]
[1,]    5    6    7    8
, , 3
[,1] [,2] [,3] [,4]
[1,]    8    8    8    8

#n-separates the specified interval:midseq command
midseq(min = 3, max = 4, n = 4)
[1] 3.125 3.375 3.625 3.875

#Timer: Use the tick command and the tock command together
tick(txt = "Start")
x = sum(1:1000000000000000)
tock(txt = "Stop")
(0.02s). Stop

I hope this makes your analysis a little easier !!

Copied title and URL