[R] Variate

Duncan Mackay mackay at northnet.com.au
Tue Jun 5 04:29:49 CEST 2012


Hi Rui

You got in before me - time zone differences and other commitments

I have done a base graphics of my lattice with your data - it might 
give some more insight

  Sites <- 1:92
  windows(8,10)
  par(mfrow = c(12,8),
      mai = c(0,0,0,0)

  )
   invisible(

      sapply(seq_len(nc), function(j){
     i <- order(x1[, j])
     plot(1, type="n", xlim=c(min(x1), max(x1)), ylim=c(min(y1), max(y1)),
          axes = F,
          xlab="", ylab="")
     box()
     lines(x1[i, j], y1[i, j], col=colrs[j])
     points(x1[i, j], y1[i, j], col=colrs[j], cex = 0.7, pch=20)
     text(4,0.2,Sites[j], cex = 0.7)

     })

     )

Back to lattice
limits in lattice are controlled by xlim, ylim as a vector of the max 
and min as arguments to xyplot.
With the proviso of the scales argument relation = "same".

Further information at
http://lmdvr.r-forge.r-project.org/figures/figures.html


Regards

Duncan Mackay

At 19:51 4/06/2012, you wrote:
>Hello,
>
>Sorry for not understanding your problem, but it really seemed like homework.
>
>Now, when I answered scale(x) I meant it, it transforms a matrix in 
>(x - mean)/sd, column by column.
>If you're new to R, to use the on-line help the instruction is
>
>help("scale")
>?scale   # shortcut
>
>
>As for your graph, I agree with Duncan, 92 lines on the same graph 
>doesn't seem to be a good idea. Anyway, using base R, it could be 
>done along the lines of
>
>set.seed(1)
>nc <- 92  # number of columns
>nr <- 366  # number of rows
>x <- matrix(rexp(nr*nc), ncol=nc)
>
>x1 <- scale(x) # "z", standard normal (in fact, studentized)
>y1 <- apply(x, 2, plnorm)  # log-normal
>
>colrs <- rainbow(nc)
>plot(1, type="n", xlim=c(min(x1), max(x1)), ylim=c(min(y1), 
>max(y1)), xlab="", ylab="")
>
># if you want lines
>sapply(seq_len(nc), function(j){
>     i <- order(x1[, j])
>     lines(x1[i, j], y1[i, j], col=colrs[j])})
>
># if you want points
>sapply(seq_len(nc), function(j) points(x1[, j], y1[, j], 
>col=colrs[j], pch="."))
>
>
>Hope this helps,
>
>Rui Barradas
>
>Em 04-06-2012 07:38, eliza botto escreveu:
>>Dear Mc kay,
>>thankyou very much for your reply. we are extremly greatful to you. 
>>we actually wanted all on one scale. we want to compare them all on 
>>one axis. kindle see if you could help us on that. one more thing, 
>>does this practice give us normal reduced variant on x-axis because 
>>we stricktly want normal reduced variant on x-axis.
>>i hope you will cooperate.
>>
>>eliza botto
>>waters inn
>>
>>>Date: Mon, 4 Jun 2012 11:54:11 +1000
>>>To: r-help at r-project.org
>>>From: mackay at northnet.com.au
>>>Subject: Re: [R] Variate
>>>
>>>Hi Eliza
>>>
>>>You  will not want 1 panel with 96 lines - too confusing after about 20
>>>Instead 1 per panel or with groups using useOuterStrips  and
>>>combineLimits from latticeExtra  package
>>>
>>>Try this -- a minimal example with an 12 row 8 col grid done on the fly
>>>
>>>setseed(12)
>>>Sites<- 1:92
>>>dat<-
>>>data.frame(y = rep(rnorm(5),92), x = rep(1:5,92), site = 
>>>rep(Sites,each = 5))
>>>
>>>xyplot(y ~ x|site,dat,
>>>          as.table=T,
>>>          strip = F,
>>>          layout = c(8,12),
>>>          scales = list(x = list(alternating = 2),y=list(alternating=1)),
>>>          type = "b",
>>>          panel = function(x,y,...){
>>>                   pnl=panel.number()
>>>                   panel.xyplot(x,y,...)
>>>                   panel.text(4,-1.5,Sites[pnl], cex = 0.6)
>>>                 }
>>>)
>>>
>>>or with groupings for Site something like (untested)
>>>
>>>xyplot(y ~ x|groupings,dat,
>>>          as.table=T,
>>>          strip = F,
>>>          strip.left = T,
>>>          groups = site,
>>>          scales = list(x = list(alternating = 2),y=list(alternating=1)),
>>>          type = "b",
>>>          panel = function(x,y,...){
>>>                   pnl=panel.number()
>>>                   panel.xyplot(x,y,...)
>>>                   panel.text(4,-1.5,Sites[pnl], cex = 0.6)
>>>                 }
>>>)
>>>You will need an extra column for groupings
>>>
>>>This can also be done with the base plot function but lattice gives
>>>more flexibility, see  ?xyplot  and particularly par.settings into
>>>get things right size
>>>
>>>Regards
>>>
>>>Duncan
>>>
>>>
>>>Duncan Mackay
>>>Department of Agronomy and Soil Science
>>>University of New England
>>>Armidale NSW 2351
>>>Email: home: mackay at northnet.com.au
>>>
>>>
>>>At 11:01 4/06/2012, you wrote:
>>>>Content-Type: text/plain
>>>>Content-Disposition: inline
>>>>Content-length: 2431
>>>>
>>>>
>>>>
>>>>
>>>>Dear
>>>>R users,
>>>>
>>>>We
>>>>are working on a project called,"Environmental Impact Assessment".
>>>>We are stationed
>>>>at alpine regions of Ireland to see the impact of rainfall on
>>>>localities. We have
>>>>divided our study area into 92 stations. We have also collected 1 year data
>>> >from each station. Afterwards we placed data into a matrix in 
>>> such a way that
>>>>we got 366*92 matrix. 366 stands for number of days.
>>>>
>>>>What
>>>>we want is a lognormal probability plot, of each station(which is 
>>>>individual
>>>>column of matrix) with normal reduced variant on x-axis. In this
>>>>way, we should
>>>>be getting, at the end, 92 curves, one for each station, on same coordinate
>>>>axis.
>>>>
>>>>Kindly
>>>>help us on that. We are all very new to R.
>>>>
>>>>
>>>>
>>>>Eliza
>>>>botto
>>>>
>>>>Waters
>>>>Inn
>>>>
>>>>
>>>>
>>>>>CC: r-help at r-project.org
>>>>>From: dwinsemius at comcast.net
>>>>>To: eliza_botto at hotmail.com
>>>>>Subject: Re: [R] Log-normal probability plot
>>>>>Date: Sun, 3 Jun 2012 13:11:35 -0400
>>>>>
>>>>>
>>>>>On Jun 2, 2012, at 9:38 PM, eliza botto wrote:
>>>>>
>>>>>You might consider the strategy of reading the Posting Guide, followed
>>>>>by posting an intelligible message.
>>>>>
>>>>>>Dear R users,
>>>>>>
>>>>>>You can literally safe my
>>>>>>life my telling me the solution of my problem. I have created matrix
>>>>>>of a data
>>>>>>frame with 3 columns, with each column representing data of
>>>>>>different year.
>>>>>>
>>>>>>   2
>>>>>...snipped useless srting of numbers mangled by mailer processing of
>>>>>HTML.
>>>>>
>>>>>>4
>>>>>>
>>>>>>
>>>>>>I now want to plot "Lognormal
>>>>>>probability plot" of each column data against its respective "normal
>>>>>>reduced
>>>>>>variante(z)".
>>>>>"Normal reduced variate"? What is that? Is it a set of numbers that
>>>>>have been centered and scaled, also known as a z-transform? If so, I
>>>>>do not think it should affect the results of a probability plot since
>>>>>it is just a linear transformation and the theoretical quantiles will
>>>>>be unaffected.
>>>>>
>>>>>You might look at qqplot()
>>>>>
>>>>>>How to do that?
>>>>>>If you don't know the
>>>>>>answer, consider me dead.
>>>>>What greater lifesaving project are you trying to accomplish, ....
>>>>>other than getting homework done?
>>>>>>      [[alternative HTML version deleted]]
>>>>>
>>>>>--
>>>>>David Winsemius, MD
>>>>>West Hartford, CT
>>>>          [[alternative HTML version deleted]]
>>>>
>>>>
>>>>______________________________________________
>>>>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.
>>>______________________________________________
>>>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.
>>
>>         [[alternative HTML version deleted]]
>>
>>______________________________________________
>>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.
>
>______________________________________________
>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