gorups variables

I am new to RStudio
trying my best to understand it

I have a dataset with multiple cities and I want to group cities into predefined 8 regions

Any tips to do so ????


To help us help you, could you please prepare a reproducible example (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:

If you are just looking for learning resources, this two free ebooks will teach you everything you need to know to get you up and running with R

I have for example USA cities and I want to group them according to states.
for example. my list has 61 cities and 11 states. I am trying to sort them and group them into the correct state for the whole list.

what package to use and what function ?
my data set called RoyApp , the variable name for the cities is called WALAYAT.

how to group cities into different group according to states
Idaho City Idaho
Illinois City Illinois
Indianapolis Indiana
Iowa City Iowa
Jersey City New Jersey
Kansas City Kansas
Maryland City Maryland*
Minnesota City Minnesota
Mississippi City Mississippi
Missouri City Missouri
Montana City Montana
Nebraska City Nebraska
Nevada City Nevada*
New York City New York
Ohio City Ohio
Oklahoma City Oklahoma
Oregon City Oregon
Tennessee City Tennessee
Texas City Texas

The data you are posting is not on a copy/paste friendly format and makes things harder for people trying to help you, please read the link I gave you before about reproducible example and try to make one.


I have 100 cities and I want to group each city to the correct states

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.