state: Generate Random Vector of states

Description Usage Arguments Details Value See Also Examples

Description

Generate a random factor vector of states.

Usage

1
2
3
4
5
6
state(
  n,
  x = datasets::state.name,
  prob = wakefield::state_populations[["Proportion"]],
  name = "State"
)

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 state populations and probabilities:

State Population Percent
California 37,253,956 12.09 %
Texas 25,145,561 8.16 %
New York 19,378,102 6.29 %
Florida 18,801,310 6.10 %
Illinois 12,830,632 4.16 %
Pennsylvania 12,702,379 4.12 %
Ohio 11,536,504 3.74 %
Michigan 9,883,640 3.21 %
Georgia 9,687,653 3.14 %
North Carolina 9,535,483 3.09 %
New Jersey 8,791,894 2.85 %
Virginia 8,001,024 2.60 %
Washington 6,724,540 2.18 %
Massachusetts 6,547,629 2.12 %
Indiana 6,483,802 2.10 %
Arizona 6,392,017 2.07 %
Tennessee 6,346,105 2.06 %
Missouri 5,988,927 1.94 %
Maryland 5,773,552 1.87 %
Wisconsin 5,686,986 1.85 %
Minnesota 5,303,925 1.72 %
Colorado 5,029,196 1.63 %
Alabama 4,779,736 1.55 %
South Carolina 4,625,364 1.50 %
Louisiana 4,533,372 1.47 %
Kentucky 4,339,367 1.41 %
Oregon 3,831,074 1.24 %
Oklahoma 3,751,351 1.22 %
Connecticut 3,574,097 1.16 %
Iowa 3,046,355 .99 %
Mississippi 2,967,297 .96 %
Arkansas 2,915,918 .95 %
Kansas 2,853,118 .93 %
Utah 2,763,885 .90 %
Nevada 2,700,551 .88 %
New Mexico 2,059,179 .67 %
West Virginia 1,852,994 .60 %
Nebraska 1,826,341 .59 %
Idaho 1,567,582 .51 %
Hawaii 1,360,301 .44 %
Maine 1,328,361 .43 %
New Hampshire 1,316,470 .43 %
Rhode Island 1,052,567 .34 %
Montana 989,415 .32 %
Delaware 897,934 .29 %
South Dakota 814,180 .26 %
Alaska 710,231 .23 %
North Dakota 672,591 .22 %
Vermont 625,741 .20 %
Wyoming 563,626 .18 %

Value

Returns a random character vector of state elements.

See Also

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

Examples

1
2
3
state(10)
pie(table(state(10000)))
sort(100*table(state(n <- 10000))/n)

wakefield documentation built on Sept. 14, 2020, 1:07 a.m.