我有这个数据框 https://www.dropbox.com/s/n5qfdbnsa53svsu/NPmod.xlsx?dl=0
我想将其转换为面板数据。
这是我尝试过的代码,但是暂时不起作用。
panelNP <- reshape(NPmod, idvar = "country", ids = colnames(NPmod[,2:32]),
times = NPmod$Year, timevar = "year",
varying = list(row.names(NPmod[1:46,])),v.names="NP",
new.row.names = 1:((dim(NPmod)[2])*(dim(NPmod)[1])),
direction = "long")
我想拥有的是: 第一栏:国家名称 第二栏:年份 第三栏:值
\begin{table}[]
\begin{tabular}{llr}
\cline{1-2}
Country & Year & NP \\ \hline
Austria & 1970 & ... \\
Austria & 1971 & ... \\
Austria & 1972 & ... \\
... & ... & ... \\
Belgium & 1970 & ... \\ \hline
... & ... & \multicolumn{1}{l}{...}
\end{tabular}
\end{table}