Learn R Programming

wakefield (version 0.3.9)

state: Generate Random Vector of states

Description

Generate a random factor vector of states.

Usage

state(
  n,
  x = datasets::state.name,
  prob = wakefield::state_populations[["Proportion"]],
  name = "State"
)

Value

Returns a random character vector of state 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 state populations and probabilities:

StatePopulationPercent
California37,253,95612.09 %
Texas25,145,5618.16 %
New York19,378,1026.29 %
Florida18,801,3106.10 %
Illinois12,830,6324.16 %
Pennsylvania12,702,3794.12 %
Ohio11,536,5043.74 %
Michigan9,883,6403.21 %
Georgia9,687,6533.14 %
North Carolina9,535,4833.09 %
New Jersey8,791,8942.85 %
Virginia8,001,0242.60 %
Washington6,724,5402.18 %
Massachusetts6,547,6292.12 %
Indiana6,483,8022.10 %
Arizona6,392,0172.07 %
Tennessee6,346,1052.06 %
Missouri5,988,9271.94 %
Maryland5,773,5521.87 %
Wisconsin5,686,9861.85 %
Minnesota5,303,9251.72 %
Colorado5,029,1961.63 %
Alabama4,779,7361.55 %
South Carolina4,625,3641.50 %
Louisiana4,533,3721.47 %
Kentucky4,339,3671.41 %
Oregon3,831,0741.24 %
Oklahoma3,751,3511.22 %
Connecticut3,574,0971.16 %
Iowa3,046,355.99 %
Mississippi2,967,297.96 %
Arkansas2,915,918.95 %
Kansas2,853,118.93 %
Utah2,763,885.90 %
Nevada2,700,551.88 %
New Mexico2,059,179.67 %
West Virginia1,852,994.60 %
Nebraska1,826,341.59 %
Idaho1,567,582.51 %
Hawaii1,360,301.44 %
Maine1,328,361.43 %
New Hampshire1,316,470.43 %
Rhode Island1,052,567.34 %
Montana989,415.32 %
Delaware897,934.29 %
South Dakota814,180.26 %
Alaska710,231.23 %
North Dakota672,591.22 %
Vermont625,741.20 %
Wyoming563,626.18 %

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(), religion(), sat(), sentence(), sex(), sex_inclusive(), smokes(), speed(), string(), upper(), valid(), year(), zip_code()

Examples

Run this code
state(10)
pie(table(state(10000)))
sort(100*table(state(n <- 10000))/n)

Run the code above in your browser using DataLab