Learn R Programming

wakefield (version 0.3.9)

religion: Generate Random Vector of Religions

Description

Generate a random vector of religion.

Usage

religion(
  n,
  x = c("Christian", "Muslim", "None", "Hindu", "Buddhist", "Folk", "Other", "Jewish"),
  prob = c(0.31477, 0.23163, 0.16323, 0.14985, 0.07083, 0.05882, 0.00859, 0.00227),
  name = "Religion"
)

Value

Returns a random factor vector of religion elements.

Arguments

n

The number elements to generate. This can be globally set within the environment of r_data_frame or r_list.

x

A vector of elements to chose from.

prob

A vector of probabilities to chose from.

name

The name to assign to the output vector's varname attribute. This is used to auto assign names to the column/vector name when used inside of r_data_frame or r_list.

Details

The religion and probabilities used match approximate world religion make-up (from Pew Research Center). The default make up is:

ReligionNPercent
Christian2,173,260,00031.48 %
Muslim1,599,280,00023.16 %
None1,127,000,00016.32 %
Hindu1,034,620,00014.99 %
Buddhist489,030,0007.08 %
Folk406,140,0005.88 %
Other59,330,000.86 %
Jewish15,670,000.23 %

References

https://www.pewforum.org/2012/12/18/table-religious-composition-by-country-in-numbers/

See Also

Other variable functions: age(), animal(), answer(), area(), car(), children(), coin(), color(), date_stamp(), death(), dice(), dna(), dob(), dummy(), education(), employment(), eye(), grade(), grade_level(), group(), hair(), height(), income(), internet_browser(), iq(), language, level(), likert(), lorem_ipsum(), marital(), military(), month(), name, normal(), political(), race(), sat(), sentence(), sex(), sex_inclusive(), smokes(), speed(), state(), string(), upper(), valid(), year(), zip_code()

Examples

Run this code
religion(10)
barplot(table(religion(10000)))
pie(table(religion(10000)))

Run the code above in your browser using DataLab