0
一個數據幀我有這樣的data.frame:重塑與reshape2
habitat <- data.frame(
proportion = c(0.053, 0.139, 0.050, 0.756, 0.001, 0.084, 0.000, 0.011, 0.005, 0.066, 0.810, 0.025),
habitat = c("Non-irrigated arable land", "Pastures", "Natural grasslands", "Intertidal flats", "Sea and ocean", "Non-irrigated arable land", "Pastures", "Natural grasslands", "Beaches, dunes, sands", "Salt marshes", "Intertidal flats", "Sea and ocean"),
zone = c(rep("dark", 5), rep("light", 7)))
habitat
proportion habitat zone
1 0.053 Non-irrigated arable land dark
2 0.139 Pastures dark
3 0.050 Natural grasslands dark
4 0.756 Intertidal flats dark
5 0.001 Sea and ocean dark
6 0.084 Non-irrigated arable land light
7 0.000 Pastures light
8 0.011 Natural grasslands light
9 0.005 Beaches, dunes, sands light
10 0.066 Salt marshes light
11 0.810 Intertidal flats light
12 0.025 Sea and ocean light
我需要重塑看起來像這樣:
可以這樣用reshape2做了什麼?