[R] Loop and 3D-Densityplot
Patrick Hausmann
patrick.hausmann at uni-bremen.de
Sun Jun 30 18:43:34 CEST 2002
Dear list,
I've got some more question.
# Number 1:
If I run this:
#----------------------------
Per.Start <- c(1950,1973)
Per.End <- c(1973,2001)
for(i in 1:2) {
age <- Per.End-Per.Start
}
age
#----------------------------
I'm getting:
[1] 23 28
But I want to save the result in two different
variables. Something like this:
#----DON'T WORK-------------
Per.Start <- c(1950,1973)
Per.End <- c(1973,2001)
age <- c("age.50","age.73")
for(i in 1:2) {
age[i] <- Per.End-Per.Start
}
#----DON'T WORK-------------
age.50
[1] 23
age.73
[1] 28
# Number 2:
Suppose I have this dataframe:
> m5001c[1:5,1:6]
year AUS AUT BEL CAN DNK
1 1950 7493.457 3706.128 5461.806 7437.141 6946.357
2 1951 7589.926 3959.054 5746.515 7685.627 6935.874
3 1952 7466.991 3967.090 5667.850 7992.271 6955.238
4 1953 7536.674 4136.737 5818.068 8145.948 7292.058
5 1954 7849.489 4554.899 6028.685 7857.842 7371.312
To plot the density for year 1950 I use:
plot(density(as.matrix(k[1,2:6])))
But how can I make a 3D-Densityplot for the years
1950-1954?
Again, thanks for your help
Patrick
-------------
Patrick Hausmann
Friedrich-Wilhelm Str. 37 - D-28199 Bremen
Tel. +49 421 5980631 - Fax. +49 421 5980632
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list