Re: [R] trajectory plot (growth curve)

2010-08-23 Thread Kingsford Jones
x27;, 'l'), key = mykey) > > Defining the key externally modularizes the problem, lets one define > the features one wants to contain, and simplifies the high-level > xyplot() call. > > There is a type = 'a' (shorthand for panel.average()) that can be > us

Re: [R] trajectory plot (growth curve)

2010-08-23 Thread Kingsford Jones
lass = "data.frame") #adding another subject to introduce replicates id3 <- data.frame(ID=as.factor(rep(3, 4)),time = c(1, 1.5, 2, 5.5), y = c(1, 2.2, 3, 2)) dat <- rbind(dat, id3) mean.y <- aggregate(formula = y ~ time, data = dat,

Re: [R] trajectory plot (growth curve)

2010-08-23 Thread Kingsford Jones
, "y"), row.names = c(NA, -7L), class = "data.frame") library(lattice) xyplot(y ~ time|ID, data = dat, type = 'l') xyplot(y ~ time, data = dat, group = ID, type = 'l') library(ggplot2) qplot(time, y, data = dat, facets = .~ID, geom = 'line') qplot(ti

Re: [R] Figures in Latex

2010-07-23 Thread Kingsford Jones
to make the desired within R's plotting device rather than in latex try: par(mfrow = c(3, 2)) and you'll probably want to adjust other mar, parameters as well (e.g. mar, cex.lab, etc). Or, take advantage of the flexibility offered by the graphics package by studying ?layout hth, Kingsford On

Re: [R] Tutorial Tinn-R

2010-07-23 Thread Kingsford Jones
re, and Tinn-R is now my favorite interface to R under Windows. Yesterday I used the document comparison tool for the first time (Tools > Differences) ...very nice. Kingsford Jones On Fri, Jul 23, 2010 at 10:55 AM, Bert Gunter wrote: > Google on "tinn-r tutorial." However, I belie

Re: [R] Multilevel survival model

2010-07-22 Thread Kingsford Jones
On Thu, Jul 22, 2010 at 8:23 AM, Christopher David Desjardins wrote: > * Please cc me if you reply as I am a digest subscriber * > > Hi, > I am wondering how I can run a multilevel survival model in R? Below is > some of my data. > >> head(bi0.test) >  childid famid lifedxm     sex      age delta

Re: [R] Heterogeneous variance in two-way mixed ANOVA

2010-07-22 Thread Kingsford Jones
Can't give more specific advice without more information (see the posting guide), but I suspect you want to use nlme::lme, specifying a weights argument to adjust for the heterogeneity. Kingsford On Wed, Jul 21, 2010 at 11:10 PM, Kline, Keith A wrote: > I have heterogeneous variance in a two-way

Re: [R] xtable

2010-07-22 Thread Kingsford Jones
not an xtable solution, but R2HTML::HTML has an impressive list of methods, including HTML.infl: lm.SR <- lm(sr ~ pop15 + pop75 + dpi + ddpi, data = LifeCycleSavings) influencia <- influence.measures(lm.SR) library(R2HTML) methods(HTML) HTML(influencia, 'influencia.html') and open the html file i

Re: [R] data from SpatialGridDataFrame

2010-07-20 Thread Kingsford Jones
see ?sp::overlay and section 5.2 of Applied Spatial Data Analysis with R I see there is now also raster::overlay, but I can't claim experience with that funciton (however my impression is that the raster package is a powerful tool for working with potentially very large rasters in R). hth, Kingsf

Re: [R] Help with Reshaping from Wide to Long

2010-07-20 Thread Kingsford Jones
sponse and limited sample size (both terms of number of subjects and conflation between error and interaction) makes me think fitting a meaningful model is not trivial. Off the cuff, perhaps a beta or binomial model or using logit-transformed Accuracy (noting that nothing can retrieve the &#

Re: [R] Indexing by logical vectors

2010-07-20 Thread Kingsford Jones
t;Z" However, given the long history of S/R, there must be logical or philosophical obstacles to this...? best, Kingsford Jones >> -Original Message- >> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On >> Behalf Of Christian Raschke >&g

Re: [R] xyplot: key inside the plot region / lme: confidence bands for predicted

2010-07-07 Thread Kingsford Jones
ite a bit. Here's a recent conversation: <http://comments.gmane.org/gmane.comp.lang.r.lme4.devel/3291> hope it helps, Kingsford Jones > > My working example is: > > library(nlme) > library(lattice) > > Ortho <- Orthodont > Ortho$year <- Ortho$age - 8  # make intercept

Re: [R] Some questions about R's modelling algebra

2010-07-05 Thread Kingsford Jones
On Fri, Jul 2, 2010 at 8:16 AM, Hadley Wickham wrote: >> ?formula in R 2.9.2 says in para 2: >> "The %in% operator indicates that the terms on its left are nested >> within those on the right. For example a + b %in% a expands to the >> formula a + a:b. " > > Ooops, missed that.  So b %in% a = a:b,

Re: [R] use of random and nested factors in lme

2010-04-05 Thread Kingsford Jones
ives the gist of concepts. > random = ~1|R+N > > or direct me to an overview regarding notation of these formulas in lme > (package nlme)? The help files weren't exactly clear to me on this subject. IMO Pinheiro and Bates' companion book to nlme is a prerequisite for efficient

Re: [R] two questions for R beginners

2010-02-27 Thread Kingsford Jones
nk the real 'a-ha' moments came by interactively exploring objects within R. This was vastly facilitated by the use of str and indexing tools ([, [[, $, @). A mantra for R beginners might be "In R we work with objects, and str reveals their essence" ;-) Kingsford Jones >

Re: [R] Use of R in clinical trials

2010-02-21 Thread Kingsford Jones
, TARSIER, ZORILLA, GENSTAT, and STORM, among others. best, Kingsford Jones On Thu, Feb 18, 2010 at 9:05 PM, wrote: > > I am old enough to have lived through this particular transition. > Prior to the advent of SAS, trials were analyzed by in-house written > programs (usually in F

Re: [R] population variance and sample variance

2010-02-04 Thread Kingsford Jones
e, and >>> divide by n-1 when estimating a population standard deviation (your >>> initial description had it backwards I think). >>> >>> On Tue, Feb 2, 2010 at 5:25 PM, Peng Yu wrote: >>> > On Mon, Oct 19, 2009 at 12:53 PM, Kingsford Jones >>

Re: [R] population variance and sample variance

2010-02-04 Thread Kingsford Jones
On Tue, Feb 2, 2010 at 10:25 AM, Peng Yu wrote: > On Mon, Oct 19, 2009 at 12:53 PM, Kingsford Jones > wrote: >>> sum((x-mean(x))^2)/(n) >> [1] 0.4894708 >>> ((n-1)/n) * var(x) >> [1] 0.4894708 > > But this is not a built-in function in R to do so, rig

Re: [R] extracting estimated covariance parameters from lme fit

2009-11-16 Thread Kingsford Jones
imnames")=List of 2 # ..$ : chr [1:3] "(Intercept)" "age" "Residual" # ..$ : chr [1:3] "Variance" "StdDev" "Corr" # - attr(*, "title")= chr "Subject = pdLogChol(1 + age)" (sigma2.age <- as.numeric(vc[2, 1])) # [

Re: [R] How to display full name for the coefficients/factors in summary()?

2009-11-03 Thread Kingsford Jones
By default orthogonal polynomial contrasts are used for ordered factors. Drop the 'ordered = TRUE' and you will get treatment contrasts. hth, Kingsford Jones On Tue, Nov 3, 2009 at 8:52 AM, Jen-Chien Chang wrote: > Hi, > > I am wondering if there is a way to display t

Re: [R] Robust ANOVA or alternative test?

2009-11-02 Thread Kingsford Jones
See the nlme library and accompanying book by Pinheiro and Bates. The lme function is appropriate for linear mixed models with normal errors, and the 'weights' argument provides flexible methods for modeling error heterogeneity. hth, Kingsford On Mon, Nov 2, 2009 at 12:10 PM, jinyan fan wrote:

Re: [R] Easy method to set user-mode virtual memory space in Windows Vista and 7

2009-10-30 Thread Kingsford Jones
Thank you for the response, Prof Ripley. Some comments below On Fri, Oct 30, 2009 at 9:27 AM, Prof Brian Ripley wrote: > On Wed, 28 Oct 2009, Kingsford Jones wrote: > >> I thought I'd share this with the list since it appears to provide a >> quick fix to some memory prob

[R] Easy method to set user-mode virtual memory space in Windows Vista and 7

2009-10-28 Thread Kingsford Jones
ages of using this method *please* post a response. best, Kingsford Jones __ R-help@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

Re: [R] how do I plot a regression curve with the data?

2009-10-28 Thread Kingsford Jones
On Wed, Oct 28, 2009 at 9:23 AM, Tom Gottfried wrote: > ?curve > > regards, > Tom and I was in the process of writing a curve example when I noticed Tom sent this. Here it is: set.seed(777) x <- runif(100, 0, 100) y <- 10*x + x^2 - .01*x^3 + rnorm(100, 0, 500) fit <- lm(y ~ x + I(x^2) + I(x^3))

Re: [R] explalinig the output of my linear model analysis

2009-10-27 Thread Kingsford Jones
...which would complement the apropos fortune from John Fox: > library(fortunes) > fortune('dangerous') If you give people a linear model function you give them something dangerous. -- John Fox useR! 2004, Vienna (May 2004) On Tue, Oct 27, 2009 at 12:48 PM, Rolf Turner wrote: > > On

Re: [R] lasso plot using LARS

2009-10-27 Thread Kingsford Jones
Within the plot.lars code, change the type argument to matplot from 'b' to 'l': library(lars) myplot.lars <- edit(plot.lars) #change type = 'b' to type = 'l' in the call to matplot data(diabetes) object <- with(diabetes, lars(x,y)) myplot.lars(obj

Re: [R] interpretation of RCS 'coefs' and 'knots'

2009-10-24 Thread Kingsford Jones
Perhaps functional data analysis would be of interest. See, for example, package fda. Kingsford On Fri, Oct 23, 2009 at 4:46 PM, Dylan Beaudette wrote: > Hi, > > I have fit a series of ols() models, by group, in this manner: > > l <- ols(y ~ rcs(x, 4)) > > ... where the series of 'x' values in

Re: [R] removing random effect from nlme or using varPower() in nls

2009-10-22 Thread Kingsford Jones
help(gnls, pack=nlme) hth, Kingsford Jones On Thu, Oct 22, 2009 at 4:36 PM, Michael A. Gilchrist wrote: > Hello, > > I've been fitting a random effects model using nlme to some data, but I am > discovering that the variation in my random effect is very small.  As a > res

Re: [R] Missing data and LME models and diagnostic plots

2009-10-21 Thread Kingsford Jones
Mixed models based on likelihood methods can often handle missing observations within subjects, but they not do well with missing individual elements in the design matrices (think unit nonresponse vs item nonresponse in the survey world). Continuing with the example I recently sent to you set.see

Re: [R] Question on mixed effect models with LME

2009-10-21 Thread Kingsford Jones
dom=~1|school) f2 <- update(f1, . ~ year.c*tmt) summary(f1)$corFixed['year', '(Intercept)'] # [1] -0.997 summary(f2)$corFixed['year.c', '(Intercept)'] # [1] 0 A possibility is that the data are not of the expected classes. What does str(long) report? h

Re: [R] ScatterPlot

2009-10-20 Thread Kingsford Jones
= 2, lty = 2) abline(f2, col = 3, lty = 3) legend('topleft', c('male', 'female'), lty = 2:3, col = 2:3) For some fancier plots see the ggplot2 examples here: http://had.co.nz/ggplot2/stat_smooth.html hth, Kingsford Jones On Tue, Oct 20, 2009 at 1:20 PM, Marsha Me

Re: [R] Interpretation of VarCorr results

2009-10-20 Thread Kingsford Jones
On Tue, Oct 20, 2009 at 5:09 AM, r-quantide wrote: [snip] > .         Is there any methods/functions to obtain the variance components > for the station factor too? (please, give me some references, at least.) Pinheiro and Bates 2000 is (practically) a prerequisite for intelligent use of the nlme

Re: [R] Interpretation of VarCorr results

2009-10-20 Thread Kingsford Jones
ease, give me some references, at least.) > With the proper design (i.e. enough data in the appropriate levels) you might specify something like: random = ~N + station - 1|spliceOrHoming To get estimates of the between group variation for each of the levels of the station factor, as well a

Re: [R] What an element in loading is missing? (princomp)

2009-10-19 Thread Kingsford Jones
Peng, It's generally useful to know the class of the object you are working with, and the methods available for that class. This would have led you to the 'loadings' help page. > class(pca_result$loadings) [1] "loadings" > methods(class='loadings') [1] print.loadings* Non-visible functions a

Re: [R] population variance and sample variance

2009-10-19 Thread Kingsford Jones
> sum((x-mean(x))^2)/(n) [1] 0.4894708 > ((n-1)/n) * var(x) [1] 0.4894708 hth, Kingsford On Mon, Oct 19, 2009 at 9:30 AM, Peng Yu wrote: > It seems that var() computes sample variance. It is straight forward > to compute population variance from sample variance. However, I feel > that it is sti

Re: [R] Proper syntax for using varConstPower in nlme

2009-10-18 Thread Kingsford Jones
ce covariate such as ~age, there is no need for updating of the variance covariate during optimization. hth, Kingsford Jones > > Thanks. > > Mike > > On Fri, 16 Oct 2009, Dieter Menne wrote: > >> >> >> >> Michael A. Gilchrist wrote: >>> >&g

Re: [R] Introduction to mark-recapture analysis in R?

2009-10-13 Thread Kingsford Jones
see https://stat.ethz.ch/pipermail/r-sig-ecology/2008-May/000160.html hth, Kingsford On Tue, Oct 13, 2009 at 6:00 AM, Anne-Katrin Link wrote: > Normal        0        21                        false        false > false > MicrosoftInternetExplorer4 > > > Dear R-helpers, > >          I was wond

Re: [R] interpreting glmer results

2009-10-05 Thread Kingsford Jones
ance parameter space. - It seems the issue of counting the number of parameters being estimated will be an issue when comparing models that differ in their random effects. best, Kingsford Jones > > -- Bert > > hth, > > Kingsford > > > >> Many thanks

Re: [R] interpreting glmer results

2009-10-05 Thread Kingsford Jones
On Mon, Oct 5, 2009 at 8:52 AM, Umesh Srinivasan wrote: > Hi all, [snip] > > Fixed effects: >             Estimate Std. Error z value Pr(>|z|) > (Intercept) -138.8423     0.4704  -295.1  < 2e-16 *** > SpeciesCr     -0.9977     0.6259    -1.6  0.11091 > SpeciesDb     -1.2140     0.6945    -1.7  0.0

Re: [R] How to plot a Quadratic Model?

2009-10-05 Thread Kingsford Jones
see ?curve e.g. qftn <- function(x) 1 + 2*x - .1*x^2 curve(qftn, 0, 10) hth, Kingsford On Mon, Oct 5, 2009 at 9:42 AM, Juliano van Melis wrote: > Good day for all, > > I'm a beginner aRgonaut, thus I'm having a problem to plot a quadratic model > of regression in a plot. > First I wrote: > >>

Re: [R] AIC and goodness of prediction - was: Re: goodness of "prediction" using a model (lm, glm, gam, brt,

2009-09-11 Thread Kingsford Jones
itting process. Also, the general definition of AIC uses likelihoods not SS residuals. Also, using the SS resids you are once again back to a linear transormation of the MSE estimate... Kingsford > What do you / other R list members think? > > Regards > > On Thursday 03 Septembe

Re: [R] How Does One Use the Value of Density Function?

2009-09-07 Thread Kingsford Jones
On Mon, Sep 7, 2009 at 12:42 AM, Gundala Viswanath wrote: > How do people usually use the result of density function (e.g. dnorm)? > Especially when its value can be greater than 1. > > What do they do with such density >1? > >> dnorm(2.02,2,.24) > [1] 1.656498 There are countless uses. E.g., wh

Re: [R] how do I draw this surface -- hand drawn in the attachemtn

2009-09-07 Thread Kingsford Jones
for example... x <- y <- seq(.1, 2, .1) ftn <- function(x, y) x - .25*x^2 z <- outer(x, y, ftn) persp(x, y, z, theta = 330, phi = 30) hth, Kingsford On Sun, Sep 6, 2009 at 8:28 AM, Steve Lianoglou wrote: > Hi, > > On Sat, Sep 5, 2009 at 5:16 AM, gallon li wrote: >> Basially I have the observa

Re: [R] Using anova(f1, f2) to compare lmer models yields seemingly erroneous Chisq = 0, p = 1

2009-09-07 Thread Kingsford Jones
On Mon, Sep 7, 2009 at 10:34 AM, Alain Zuur wrote: > > > > rapton wrote: >> >> Hello, >> >> I am using R to analyze a large multilevel data set, using >> lmer() to model my data, and using anova() to compare the fit of various >> models.  When I run two models, the output of each model is generated

Re: [R] goodness of "prediction" using a model (lm, glm, gam, brt, regression tree .... )

2009-09-03 Thread Kingsford Jones
There are many ways to measure prediction quality, and what you choose depends on the data and your goals. A common measure for a quantitative response is mean squared error (i.e. 1/n * sum((observed - predicted)^2)) which incorporates bias and variance. Common terms for what you are looking for

Re: [R] understanding the output from gls

2009-09-02 Thread Kingsford Jones
ellipse with elongation determined by the covariance. hth, Kingsford > Tim Handley > Fire Effects Monitor > Santa Monica Mountains National Recreation Area > 401 W. Hillcrest Dr. > Thousand Oaks, CA 91360 > 805-370-2347 > > > &

Re: [R] understanding the output from gls

2009-09-01 Thread Kingsford Jones
This will generally have non-zero off-diagonals, implying the fixed effects estimates are correlated. The values you're inquiring about are the scaled estimates of those off-diagonals. hth, Kingsford Jones > > ##More detailed information > ##function calls: >  sppl.i.xx = gls(all.all.rc

Re: [R] Syntax for crossed random effects in nlme

2009-09-01 Thread Kingsford Jones
Hi Ben, Pinheiro and Bates 2000 is the "real" documentation for nlme. See the Cell Culture Bioassay example starting on pg 163 for a demonstration of fitting crossed random effects using pdIdent and pdBlocked objects. hth, Kingsford On Tue, Sep 1, 2009 at 6:44 AM, bamsel wrote: > > Hello R user

Re: [R] how to generate a random correlation matrix with restrictions

2009-08-29 Thread Kingsford Jones
ations are uniformly > distributed. > > Hope this helps, > Ravi. > > > > Ravi Varadhan, Ph.D. > Assistant Professor, > Division of Geriatric Medicine and Gerontology > School of Medicine > Johns Hopki

Re: [R] how to generate a random correlation matrix with restrictions

2009-08-28 Thread Kingsford Jones
28, 2009 at 7:36 PM, Kingsford Jones wrote: >  R <- matrix(runif(1), ncol=100) > > hth, > > Kingsford Jones > > On Fri, Aug 28, 2009 at 7:26 PM, Ning Ma wrote: >> Hi, >> >> How can I generate a random 100x100 correlation matrix, R={r_ij}, >> whe

Re: [R] how to generate a random correlation matrix with restrictions

2009-08-28 Thread Kingsford Jones
R <- matrix(runif(1), ncol=100) hth, Kingsford Jones On Fri, Aug 28, 2009 at 7:26 PM, Ning Ma wrote: > Hi, > > How can I generate a random 100x100 correlation matrix, R={r_ij}, > where about 10% of r_ij are greater than 0.9 > &

Re: [R] Google's R Style Guide

2009-08-28 Thread Kingsford Jones
hould be MakeColName(...) -- I was happy to see promotion of "<-". Reading code using '=' for both object assignment and argument setting is a little like fingernails on a blackboard...again and again and... -- It's nice that people have made these guides available

Re: [R] r2 question

2009-07-28 Thread Kingsford Jones
example(plotmath) hth, Kingsford Jones On Sat, Jul 25, 2009 at 6:25 AM, Buckmaster, Sarah wrote: > Hi everyone, > > I have a question about calculating r-squared in R. I have tried searching > the archives and couldn't find what I was looking for - but apologies if > there

Re: [R] Check functions in package

2009-07-28 Thread Kingsford Jones
a couple more options: > ls("package:glmnet") [1] "coef.glmnet" "glmnet" "jerr" "nonzeroCoef" "plot.glmnet" [6] "plotCoef""predict.elnet" "predict.glmnet" "predict.lognet" "predict.multnet" [11] "print.glmnet" > # or > ls(pos = 2) [1] "coef.glmnet" "glmnet"

Re: [R] R package for Hierarchical Modelling of Multinomial Logistic Regression

2009-07-28 Thread Kingsford Jones
See the Bayesian Task View http://cran.r-project.org/web/views/Bayesian.html which will lead you to the arm and bayesm packages, among others. hth, Kingsford On Tue, Jul 28, 2009 at 1:54 AM, nikolay12 wrote: > > Hello, > > I need to implement a hierarchical model for Bayesian multinomial logist

Re: [R] ggplot2 : commands on one line vs two lines.

2009-07-23 Thread Kingsford Jones
geom_segment() + labs(x="Area", y="Povs") pb1 hth, Kingsford Jones On Thu, Jul 23, 2009 at 5:13 PM, John Kane wrote: > > I have just started using ggplot2 and I seem to be doing something stupid > in writing ggplot2 commands on more than one line. > > I

Re: [R] setting up LMER for repeated measures and how do I get a p value for my fixed effect, group?

2009-07-23 Thread Kingsford Jones
On Thu, Jul 23, 2009 at 12:36 PM, Kingsford Jones wrote: > > As you might have suspected from the lmer t-value close to 0, the > associated p-value is about .5. you can ignore the sentence above -- it's a two sided test and the t-value is not that close to 0... > > hth,

Re: [R] setting up LMER for repeated measures and how do I get a p value for my fixed effect, group?

2009-07-23 Thread Kingsford Jones
lme: fit2 <- aov(Value ~ Group + Error(SS), data = smallDS) #or library(nlme) fit3 <- lme(Value ~ Group, data = smallDS, random = ~1|SS) As you might have suspected from the lmer t-value close to 0, the associated p-value is about .5. hth, Kingsford Jones > My subjects are divide

Re: [R] Problem with GroupedData

2009-07-14 Thread Kingsford Jones
ture. My opinion is that code is much clearer if modeling and plotting calls do not implicitly rely on a non-standard data structure. hth, Kingsford Jones On Tue, Jul 14, 2009 at 8:54 AM, FMH wrote: > Hi, > > I have an original data frame with 8 columns of variables, which are stored

Re: [R] Degree of freedom in the linear mixed effect model using lme function in R

2009-07-10 Thread Kingsford Jones
the r-sig-mixed-models list. hoping it helps, Kingsford Jones On Fri, Jul 10, 2009 at 9:27 AM, Djibril Dayamba wrote: > Hello, > I would appreciate if somebody could help me clear my mind about the below > issues. > I have a factorial experiment to study the effects of Grazing an

Re: [R] corspatial

2009-07-09 Thread Kingsford Jones
nd there should not be > any zero distances. Any idea? The error does suggest the function thinks there are duplicates in lonlat. Have you tried, for example, sum(duplicated(lonlat))? Or you could add a small amount of random noise to one of the coordi

Re: [R] how to read point shp file to R?

2009-07-07 Thread Kingsford Jones
Assuming you are referring to ESRI shapefiles, options can be found in the following packages: maptools, rgdal, and shapefiles See the Spatial Task View for more info: http://cran.r-project.org/web/views/Spatial.html hth, Kingsford On Tue, Jul 7, 2009 at 12:28 PM, Sunny wrote: > I am new with R

Re: [R] Using by() and stacking back sub-data frames to one data frame

2009-06-24 Thread Kingsford Jones
try do.call(rbind, yourByList) hth, Kingsford Jones On Wed, Jun 24, 2009 at 9:34 PM, Stephan Lindner wrote: > Dear all, > > > I have a code where I subset a data frame to match entries within > levels of an factor (actually, the full script uses three difference > factors do

Re: [R] lapply across using multiple columns

2009-06-23 Thread Kingsford Jones
try: dfr <- data.frame(A=rnorm(50), B=runif(50), X=factor(sample(c('L1','L2'),50,repl=TRUE))) by(dfr[, 1:2], dfr$X, mean) hth, Kingsford Jones On Tue, Jun 23, 2009 at 7:57 PM, R_help Help wrote: > Hi, > > To set a simple an clear picture of what I'

Re: [R] Partitioning matrix

2009-06-23 Thread Kingsford Jones
see ?"[" and notice the 'drop' argument. So in your example try dat[1, , drop=FALSE] hth, Kingsford On Tue, Jun 23, 2009 at 1:13 AM, Bogaso wrote: > > Let say, I have following matrix : > > dat <- matrix(rnorm(40), 2, 20) > > Now I want to partition this like this : > > dat1 <- dat[1,] > da

Re: [R] Smart way to check if a column with certain name exists in a data.frame

2009-06-22 Thread Kingsford Jones
try: 'x' %in% colnames(df) hth, Kingsford On Mon, Jun 22, 2009 at 9:17 PM, R_help Help wrote: > Hi, > > I have a matrix or data.frame (df). When I would like to check if a column > named "x" exists, it becomes my habit to do the following: > > if (length(which(colnames(df)=="x"))>0) > > Is there

Re: [R] maps maptools

2009-06-22 Thread Kingsford Jones
he spatial Task View http://cran.r-project.org/web/views/Spatial.html and an active spatial mailing list https://www.stat.math.ethz.ch/mailman/listinfo/R-SIG-Geo/ hth, Kingsford Jones On Mon, Jun 22, 2009 at 1:01 PM, John Lipkins wrote: > Hey, > > A basic question. Is there anyone tha

Re: [R] how to apply the dummy coding rule in a dataframe with complete factor levels to another dataframe with incomplete factor levels?

2009-06-20 Thread Kingsford Jones
1 1 010 3 1 1 010 attr(,"assign") [1] 0 1 1 2 2 attr(,"contrasts") attr(,"contrasts")$f1 [1] "contr.treatment" attr(,"contrasts")$f2 [1] "contr.treatment" hth, Kingsford Jones On Fri, Jun 19, 2009 at

Re: [R] latex subscripts in title of a plot

2009-06-07 Thread Kingsford Jones
Hi Dajiang, try plot(1, main=expression(beta[1])) and, more generally, see ?plotmath or demo(plotmath) Kingsford Jones On Sun, Jun 7, 2009 at 4:43 PM, Dajiang Jeff Liu wrote: > Dear All, > I want to ask how to make latex symbol \beta_1 into the title of the page. > The usual bq

Re: [R] How to google for R stuff?

2009-05-20 Thread Kingsford Jones
position of the firefox search bar so that on my windows box I can Ctrl-Tab to firefox, then Ctrl-K to search R sites. hth, Kingsford Jones On Wed, May 20, 2009 at 3:05 PM, Kynn Jones wrote: > Thank you all very much for the so many useful ideas and resources. > KJ > >        [[alte

Re: [R] qqnorm.lme & pairs.lme

2009-04-23 Thread Kingsford Jones
The model has multiple levels of random effects, so you need to tell qqnorm.lme which one you're interested in. e.g. qqnorm(m1, ~ranef(., level=1)) hth, Kingsford Jones On Thu, Apr 23, 2009 at 11:03 AM, Patrick Zimmerman wrote: > Hello, > > I am trying to do some plotting t

Re: [R] surface interpolating 3d

2009-04-23 Thread Kingsford Jones
, Kingsford Jones On Thu, Apr 23, 2009 at 7:15 AM, calpeda wrote: > > Hi all, > > When you want to draw a surface with a mathematics program you need of two > vectors x and y and a matrix z. Then you plot the surface. > For example: > x=[1 2 3]; > y=[5 6 7]; > z=[1 2 3 >

Re: [R] converting histogram to barchart

2009-04-22 Thread Kingsford Jones
ensities. Also, you may need to adjust the ylim and xlim arguments if the densities from your two samples are dissimilar. As for converting the histogram to a bar plot -- I think that's an aberration best left in Excel... hope it helps, Kingsford Jones On Wed, Apr 22, 2009 at 2:56 AM,

Re: [R] Color coded 3D plot

2009-04-21 Thread Kingsford Jones
The attachment didn't come through, but try: example(filled.countour) #or library(lattice) example(levelplot) hth, Kingsford Jones On Tue, Apr 21, 2009 at 9:46 PM, wrote: > I wonder whether it is possible  in R to generate color-coded 3D plots, like > the attached example. &g

Re: [R] How to handle tabular form data in lmer without expanding the data into binary outcome form?

2009-04-10 Thread Kingsford Jones
See ?lmer and notice model gm1 in the examples. As with glm, a binomial lmer model can have the response specified "as a two-column matrix with the columns giving the numbers of successes and failures". hth, Kingsford Jones On Fri, Apr 10, 2009 at 2:48 PM, Sean Zhang wrote: >

Re: [R] Determine the Length of the Longest Word in a String

2009-04-10 Thread Kingsford Jones
point you can just do > max(nchar(shadvector)) [1] 9 hth, Kingsford Jones >> shadvlength <- lapply(shadvector,nchar) >> shadmaxind <- which.max(shadvlength) ## Maximum element >> shadmax <- nchar(shadvector[shadmaxind]) >> shadmax > [1] 9 &

Re: [R] Help plotting image to window without margin

2009-04-08 Thread Kingsford Jones
See 'mar' under ?par e.g., x <- y <- -100:100 z <- outer(x, y, function(x,y) sqrt(x^2 + y^2)) par(mar=c(0,0,0,0)) image(x,y,z) hth, Kingsford Jones On Wed, Apr 8, 2009 at 9:07 PM, Bob Meglen wrote: > I am using several scripts that employ various packages to proce

Re: [R] Post-hoc and planned comparisons for repeated measures

2009-03-29 Thread Kingsford Jones
rgument to specify linear combinations of the coefficients to be tested to be 0. Kingsford On Sun, Mar 29, 2009 at 11:57 AM, Kingsford Jones wrote: > Hi Dwight, > > The answer likely depends on how you are fitting the model.  Have a > look at the multcomp package and its vignettes to see i

Re: [R] Post-hoc and planned comparisons for repeated measures

2009-03-29 Thread Kingsford Jones
Hi Dwight, The answer likely depends on how you are fitting the model. Have a look at the multcomp package and its vignettes to see if it can handle the model class you are interested in. hth, Kingsford Jones On Sun, Mar 29, 2009 at 11:11 AM, Krehbiel, Dwight wrote: > Dear colleag

Re: [R] re form data for aov()?

2009-03-29 Thread Kingsford Jones
lts are tests for differences of each method from Alcohol.Spray. There are many other options for setting up the design matrix to test hypotheses of interest, and for making adjustments for multiple testing. Hope that helps, Kingsford Jones On Sun, Mar 29, 2009 at 11:01 AM, Dan Kelley wrote: >

Re: [R] Extracting SD of random effects from lme object

2009-03-23 Thread Kingsford Jones
.051269 Standard Deviations: 2.327 0.22643 One way to extract the standard deviations shown by the print method above is: > diag(sqrt(getVarCov(fm1))) (Intercept) age 2.3270339 0.2264276 Warning message: In sqrt(getVarCov(fm1)) : NaNs produced And to get

Re: [R] Basic regression output question

2009-03-23 Thread Kingsford Jones
)[50])[1,4] > > Error in `[.default`((coef(summary(lm(t(returns2) ~ factors)))[50]), 1, > : >  incorrect number of dimensions Use of the 'str' function will reveal you are indexing a list element, so try

Re: [R] persp plot + plotting grid lines

2009-03-15 Thread Kingsford Jones
x,y, peaks) z2 <- 10 * round(c(z) + abs(min(z)) + 1) jet.colors = colorRampPalette(c("#7F", "blue", "#007FFF", "cyan", "#7FFF7F", "yellow", "#FF7F00", "red", "#7F")) color <- jet.colors(160)[z2]

Re: [R] Selecting / creating unique colours for behavioural / transitional data

2009-03-14 Thread Kingsford Jones
;wheat3" > ... >> ##chr [1:4] "tomato1" "yellow1" "green" "blue" >> >> attach(dd) >> seqiplot(data.seq[1:4,], withlegend=FALSE, ylab="Seal ID", > + axes = F, title = "30-09-2008", cpal=mycols) > There wer

Re: [R] Selecting / creating unique colours for behavioural / transitional data

2009-03-13 Thread Kingsford Jones
een",..: 3 4 2 1 > str(as.character(mycols$color.names)) chr [1:4] "tomato1" "yellow1" "green" "blue" hth, Kingsford > > Ross > > > > Kingsford Jones wrote: >> >> One option for creating your own palette is >>

Re: [R] code to find all distinct subsets of size r from a set of size n

2009-03-13 Thread Kingsford Jones
For permutations a couple of options are 'permutations' in package gtools, and 'urnsamples' in package prob hth, Kingsford Jones On Fri, Mar 13, 2009 at 6:35 AM, Dale Steele wrote: > I'm doing a permutation test and need to efficiently generate all > distinct

Re: [R] Selecting / creating unique colours for behavioural / transitional data

2009-03-13 Thread Kingsford Jones
he only thing i can do is > create my own palette, but i'm having limited success in trying to work out > how to do this. > > > Kingsford Jones wrote: >> >> Try >> >> #install.packages('RColorBrewer') >> example(brewer.pal, pack='RCo

Re: [R] Selecting / creating unique colours for behavioural / transitional data

2009-03-13 Thread Kingsford Jones
Try #install.packages('RColorBrewer') example(brewer.pal, pack='RColorBrewer') hth, Kingsford Jones On Fri, Mar 13, 2009 at 3:20 AM, Ross Culloch wrote: > > Dear all, > > This seems like a simple problem but i've searched the help files and tried > var

Re: [R] RES: North Arrow (.png file) on a Map

2009-03-11 Thread Kingsford Jones
Also, see # install.packages('sp') example('spplot', package='sp') Kingsford Jones On Wed, Mar 11, 2009 at 9:38 AM, Greg Snow wrote: > Another possibility is the my.symbols function in the TeachingDemos package.   > You can define a polygon of your arrow (o

Re: [R] lme anova() and model simplification

2009-03-09 Thread Kingsford Jones
unfortunately the issues are compounded by the sparseness of your data in the predictor space. hth, Kingsford Jones On Mon, Mar 9, 2009 at 4:44 PM, Menelaos Stavrinides wrote: > I am running an lme model with the main effects of four fixed variables (3 > continuous and one categorical – see belo

Re: [R] Zero distance error in corSpatial - correlation structure using lme

2009-03-09 Thread Kingsford Jones
y area (although the latter may be difficualt, depending on the spatial layout of your study). I don't know of a regression tool in R that allows for estimation of the spatial correlation strructure at levels higher than than the observations. Kingsford Jones On Mon, Mar 9, 2009 at 7:28 AM, Joh

Re: [R] repeated measures anova, sphericity, epsilon, etc

2009-03-09 Thread Kingsford Jones
n subjects are temporally or spatially correlated. Kingsford Jones On Mon, Mar 9, 2009 at 1:15 PM, Paul Gribble wrote: > After much research I've listed a couple of ways to do repeated measures > anova here: > > http://gribblelab.org/2009/03/09/repeated-measures-anova-using-

Re: [R] ANOVA

2009-03-05 Thread Kingsford Jones
e|Subject, weights=varPower()) plot(f1, distance~fitted(.)|Subject, abline=c(0,1)) intervals(f1) hth, Kingsford Jones >any other suggestion on dealing with this > problem is welcome. > > Thanks, > > -- > View this message in context: > http://www.nabble.com/ANOVA-tp2235

Re: [R] output formatting

2009-03-04 Thread Kingsford Jones
: M : B [1] 259 -- : H : B [1] 169 hth, Kingsford Jones On Wed, Mar 4, 2009 at 8:17 PM, Pele wrote: > > Hi R users, > > I have an R object with the following attributes: > >> str(s

Re: [R] listing functions in base package

2009-03-04 Thread Kingsford Jones
On Mar 4, 2009, at 10:26 PM, Kingsford Jones wrote: > > see > > https://stat.ethz.ch/pipermail/r-help/2008-January/151694.html > > hth, > Kingsford Jones > > On Wed, Mar 4, 2009 at 7:30 PM, Fuchs Ira wrote: >> How can I print the definition of a function that is in

Re: [R] listing functions in base package

2009-03-04 Thread Kingsford Jones
see https://stat.ethz.ch/pipermail/r-help/2008-January/151694.html hth, Kingsford Jones On Wed, Mar 4, 2009 at 7:30 PM, Fuchs Ira wrote: > How can I print the definition of a function that is in the base package? > > for example, if I type: > > which.min > > I get > &g

Re: [R] changing font size for y-axis factor labels

2009-03-04 Thread Kingsford Jones
Does cex.axis not work in that it reduces the size for both x and y axes? If that's the case try calling plot with axes=FALSE, and then add axes seperately with the axis function. Kingsford Jones On Wed, Mar 4, 2009 at 1:59 PM, Tiffany Vidal wrote: > I am trying to reduce the font si

Re: [R] how to create many variables at one time?

2009-03-04 Thread Kingsford Jones
try dat <- as.data.frame(replicate(100, rnorm(10))) hth, Kingsford Jones > >  Thanks~ > >        [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-hel

Re: [R] object ".trPaths" not found

2009-02-28 Thread Kingsford Jones
RSiteSearch('trpaths') will lead you to potential solutions... On Fri, Feb 27, 2009 at 7:18 PM, wrote: > I am running an R script with Tinn-R (2.2.0.1) and I get the error message > > Error in source(.trPaths[4], echo = TRUE, max.deparse.length = 150) : >  object ".trPaths" not found > > Any

Re: [R] windows vs. linux code

2009-02-25 Thread Kingsford Jones
X11() on my Vista machine running 2.8.1 seems to work the same as windows(). From the help page, the only difference I see is that 'X11' (and 'x11') have only width, height and pointsize arguments ('windows' has another 13). Kingsford On Wed, Feb 25, 2009 at 8:58 PM, Ted Harding wrote: > There

  1   2   >