how to pivot/unpivot (cast/melt) data frame? [duplicate]
问题 This question already has answers here : Reshaping data.frame from wide to long format (7 answers) Closed 3 years ago . How can I 'unpivot' a table? What is the proper technical term for this? UPDATE: The term is called melt I have a data frame for countries and data for each year Country 2001 2002 2003 Nigeria 1 2 3 UK 2 NA 1 And I want to have something like Country Year Value Nigeria 2001 1 Nigeria 2002 2 Nigeria 2003 3 UK 2001 2 UK 2002 NA UK 2003 1 回答1: I still can't believe I beat