5
This is my date.:
data<-read.csv2("NewEXEMPL.csv",header=TRUE,sep=";")
head(data,5)
DATE P.A i.A S.A w.A b.A P.B i.B S.B w.B b.B P.C i.C S.C w.C b.C
1 jun/79 16.86 59.67768 12.3125 0.4291845 497.9 10.38 28.41693 23.000 0.000862813 16.86 59.67768 12.3125 0.4291845 497.9 10.38
2 jul/79 16.69 59.90459 12.2500 0.4177109 533.6 10.48 28.73513 24.250 0.000838926 16.69 59.90459 12.2500 0.4177109 533.6 10.48
3 ago/79 16.62 60.28277 12.0625 0.4046945 542.7 10.55 28.90646 29.500 0.000814996 16.62 60.28277 12.0625 0.4046945 542.7 10.55
4 set/79 16.90 60.43405 12.3125 0.4085802 533.3 10.54 29.17570 36.125 0.000821018 16.90 60.43405 12.3125 0.4085802 533.3 10.54
5 out/79 17.05 60.73660 12.0000 0.4301075 495.3 10.59 29.59179 39.125 0.000849257 17.05 60.73660 12.0000 0.4301075 495.3 10.59
P.D i.D S.D w.D b.D
1 28.41693 12.400 42.404741100 12.00000 0.2405581
2 28.73513 12.980 42.781114500 12.37500 0.2379819
3 28.90646 13.220 43.241126500 11.06250 0.2279202
4 29.17570 495.300 8.700000000 26.27222 18.2500000
5 29.59179 39.125 0.000849257 10.76000 54.1561672
has about 400 lines.
In this code below I would like to have for each country (A, B and C) a data.frame ("NEW") with columns: P.A
, P.D
, i.A
, i.D
and S.A
. That is, my reference will always be the country D. I would like to do this with the "get" function but I’m not getting it. Some help?
mylist<-c("A","B","C") # São os países
for (cno in 1:3){
country<-mylist[cno]
NEW<-data.frame(get(paste("S,i",country,sep=".",data)))
}
Some help?
Thanks, Carlos! You helped a lot.
– Linkman