Skip to main content

Combining and Restructuring Datasets

  • Chapter
  • First Online:
Using R for Statistics
  • 11k Accesses

Abstract

This chapter explains how to make major changes to the structure of a dataset. You may need to combine data from two or more different sources into one dataset. This may be as simple as attaching one dataset to the bottom or side of another (known as appending or concatenating), or it may involving using a common variable to match the observations (known as merging). Alternatively, you may need to combine the values from several variables into one variable (stacking) or split one variable into several variables (unstacking). Finally, you may need to reshape a dataset so that data that was once held in separate variables in now held in separate observations, or vice versa (also known as rotating or transposing).

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

eBook
USD 16.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 16.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2014 Sarah Stowell

About this chapter

Cite this chapter

Stowell, S. (2014). Combining and Restructuring Datasets. In: Using R for Statistics. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-0139-8_4

Download citation

Publish with us

Policies and ethics