# statar

## Vector functions

The package adds the following vector functions


# sample_mode returns the statistical mode
sample_mode(c(1, 2, 2))
sample_mode(c(1, 2))
sample_mode(c(NA, NA, 1))
sample_mode(c(NA, NA, 1), na.rm = TRUE)

# pctile computes quantile and weighted quantile of type 2 (similarly to Stata _pctile)
v <- c(NA, 1:10)
pctile(v, probs = c(0.3, 0.7), na.rm = TRUE)

# xtile creates integer variable for quantile categories (corresponds to Stata xtile)
v <- c(NA, 1:10)
xtile(v, n = 3) # 3 groups based on terciles
xtile(v, probs = c(0.3, 0.7)) # 3 groups based on two quantiles
xtile(v, cutpoints = c(2, 3)) # 3 groups based on two cutpoints

# winsorize (default based on 5 x interquartile range)
v <- c(1:4, 99)
winsorize(v)
winsorize(v, replace = NA)
winsorize(v, probs = c(0.01, 0.99))
winsorize(v, cutpoints = c(1, 50))
{"ft_lang_label":"__label__en","ft_lang_prob":0.7600032,"math_prob":0.9983806,"size":809,"snap":"2022-40-2023-06","text_gpt3_token_len":298,"char_repetition_ratio":0.13416149,"word_repetition_ratio":0.03937008,"special_character_ratio":0.35723114,"punctuation_ratio":0.1923077,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9997509,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-01-27T01:51:45Z\",\"WARC-Record-ID\":\"<urn:uuid:d30796f3-aeea-433c-a7c6-3890ecd35f82>\",\"Content-Length\":\"14000\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:7ce7fb28-a19e-4866-8283-7d20f4bec035>\",\"WARC-Concurrent-To\":\"<urn:uuid:5a10851f-62b8-4f06-a6bc-547588bd3c0e>\",\"WARC-IP-Address\":\"128.252.93.10\",\"WARC-Target-URI\":\"https://cran.wustl.edu/web/packages/statar/vignettes/vector.html\",\"WARC-Payload-Digest\":\"sha1:S6CEZFX3E2HNA45PUV7RW5CXXKTNRDMH\",\"WARC-Block-Digest\":\"sha1:XS7QVKNSX6K7NNFNT3CWNW3HXBOJ6XJE\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-06/CC-MAIN-2023-06_segments_1674764494852.95_warc_CC-MAIN-20230127001911-20230127031911-00449.warc.gz\"}"}