[R] XYPlot Conditioning Variable in Specific, Non-Alphanumeric Order. -- Resending with corrected .txt file

Guy Jett GJett at itsi.com
Fri Mar 18 22:23:01 CET 2011


Due to an error on my part, I have renamed the previously attached file from 
  T_5-04b_LTC-SE-SO-Compared.csv to 
  T_5-04b_LTC-SE-SO-Compared.txt.  
It remains a comma-delimited file so the extension can be changed and used per the script, or loaded separately.
My sincere apologies,
Guy

-----Original Message-----
From: Guy Jett 
Sent: Friday, March 18, 2011 1:13 PM
To: 'r-help at R-project.org'
Subject: XYPlot Conditioning Variable in Specific, Non-Alphanumeric Order.

# I need to create an xyplot() where I control the specific order of #  both my conditioning variables.  The default code below plots the #  data correctly (dispersed across all 14 columns), but fails in two #  ways.  Both the primary conditioning variable (Transect), and the #  secondary conditioning variable (Offset) are in alphanumeric order, #  rather than the specific order I need.

# Here is a call to the input datafile, which should be attached.  You may rename that .txt file to .csv for processing in the following line.
    df <- read.csv(file = "T_5-04b_LTC-SE-SO-Compared.csv")

# Basic default plot (correct data, incorrect layout):
    xyplot((sbd+sed)/2 ~ Result | Offset+Transect, groups = PARLABEL, as.table = TRUE,
    data = df,
    layout = c(14,4), type = "b")

# I attempted to control the order following the method described in #  the thread "[R] xyplot() - can you control how the plots are #  ordered?", but I appear to be missing, or misunderstanding #  something.  The modeled code is here.  It does put all the #  individual 'lattices'(?) in the needed order, BUT the graphics #  for the individual sets dump all the measurements into a single #  cell, on the diagonal, as if it's treating the conditioning #  variables as an [i,j] index.  Again not what I want.

#  Draft code (incorrect data, correct layout):
    Transects <- c("LNF02", "LSF02", "LUR01", "LURT1", "LUR03",
                   "LUR05", "LUR09", "LUR11", "LUR12", "LUR15",
                   "LUR16", "LUR21", "LURT3", "LUR25", "LURT4",
                   "LUR28", "LUR36", "LUR38", "LUR46", "LURT5",
                   "LUR48", "LLR04", "LLR10", "LLR11", "LLRT1",
                   "LLR17", "LLRT2", "LLR18", "LLRT3", "LLR19")
    Transects <- factor(Transects, levels = Transects)

    Offsets <- c("T", "U", "V", "Y", "Z", "A", "B", "C", "D", "E", "F", "G", "H")
    Offsets <- factor(Offsets, levels = Offsets)

    xyplot((sbd+sed)/2 ~ Result | Offsets+Transects, groups = PARLABEL, as.table = TRUE,
    data = df,
    layout = c(13,5), type = "b")

# What I am looking for is a combination of the default plot, but ordered in #  the layout of the second code fragment.

# Baring my likely misunderstanding of the example cited above, #  there several comments in the help files that index.cond and/or #  param.cond could be 'easily' used.  I have read the lattice help, #  the lattice pdf, and many items in the R site help files.  The #  use of these features remains a complete mystery to me, but #  then, that doesn't surprise me at all.

# This should clean up anything created by the above scripts:
# Clean-up ----------------------------------------------------------------
  rm(df, xLabel, yLabel, xlimit)

Thanks for all the help.
Cheers,
Guy Jett, R.G.
Project Geologist
gjett at itsi.com

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: T_5-04b_LTC-SE-SO-Compared.txt
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110318/245124c5/attachment.txt>


More information about the R-help mailing list