Indexing in pdata.frame not working as it should be

Hello,

I have the following snippet of code:

> df <-data.frame(name=c(rep("r1",152), rep("r2",152), rep("r3", 152)), year=c(1:152, 1:152, 1:152), y = y, var = x)  #tai
>   b <- pdata.frame(df, index=c("name","year"))
>   print(b)
> ```

a sample of the print function is the following:
     

name year y var.1 var.2 var.3 var.4
1-1 r1 1 0.767 -4.819 -45.18 -94.292 -45.944
1-2 r1 2 1.05 7.911 -45.18 -94.292 65.346
1-3 r1 3 1.576 10.091 -45.18 -94.292 129.333
1-4 r1 4 2.405 14.011 -45.18 -94.292 144.563
1-5 r1 5 2.414 17.811 -45.18 -94.292 91.079
1-6 r1 6 2.181 17.811 450.924 -94.292 133.769
1-7 r1 7 2.046 17.811 503.1 -94.292 113.397
1-8 r1 8 1.886 17.811 398.25 -94.292 101.108
1-9 r1 9 2.023 17.811 16.082 621.812 27.582
1-10 r1 10 1.599 17.811 450.371 673.988 -9.181
1-11 r1 11 1.256 17.811 189.436 569.138 -27.562
1-12 r1 12 1.206 17.811 176.28 186.97 -36.753
.
.
.
2-1 r2 1 0.738 -18.066 -45.18 -94.292 -45.944
2-2 r2 2 1.194 -7.156 -45.18 -94.292 65.346
2-3 r2 3 1.323 -3.866 -45.18 -94.292 129.333
2-4 r2 4 1.369 -1.586 -45.18 -94.292 144.563
2-5 r2 5 0.935 -1.586 -45.18 -94.292 91.079
2-6 r2 6 1.185 -1.586 450.924 -94.292 133.769
2-7 r2 7 1.484 -1.586 503.1 -94.292 113.397
2-8 r2 8 1.274 -1.586 398.25 -94.292 101.108
2-9 r2 9 1.148 -1.586 16.082 621.812 27.582
2-10 r2 10 0.912 -1.586 450.371 673.988 -9.181
2-11 r2 11 0.808 -1.586 189.436 569.138 -27.562
2-12 r2 12 0.773 -1.586 176.28 186.97 -36.753

.
.
.
3-1 r3 1 0.223 -55.211 -45.18 -94.292 -45.944
3-2 r3 2 0.321 -49.161 -45.18 -94.292 65.346
3-3 r3 3 0.357 -48.251 -45.18 -94.292 129.333
3-4 r3 4 1.842 -9.881 -45.18 -94.292 144.563
3-5 r3 5 2.748 -0.591 -45.18 -94.292 91.079
3-6 r3 6 2.738 1.109 450.924 -94.292 133.769
3-7 r3 7 2.801 1.109 503.1 -94.292 113.397
3-8 r3 8 1.134 1.109 398.25 -94.292 101.108
3-9 r3 9 0.699 1.109 16.082 621.812 27.582
3-10 r3 10 0.575 1.109 450.371 673.988 -9.181
3-11 r3 11 0.497 1.109 189.436 569.138 -27.562
3-12 r3 12 0.518 1.109 176.28 186.97 -36.753
.
.
.

the output os printed in the eclipse console, I am using renjin to do that. 
any ideas why the index is not taking the regions (r1, r2, r3) into account and giving its own indexing (1, 2, 3)?

Thank you!

Hi, could you edit to provide your example as a reproducible example, called a reprex, please, and correct the error?

library(plm)
df <-data.frame(name=c(rep("r1",152), rep("r2",152), rep("r3", 152)), year=c(1:152, 1:152, 1:152), y = y, var = x)  #tai
#> Error in data.frame(name = c(rep("r1", 152), rep("r2", 152), rep("r3", : object 'y' not found
b <- pdata.frame(df, index=c("name","year"))
#> Error in pdata.frame(df, index = c("name", "year")): variable name does not exist (individual index)
print(b)
#> Error in print(b): object 'b' not found

Created on 2019-12-15 by the reprex package (v0.3.0)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.