[R] qnorm to a list
QAMAR MUHAMMAD UZAIR
d029307 at polito.it
Fri May 25 16:56:13 CEST 2012
dear jim,
thakyou very much for your help. i would really appreciate
if you give me one more favor. i want to apply qnorm to
the whole coulmn so that i would have on the x-axis the
quantile of the lognormal distribution (qnorm(....)) with
zero-mean and unit-variance, corresponding to excedence
probabilities F=i/(365+1) with i=1...365.
thanks in advance
bye
On Fri, 25 May 2012 18:15:45 +1000
Jim Lemon <jim at bitwrit.com.au> wrote:
> On 05/25/2012 02:45 AM, QAMAR MUHAMMAD UZAIR wrote:
>> ...
> > I want to reshape it in the following FORMAT
> >
> > 1967 1968 1969 1970 1971 1972
> 1973 1974
> > 1 0.87 0.87 0.87 0.87 0.71
> > 2 0.87 0.87 0.87 0.87 0.72
> >
> > OBVIOUSLY, I HAVE A LARGE AMOUNT OF DATA TO WORK
>WITH.i would also
> > like to take into account the effect of leap year. For
>example if
> > 1969 in a leap year then the column under it, has to
>have 1 extra
> > reading.
>
> Hi Qamar,
> You can do something like this, assuming that your data
>frame is named "qmu" and the two columns are named "V1"
>and "V2":
>
> # extract years from the dates
> qmu$year<-as.numeric(sapply(strsplit(as.character(qmu$V1),"[.]"),"[",3))
> # get a vector of the unique years
> uyears<-unique(qmu$year)
> # make an empty list
> newqmu<-list()
> # populate the list year by year
> for(i in 1:length(uyears))
>newqmu[[i]]<-qmu$V2[qmu$year==uyears[i]]
>
> This will give you a list with the same characteristics
>as you described. You can't have a data frame with
>different column lengths, so you would have to pad the
>shorter columns with NA values if you want a data frame.
>
> Jim
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
>reproducible code.
More information about the R-help
mailing list