reshape - convert data from many rows to many columns in R? -


I have data that comes out of a DB in a normalized manner with the year, state and value area. I want to analyze the data and format it where every year is a field and there is no record. That's why I would like the data where each record is a state and then for each year the field and for each of those values, each value is in that year's value and in that position. Is there any order to do this?

Then I have:

state, year, value
KY, 1998, 56
KY, 1997, 78
IL, 99 8, 48 il, 1997, 72

and I want to:

state, 1997_value, 1998_value
KY, 78, 56
IL, 72, 48

You want to use reshape ( ) function.

  reshape (data, idvar = "state", time = "year", direction = "wide")  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -