# How to Convert Long Data to Wide Data Using Spread Command !(/Users/kei/.exploratory/projects/Venn_Blog_b89290e38045/markdown_output/image-1533521662218.png) In this article, I will introduce the operation called Spread which transforms the data in one category column into columns for each category. Note that this operation is the opposite operation of Gather, which introduces by converting horizontally spread data (Wide data) to vertically spread data (Long data). # When to Use I would like to explain [the United Nations General Assembly Voting Data from Dataverse](https://dataverse.harvard.edu/dataset.xhtml?persistentId=hdl:1902.1/12379) as an example. Each line of this data contains the content of each country's vote for each resolution. For the sake of simplicity, an example of data filtered to the three countries of the United States, Canada, Russia is shown below, narrowing down the column to the resolution ID (vote_id), country name (country), voting content (vote). The data is structured such that the first row votes for Resolution 3 against the United States (USA), the second row is for Canada (CAN) vote, and the third row is for Russia (RUS) vote. !(/Users/kei/.exploratory/projects/Venn_Blog_b89290e38045/markdown_output/image-1533521093306.png) When you are processing data, you often want to transform such data in a way that each country such as USA, Canada and Russia has its own column as shown in the following figure. !(/Users/kei/.exploratory/projects/Venn_Blog_b89290e38045/markdown_output/image-1533520975592.png) You can use the Spread command to do this transformation. By the way, the data structure before the transformation is called "Long data". In this structure, the data gets "longer" as the number of countries increases. On the other hand, the data structure after the transformation is called "Wide data". In this structure, the data gets "wider" as the number of countries increases. The Spread command transforms Long data to Wide data. # How to Use Here is how to transform Long data of the above example to Wide data on Exploratory. Go to the table view, hold down the command key (control key for Windows), click the country column and vote column. It will select both columns. Then select Spread (Wide to Long) from the column header menu. !(/Users/kei/.exploratory/projects/Venn_Blog_b89290e38045/markdown_output/image-1542509266976.png) As the dialog appears, make sure that "country" is selected for the key column and "vote" is selected for the value column. !(/Users/kei/.exploratory/projects/Venn_Blog_b89290e38045/markdown_output/image-1542509302109.png) The operation of Spread is completed and the data structure has been transformed. !(/Users/kei/.exploratory/projects/Venn_Blog_b89290e38045/markdown_output/image-1533520975592.png) # Summary I introduced the Spread command to convert Long data to Wide data. I summarized how the Spread command works in the figure. !(/Users/kei/.exploratory/projects/Venn_Blog_b89290e38045/markdown_output/image-1533521662218.png) You can download the EDF file from [here](https://exploratory.io/data/kei/United-Nations-Voting-Data-for-US-Canada-and-Russia-0781669549964935) and import it into Exploratory to see how the steps are actually created. ----- # Try It for Yourself! If you don’t have Exploratory Desktop yet, you can sign up from [here](https://exploratory.io/?utm_campaign=howto-spread&utm_medium=blog&utm_source=exploratory) for free. If you are currently a student or teacher, then it’s free! ----- # Learn Data Science without Programming If you are interested in learning various powerful Data Science methods ranging from Machine Learning, Statistics, Data Visualization, and Data Wrangling without programming, go visit our [Booster Training home page](https://exploratory.io/training?utm_campaign=howto-spread&utm_medium=blog&utm_source=exploratory) and enroll today!
<iframe src="https://exploratory.io/note/kei/How-to-Transform-Long-Data-to-Wide-Data-with-Spread-Command-UKF1kgV8fH?embed=true" frameborder="0" width="100%" height="100%" > </iframe>