Re: [R] predict

2009-07-29 Thread ONKELINX, Thierry
Newdata needs to be a dataframe with the same variable names as the explanatory variables in your models. Model <- lm(y ~ x, data = dataset) Newdata <- data.frame(x = seq(from=0.1, to=0.32,by=0.02)) Newdata$y <- predict(Model, newdata = Newdata) HTH, Thierry ---

Re: [R] What is the best method to produce means by categorical factors?

2009-07-30 Thread ONKELINX, Thierry
Dear Pat, Have a look at recast from the reshape package. library(reshape) dataset <- expand.grid(factor1 = c("A", "B"), factor2 = c("C", "D"), Rep = 1:3) dataset$variable1 <- rnorm(nrow(dataset)) dataset$variable2 <- rnorm(nrow(dataset), mean = 10) recast(factor1 + factor2 + variable ~ ., data =

Re: [R] what is the meaning of this error message?

2009-07-31 Thread ONKELINX, Thierry
Without your script we can't figure out what went wrong. ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section bi

Re: [R] lmer() and "$ operator is invalid for atomic vectors"

2009-07-31 Thread ONKELINX, Thierry
Dear Angela, I think you have to omit the last lamba in the lmer code. Is there a reason for putting it there? lmer.lamda <- lmer(lamda ~ Age*Item + ( 1 | Subject), data=new4) HTH, Thierry ir. Thierry Onkelinx Insti

Re: [R] Logistic regression and R

2009-07-31 Thread ONKELINX, Thierry
Dear Marlene, Have a look at the polr() function in the MASS package. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie

Re: [R] Getting file name from pdf device?

2009-07-31 Thread ONKELINX, Thierry
Dear Rainer, You could have a look at ggsave() from the ggplot2 package. I guess that such an approach to save a plot is easier to combine with a tool like pdftk. HTH, Thierry ir. Thierry Onkelinx Instituut voor natu

Re: [R] how can i delete a message in R-help?

2009-07-31 Thread ONKELINX, Thierry
You can't delete post for the mailing list. The posting guide reads: "Posters should be aware that the R lists are public discussion lists and anything you post will be archived and accessible via several websites for many years."

Re: [R] Scale set of 0 values returns NAN??

2009-08-03 Thread ONKELINX, Thierry
Dear Noah, You get Nan values because you devide by zero is all values are equal. So it does not only happen when you have only zero's. Try scale(rep(1, 10)) A workaround is to turn the scaling off when all values are identical (have zero variance). You can rearrange your nested loops with the (u

Re: [R] apply function to named numeric object

2009-08-03 Thread ONKELINX, Thierry
Dear Paulo, Your object is a named vector. Apply() and colMeans() only work on matrices and dataframes. So you need to convert the vector to a matrix or data.frame. See the example below. Please not that calculating the mean of one element is a waiste of time. # a named numerical vector object <-

Re: [R] lme funcion in R

2009-08-04 Thread ONKELINX, Thierry
Dear Harry, Your model seems rather complex. Do you have enough data to support it? Did you check for multicollinearity between the variables? HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoe

Re: [R] How to catch an error using try

2009-08-04 Thread ONKELINX, Thierry
Put your function in try() and the test it's class gene.seq <- try(getSequence (id=gene.map[,"ensembl_transcript_id"], type="ensembl_transcript_id", seqType="3utr", mart=hmart)) if(class(gene.seq) == "try-error"){ #code to run when an error occurs } else { #code to run when no er

Re: [R] matrix

2009-08-04 Thread ONKELINX, Thierry
Split the first column into two columns. One with the first letter and one with the last letter. Then you cast() from the reshape-package to create the matrix you want. HTH, Thierry ir. Thierry Onkelinx Instituut vo

Re: [R] labeling in qplot

2009-08-05 Thread ONKELINX, Thierry
Dear Mo, This is rather easy. Add an ID to each data series, rbind them into one data.frame and use the colour argument of qplot. data1 <- data.frame(corArms = rnorm(1000)) data2 <- data.frame(corArms = rnorm(3000, sd = 0.5)) data3 <- data.frame(corArms = rnorm(2000, sd = 2)) data1$ID <- "Data

Re: [R] lme funcion in R

2009-08-05 Thread ONKELINX, Thierry
s: 6 housing types, and I used five dummies in model and one as the reference. I also tried to combine them into two groups and use only dummy at random level, but it does not work either. is there any one here has similar experience with the LME function in R? Thanks. Harry On Tue, Aug 4, 20

Re: [R] lme funcion in R

2009-08-06 Thread ONKELINX, Thierry
2009 21:12 Aan: ONKELINX, Thierry CC: r-help@r-project.org Onderwerp: Re: [R] lme funcion in R Thanks, Thierry and other R users. I estimate the model using the factor rather than the dummy variables I used previously. It still takes forever for the function "lme" to run. But &quo

Re: [R] Summing data based on certain conditions

2010-04-02 Thread ONKELINX, Thierry
Dear Steve, Multiplying the mean with the number of observations is essentially the same as summing the numbers. Have a look at the plyr packages. library(plyr) ddply(data, c("month", "year"), function(x){ c(MeanMultiplied = mean(x$ramm) * nrow(x), Sum = sum(x$ramm)) }) --

[R] Struggeling with svydesign()

2010-04-07 Thread ONKELINX, Thierry
Dear all, We are analysing some survey data and we are not sure if we are using the correct syntax for our design. The population of interest is a set of 4416 polygons with different sizes ranging from 0.003 to 45.6 ha, 7460 ha in total. Each polygon has a binary attribute (presence/absence) and

Re: [R] Struggeling with svydesign()

2010-04-08 Thread ONKELINX, Thierry
can be extracted from a given body of data. ~ John Tukey > -Oorspronkelijk bericht- > Van: Thomas Lumley [mailto:tlum...@u.washington.edu] > Verzonden: woensdag 7 april 2010 18:51 > Aan: ONKELINX, Thierry > CC: r-help@r-project.org > Onderwerp: Re: [R] Struggeling w

Re: [R] How to replace all non-maximum values in a row with 0

2010-04-09 Thread ONKELINX, Thierry
It can be done faster and more elegant with apply and rowSums rows <- 10 A <- matrix(rpois(n = rows * 20, lambda = 100), nrow = rows) A[4, c(1,3)] <- 1000 system.time({ y <- t(apply(A, 1, function(z){ 1 * (z == max(z)) })) y[rowSums(y) > 1, ] <- 0 }) s

Re: [R] Interpreting factor*numeric interaction coefficients

2010-04-12 Thread ONKELINX, Thierry
Dear Matthew, The easiest way the get the estimates (and their standard error) for the different slopes it to reparametrise your model. Use resp ~ var1 : cat + 0 instead of resp ~ var1 * cat HTH, Thierry ir. Thierry O

Re: [R] glmer with non integer weights

2010-04-13 Thread ONKELINX, Thierry
Dear Kay, There is a R list about mixed models. Which is a better place for your questions. The (quasi)binomial family is used with binary data or a ratio that originates from binary data. In case of a ratio you need to provide the number of trials through the weights argument. Further I would s

Re: [R] glmer with non integer weights

2010-04-13 Thread ONKELINX, Thierry
So your respons variable behaves like a continuous variable except that is range is limited to the 0-1 interval. In such a case I would transform the respons variable (e.g. logit, sqrt(arcsin())) and use a gaussian model. HTH, Thierry -

Re: [R] renaming factors *efficiently*

2010-04-13 Thread ONKELINX, Thierry
for(i in colnames(dummy)){ levels(dummy[, i]) <- abbreviate(levels(dummy[, i])) } HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek team Biometrie & Kwaliteitszorg Gaverstraat 4 9500 Gera

Re: [R] Running cumulative sums in matrices

2010-04-14 Thread ONKELINX, Thierry
?cumsum can help you m1 <- cbind(1:5,1:5,1:5) m2 <- m1 for(i in 2:ncol(m1)){ m2[,i]=apply(m1[,1:i],1,sum) } m3 <- t(apply(m1, 1, cumsum)) all.equal(m2, m3) HTH, Thierry ir. Thierry Onkelinx Instituut vo

Re: [R] Weights in binomial glm

2010-04-16 Thread ONKELINX, Thierry
Jan, It looks like you did not understand the line "For a binomial GLM prior weights are used to give the number of trials when the response is the proportion of successes." Weights must be a number of trials (hence integer). Not a proportion of a population. Here is an example that clarifies the

Re: [R] Weights in binomial glm

2010-04-16 Thread ONKELINX, Thierry
ng desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey > -Oorspronkelijk bericht- > Van: Jan van der Laan [mailto:djvanderl...@gmail.com] > Verzonden: vrijdag 16 april 2010 16:09 > Aan: ONKELINX, Thierry >

Re: [R] ecdf

2010-04-19 Thread ONKELINX, Thierry
R is case sensitive. ecdf() is in the stats package, Ecdf() is in Hmisc. So you want Ecdf(x,what='1-F') Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek team Biometrie & Kwaliteitszorg Gaverstraat 4 95

Re: [R] reduce size of pdf

2010-04-30 Thread ONKELINX, Thierry
Dear Nevil, Converting your pdf to png will be the most efficient way to reduce the file size with scatter plots. You can either export directly to pdf or first create a pdf and then use ghostscript to convert it into png. I tend to the the latter because it is easier to get plots with a consiste

Re: [R] if else and loop for code in R

2009-09-25 Thread ONKELINX, Thierry
It looks like you are trying to mimic the SAS data step. In R you can vectorise this. a_data <- read.table("D:/SNP/copy.sas", header=T, sep="\t") a_data$stat <- with(a_data, ifelse(truck < 0, 0, ifelse(cars > 100, 0, cars))) a_data$i <- seq_len(nrow(a_data)) outTable <- a_data[, c("i", "stat", "t

Re: [R] Problem on plotting TS using GGPLOT

2009-09-25 Thread ONKELINX, Thierry
You are mixing data from two datasets with different lengths. Your x variable has 51 elements, while the y variable has 306 elements? What did you expect to happen with that? Use only one dataset within a geom(). Otherwise you are likely the get in troubles. HTH, Thierry ---

Re: [R] ggplot2 box plot notches

2009-09-29 Thread ONKELINX, Thierry
Dear Steve, I don't think that ggplot2 has that option. Hadley, please correct me if I'm wrong. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel

Re: [R] ggplot2: proper use of facet_grid inside a function

2009-10-05 Thread ONKELINX, Thierry
Dear Bryan, In the ggplot() function you can choose between aes() and aes_string(). In the first you need to hardwire the variable names, in the latter you can use objects which contain the variable names. So in your case you need aes_string(). Unfortunatly, facet_grid() works like aes() and not

Re: [R] ggplot cumsum refined question (?)

2009-10-06 Thread ONKELINX, Thierry
Dear Stephen, It is much easier to do you data preparation before plotting. Cummul <- ddply(subset(DF, precipitation!="NA"), "gauge_name", function(x){ x$Cummul <- cumsum(x$precipitation) x }) ggplot(Cummul, aes(x = date_time, y = Cummul)) + geom_line() + facet_wrap(~gauge_name, s

Re: [R] package nlme

2009-10-12 Thread ONKELINX, Thierry
You did not specify the random effects. Try something like Rice.lme<-lme(Yield ~ Variety + Stand,data=Rice, random = ~1|Block) HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Instit

Re: [R] multiple groups with different colors in boxplot

2009-10-13 Thread ONKELINX, Thierry
Here is a solution using ggplot2 n <- 1000 dataset <- data.frame(A = rep(1:6, n), B = rep(gl(3, 2), n)) dataset$C <- with(dataset, rnorm(n) * as.numeric(B) + A) library(ggplot2) dataset$A <- factor(dataset$A) #with default colours ggplot(dataset, aes(x = A, y = C, colour = B)) + geom_boxplot() #wi

Re: [R] linear trend line and a quadratic trend line.

2009-11-10 Thread ONKELINX, Thierry
Here is a solution using ggplot2 n <- 50 Duncan <- data.frame(income = runif(n, 0, 5)) Duncan$prestige <- with(Duncan, 0.01 * income - .001 * income ^2 + rnorm(n, sd = 10)) library(ggplot2) ggplot(Duncan, aes(y = prestige, x = income)) + #define the data geom_point() + #ad

Re: [R] Histogram and Density on the the same graph

2009-11-30 Thread ONKELINX, Thierry
It's easy with the ggplot2 package set.seed(1234) dataset <- data.frame(x = seq(1,40,1)) dataset$Response <- with(dataset, 2*x+1+5*rnorm(length(x))) library(ggplot2) ggplot(dataset, aes(x = Response)) + geom_histogram(aes(y = ..density..)) + geom_density(colour = "red") HTH, Thierry --

Re: [R] problems installing R packages

2009-12-02 Thread ONKELINX, Thierry
R 2.4.0 is obsolete. First update to the latest version (2.10.0, 2.10.1 will be available soon). And then try to install the packages. ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek team Biometrie & Kwalite

Re: [R] column statistics

2009-12-07 Thread ONKELINX, Thierry
You have several options in R. 1) cast from the reshape package cast(Factor1 + Factor2 ~ . , data = your.data.frame, value = "Value", fun = mean) 2) ddply from the plyr package ddply(your.data.frame, c("Factor1", "Factor2"), function(x){mean(x$Value)}) HTH, Thierry -

Re: [R] Bug in lnme package?

2009-12-14 Thread ONKELINX, Thierry
Dear Pieter, I suppose that you have attached your data.frame and then messed up the Distance variable. Therefore do not use attach(your.data.frame) but use the data = your.data.frame argument in your models. If that does not solve the problem, then send us a reproducible example of your problem

Re: [R] comparison of these types is not implemented

2009-12-15 Thread ONKELINX, Thierry
Dear Tom, r_squared is a list of vectors and not a vector. Use r_squared[[i]] instead of r_squared[i] or convert r_squared to a vector with unlist(r_squared) HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur-

Re: [R] for loop for automatic pdf generation

2009-12-15 Thread ONKELINX, Thierry
Dear Stephen, You need to print() the plot explicitly. This is FAQ 7.22 (http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis -graphics-not-work_003f) HTH, Thierry ir. Thierry Onkelinx Instituut vo

Re: [R] linear contrasts for trends in an anova

2009-12-18 Thread ONKELINX, Thierry
Dear Colm, Use lm() instead of aov() and your problem is solved. The parameter of Group.L is the linear trend along your groups. Group.Q the quandratic trend. HTH, Thierry summary(lm(Mean_1 ~ Group*eventType, data=doi)) Call: lm(formula = Mean_1 ~ Group * eventType, data = doi) Residuals:

Re: [R] Nested For loops

2009-12-22 Thread ONKELINX, Thierry
Baloo, Why don't you use the built-in acf function? Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek team Biometrie & Kwaliteitszorg Gaverstraat 4 9500 Geraardsbergen Belgium Research Institute for

Re: [R] ACF normalization.

2009-12-22 Thread ONKELINX, Thierry
Just enter nlme:::ACF.gls at the command prompt and hit enter. This works with most functions. Another option is to download the source code of nlme from CRAN. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur-

Re: [R] COnfidence intervals for estimates of linear model

2009-12-23 Thread ONKELINX, Thierry
Dear Daniel, Have a look at ?predict.lm The interval argument gives you the information that you need. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek team Biometrie & Kwaliteitszorg Gaverst

Re: [R] Help with lme4 model specification

2009-05-07 Thread ONKELINX, Thierry
Please note that the case of characters is important in R. Hence "True" differs from "TRUE". You need to use REML = TRUE instead of REML = True! The only valid logical values are TRUE, FALSE, T and F. But I recommend to use only TRUE and FALSE. Because you can overwrite T and F. You could do somet

Re: [R] I updated/reinstalled ggplot2 and the trouble started...

2009-05-07 Thread ONKELINX, Thierry
What device are you using to plot the graph? According to the warning, the device is causing the problem. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Fo

Re: [R] Bumps chart in R

2009-05-07 Thread ONKELINX, Thierry
Dear Andreas and Mike, You need to use scale_colour_manual() if you want to set the colours yourself. Ggplot2 interpretes the "col" variable in the dataset as an ordinairy factor. library(ggplot2) df0 <- data.frame(text = letters[1:21], tal1 = c(rnorm (20,5,2), 5), tal2 = c(rnorm (20,6,3), 5))

Re: [R] I updated/reinstalled ggplot2 and the trouble started...

2009-05-08 Thread ONKELINX, Thierry
an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey Van: Tena Sakai [mailto:tsa...@gallo.ucsf.edu] Verzonden: donderdag 7 mei 2009 18:13 Aan: ONKELINX, Thierry; Ian Fellows; r-hel

Re: [R] Overdispersion using repeated measures lmer

2009-05-19 Thread ONKELINX, Thierry
Dear Christine, The poisson family does not allow for overdispersion (nor underdispersion). Try using the quasipoisson family instead. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Res

Re: [R] Overdispersion using repeated measures lmer

2009-05-19 Thread ONKELINX, Thierry
Dear Christine, (Month|Block) and (1|Block) + (1|Month) are completely different random effects. The first assumes that each Block exhibits a different linear trend along Month. The latter assumes that each block has a random effect, each month has a random effect and that the random effects of

[R] Coord_equal in ggplot2

2009-05-19 Thread ONKELINX, Thierry
Dear all, I'm plotting some points on a graph where both axes need to have the same scale. See the example below. Coord_equal does that trick but in this case it wastes a lot of space on the y-axis. Setting the limits of the y-axis myself was no avail. Any suggestions to solve this problem? l

Re: [R] Coord_equal in ggplot2

2009-05-19 Thread ONKELINX, Thierry
key -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Dieter Menne Verzonden: dinsdag 19 mei 2009 16:15 Aan: r-h...@stat.math.ethz.ch Onderwerp: Re: [R] Coord_equal in ggplot2 ONKELINX, Thierry inbo.be> writes: > > I'm plotting some

Re: [R] how to adding colors to data points in scatter plot in R?

2009-05-23 Thread ONKELINX, Thierry
Dear Tim, Have a look at the ggplot2 package. library(ggplot2) ggplot(your.data.frame, aes(x = EducationYears, y = Income, colour = Registered)) + geom_point() You find a lot of examples at the ggplot2 website: http://had.co.nz/ggplot2/ HTH, Thierry -

Re: [R] long format - find age when another variable is first 'high'

2009-05-25 Thread ONKELINX, Thierry
Dear David, You would speed up things is you first create a subset were all values of ldlc is >= 130. Then you only have to find the lowest age for each child in this subset. HTH, Thierry ir. Thierry Onkelinx Institu

Re: [R] How to replace Inf by zero?

2009-05-29 Thread ONKELINX, Thierry
Dear Marlene, Have a look at is.infinite(). Replacing them by zero is not a very bright idea if you want the mean of the resulting vector. Have a look at the example below. #create a vector x <- rnorm(100, mean = 1000) #replace 20 values with Inf x[sample(seq_along(x), 20, replace = FALSE)] <- In

Re: [R] Sweave:Figures from plot (LME output) not getting generated(pdf or eps)

2009-06-01 Thread ONKELINX, Thierry
Dear Girish, As they are lattice plots, you need to print() them explicitly. It is FAQ 7.22: http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis- graphics-not-work_003f <>= print(plot(fm1, distance ~ fitted(.) | Subject, abline = c(0,1))) @

Re: [R] Getting a column of values from a list - think I'm doing it thehard way

2009-06-04 Thread ONKELINX, Thierry
Dear Jason, Have a look at years() from the chron package. library(chron) HouseDates <- c("02/27/90", "02/27/91", "01/14/92", "02/28/93", "02/01/94", "02/01/95", "02/01/96") HouseDatesFormatted<-as.Date(HouseDates, "%m/%d/%y") years(HouseDates) HTH, Thierry

Re: [R] 'beside' option for boxplots

2009-06-04 Thread ONKELINX, Thierry
Dear Malcom, Another option is to merge both dataset to one big dataset and then plot the big dataset. d1 <- data.frame(a = c(rep(1:3, each = 3)), b = c(1:9), d = "A") d2 <- data.frame(a = c(rep(1:3, each = 3)), b = c(9:1), d = "B") Dataset <- rbind(d1, d2) library(ggplot2) Dataset$a <- factor(Da

Re: [R] Splicing factors without losing levels

2009-06-09 Thread ONKELINX, Thierry
Dear Titus, Your first function can be simplified to splice <- function(x, y) { as.vector(rbind(x, y)) } For factors, you better convert them first back to character strings. splice <- function(x, y) { x <- levels(x)[x] y <- levels(y)[y] factor(as.vector(rbind

Re: [R] ggplot, qplot: alpha channel for colors corresponding to factor

2009-06-10 Thread ONKELINX, Thierry
Dear Marianne, If find that a bit easier with ggplot() instead of qplot() d1 <- data.frame(Goodall=c(rep(1:3,5)), Better.adapt = c(rep(1,7),rep(2,8)),Second.adapt=c(rep(1:5,3))) library(ggplot2) ggplot(d1, aes(x= Goodall, y = Better.adapt, colour=Second.adapt)) + geom_jitter(alpha = 0.2) + scale

Re: [R] plot two variograms on a same graph

2009-06-10 Thread ONKELINX, Thierry
Dear Damien, I tend do use ggplot2 for more advanced plotting. You only have to create a dataframe with all the data you need. Here are some examples. library(gstat) library(ggplot2) data(meuse) coordinates(meuse) = ~x+y g1 <- gstat(id = "Raw", formula = lo

Re: [R] how to sort

2009-06-18 Thread ONKELINX, Thierry
You need both the name of the dataframe and the variable in the dataframe. dfCorTFandPCA[order(dfCorTFandPCA$PC1)] ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest

Re: [R] lattice wireframe within a loop ???

2009-06-24 Thread ONKELINX, Thierry
You need to print() lattice plots inside a loop or a function. ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Sect

Re: [R] Syntax in lmer...

2009-03-23 Thread ONKELINX, Thierry
Dear Anne, Is age a continuous or a categorical variable? If it is a continuous variable, then I would add it to the fixed effects. You have two options for the random effect: (Fertilier|Family/Species) or (1|Family/Species) + (0 + Fertilizer|Family/Species). Both yield a random intercept and a r

Re: [R] Variogram with Gstat

2009-03-24 Thread ONKELINX, Thierry
Have a look at the examples in the helpfile for variogram from the gstat package. data(meuse) # no trend: coordinates(meuse) = ~x+y variogram(log(zinc)~1, meuse) # residual variogram w.r.t. a linear trend: variogram(log(zinc)~x+y, meuse) # directional variogram: variogram(log(zinc)~x+y, meuse, alp

Re: [R] [ggplot2] Densityplot, grouping and NAs

2009-03-25 Thread ONKELINX, Thierry
Dear Bernd, Omitting the NA values from the dataset will work. ggplot(aes(x = x, color = g), data = na.omit(mydf)) + geom_density() Notice that I have omitted the group argument. It is redundant in this case. HTH, Thierry -

Re: [R] modelling probabilities instead of binary data with logisticregression

2009-03-25 Thread ONKELINX, Thierry
Hi Joris, glm() handles proportions but will give you a warning (and not an error) about non-integer values. So if you get an error then there should be something wrong with the syntax, model or data. Can you provide us with a reproducible example? Cheers, Thierry -

Re: [R] [ggplot2] Densityplot, grouping and NAs

2009-03-25 Thread ONKELINX, Thierry
can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: Bernd Weiss [mailto:bernd.we...@uni-koeln.de] Verzonden: woensdag 25 maart 2009 11:10 Aan: ONKELINX, Thierry; r-help@r-project.org Onderwerp: Re: [R] [ggplot2] Densityplot, grouping and NAs ONKELINX

Re: [R] histogram plots with many different samples

2009-03-25 Thread ONKELINX, Thierry
Dear Evrim, That is easy to do with the ggplot2 package. You only need the data in a "long" format. melt() is very usefull to convert data from a wide to a long format. library(ggplot2) n <- 100 Wide <- data.frame(X1 = rnorm(n, mean = -0.5), X2 = rnorm(n, mean = 0, sd = 2), X3 = rnorm(n, mean = 0

Re: [R] How to prevent inclusion of intercept in lme with interaction

2009-04-01 Thread ONKELINX, Thierry
Dear Dieter, With t*treat the model allows for a different slope AND a different intercept for each treatment. If you only want different slopes and all intercepts equal to 0, then t:treat - 1 or t + t:treat - 1 is the model you are looking for. HTH, Thierry ---

Re: [R] Tinn-R pdf()

2009-04-08 Thread ONKELINX, Thierry
Dear Henning, You need to print() lattice plots when using a device: library(lattice) pdf("plot1.pdf") PLOT<-(xyplot, ...) print(PLOT) dev.off() So this is not due to TINN-R. HTH, Thierry ir. Thierry Onkelinx Inst

Re: [R] turning list into vector/dataframe

2009-04-10 Thread ONKELINX, Thierry
Dear Melissa, Use sapply instead of lapply and name the output vector of your Cusum function. Note that I have simplified that function. Cusum <- function(x){ SUM <- cumsum(x) - seq_along(x) * mean(x) c(Min = min(SUM), Max = max(SUM), Diff = diff(range(SUM))) } lambs <- rnorm(10) resamp

Re: [R] png with ggplot on windows xp

2009-04-11 Thread ONKELINX, Thierry
Dear Juliet, ggsave uses 300 dpi as default and the png device 72 dpi. The problem seems to be that everything is scaled properly except the pointsize. At least on WinXP. A work around is to increase the theme base_size from 12 to 50 (12 * 300 / 72 = 50). p <- p + theme_gray(50) ggsave(file = "my

Re: [R] Question on zero-inflated Poisson count data with repeatedmeasures design - glmm.ADMB

2009-04-14 Thread ONKELINX, Thierry
Dear Diederik, If you revisited the same points then it makes sense to use the data at the point level. But then I would mke that explicit by using a nested random effect. In the nlme/lme4 syntax: 1|Site/Point. Make shure that each point has a unique ID. Naming a variable "count" is not a very go

Re: [R] using Sweave, how to save a plot in a given size

2009-04-15 Thread ONKELINX, Thierry
Dear Lore, The easiest thing to do is to write a function that saves your plot to a file and generates the latex code. <>= pdf("fig1.pdf", width = wid, heigth = hei) plot(1:10) dev.off() cat("\begin{figure}\") cat("\includegraphics[width = ", wid, ", height = ", hei, "]{proj1-fig1}\"} ca

Re: [R] Intersection of two sets of intervals

2009-04-15 Thread ONKELINX, Thierry
Not of the self but still not complicated: list1 <- data.frame(open=c(1,5), close=c(2,10)) list2 <- data.frame(open=c(1.5,3), close=c(2.5,10)) Intersec <- data.frame(Open = pmax(list1$open, list2$open), Close = pmin(list1$close, list2$close)) Intersec[Intersec$Open > Intersec$Close, ] <- NA Inter

Re: [R] data frame display

2009-04-15 Thread ONKELINX, Thierry
Have a look at the width argument in ?options HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Sectio

Re: [R] using Sweave, how to save a plot in a given size

2009-04-15 Thread ONKELINX, Thierry
can be extracted from a given body of data. ~ John Tukey Van: Lore M [mailto:tchiba...@hotmail.com] Verzonden: woensdag 15 april 2009 15:44 Aan: ONKELINX, Thierry; R Help Onderwerp: RE: [R] using Sweave, how to save a plot in a given size After few corrections

Re: [R] performing function on data frame

2009-04-16 Thread ONKELINX, Thierry
Dear karin, Try rescaler from the reshape package: install.packages("reshape") library("reshape") newDF <- apply(oldDF, 2, rescaler, type = "sd") HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderz

Re: [R] Modular Arithmetic Error?

2009-04-17 Thread ONKELINX, Thierry
That is more or less FAQ 7.31: http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-the se-numbers-are-equal_003f ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nat

[R] Generate bivariate binomial data

2009-04-17 Thread ONKELINX, Thierry
Dear all, Could someone point me to a function or algorithm to generate random bivariate binomial data? Some details about what I'm trying to do. I have a dataset of trees who were categorised as not damaged or damaged. Each tree is measured twice (once in two consecutive years). The trees can r

Re: [R] (senza oggetto)

2009-04-20 Thread ONKELINX, Thierry
Giuseppe, Please enter a meaningfull subject line. Have you tried the examples from the variogram helpfile? They clearly demonstrate how to do it. If you still have problems, then you need to give us a reproducible example of your dataset and code. HTH, Thierry ---

Re: [R] ggplot2 - boxplot of variables / columns

2009-04-21 Thread ONKELINX, Thierry
Dear Andreas, melt() and cast() are nice tools for this kind of problems. They both reside in the reshape package that automatic loaded when ggplot2 is. a <- rnorm(100) b <- rnorm(100,1,2) c <- rnorm(100,2,0.5) ds <- data.frame(a = a, b = b, c = c) library(ggplot2) # loads qqplot2 ggplot(melt(ds)

Re: [R] Generate bivariate binomial data

2009-04-22 Thread ONKELINX, Thierry
: Charles C. Berry [mailto:cbe...@tajo.ucsd.edu] Verzonden: vrijdag 17 april 2009 21:31 Aan: ONKELINX, Thierry CC: r-help@r-project.org Onderwerp: Re: [R] Generate bivariate binomial data On Fri, 17 Apr 2009, ONKELINX, Thierry wrote: > Dear all, > > Could someone point me to a function or alg

Re: [R] Gee with nested desgin

2009-04-22 Thread ONKELINX, Thierry
...@erasmusmc.nl] Verzonden: woensdag 22 april 2009 11:48 Aan: ONKELINX, Thierry CC: r-help@r-project.org Onderwerp: Re: [R] Gee with nested desgin Hi Thierry, in geeglm() and in connection with the GEE theory, argument "id" should identify the independent sample units in your data set, whi

[R] Gee with nested desgin

2009-04-22 Thread ONKELINX, Thierry
Dear all, Is it possible to incorporate a nested design in GEE? I have measurements on trees that where measured in two years. The trees are nested in plots. Each plot contains 24 trees. The number of plots is 72. Hence we would expect 2 * 24 * 72 = 3456 data points. A few are missing, so we end u

Re: [R] ggplot2/aesthetic plotting advice

2009-04-23 Thread ONKELINX, Thierry
Dear Ben, With a lot of overlapping errorbar things will always look cluttered. Below you will find a few suggestions. HTH, Thierry library(ggplot2) nx <- 3 ngrp <- 5 nper <- 4 x <- rep(1:nx,ngrp*nper) y <- runif(nx*ngrp*nper) g <- factor(rep(1:ngrp,each=nx*nper)) dat <- data.frame(Year = fa

Re: [R] transposing a matrix - row by row?

2009-04-23 Thread ONKELINX, Thierry
Dear Dimitri, Have a look at melt() from the reshape package. X<-matrix(c(10,20,30,40,50,60),2,3) dimnames(X)<-list(c("1","2"),c("1","2","3")) library(reshape) melt(X) HTH, Thierry ir. Thierry Onkelinx Instituut vo

Re: [R] Changing gird marks in ggplot2

2009-04-26 Thread ONKELINX, Thierry
Dear Chris, Changing coord_cartesian(ylim = c(0, 5)) into coord_cartesian() + scale_y_continuous(limits = c(0, 5)) That should solve your problem. HTH, Thierry ir. Thierry Onkelinx Instit

Re: [R] comparing matrices

2009-04-26 Thread ONKELINX, Thierry
Have a look at all.equal matA <- matrix(1:4, ncol = 2) matB <- matA all.equal(matA, matB) matB[1,1] <- -10 all.equal(matA, matB) HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research In

Re: [R] A way to get the R data stored temporarily in working memory?

2009-04-27 Thread ONKELINX, Thierry
Have a look at ?save and ?load. Those function will allow you to save an R object to a file and reload it when needed. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for

Re: [R] Hoe to get RESIDUAL VARIANCE in logistic regression using lmer

2009-04-30 Thread ONKELINX, Thierry
Dear Tommaso, The residuals variance is fixed at 1 with the binomial family. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodol

Re: [R] stepAICc

2009-04-30 Thread ONKELINX, Thierry
Dear Christoph, I done that and more. You'll find the functions below my signature. It is mainly based on stepAIC from MASS. But it does more. AICc = c(TRUE, FALSE) determines whether to use AICc or AIC Furthermore it does not only refines the 'best' model but all good models. A good model is de

Re: [R] Best method

2010-01-15 Thread ONKELINX, Thierry
Dear Vladimir, You can use a logistic regression. First define Y0 as 30 - Y. Then Y is the number of days with headache and Y0 the number of days without. Then the model looks like: glm(cbind(Y, Y0) ~ X1 + X2 + X3, family = "binomial") HTH, Thierry

Re: [R] ggplot2 histogramm

2010-01-18 Thread ONKELINX, Thierry
I think you need scale_fill_continuous("Your new label") Note that you can simplify scale_y_continuous(formatter = "percent") + ylab("Anteil in %") To scale_y_continuous("Anteil in %", formatter = "percent") HTH, Thierry

Re: [R] Stata and R user GLM method

2010-01-22 Thread ONKELINX, Thierry
Jean-Baptiste, You are not doing the same thing in R as in Stata. In stata you used the probit link, in R the logit link. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek team Biometrie & Kwa

Re: [R] Conditional sampling?

2010-02-04 Thread ONKELINX, Thierry
selection <- subset(somedf, col1 != "a") sample(selection$col2, 2, replace = TRUE) ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek team Biometrie & Kwaliteitszorg Gaverstraat 4 9500 Geraardsbergen Belgium

Re: [R] step and glmer

2010-02-09 Thread ONKELINX, Thierry
glmer() nor lmer() work with the step function. You have to build your models manually. ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek team Biometrie & Kwaliteitszorg Gaverstraat 4 9500 Geraardsbergen Belg

<    1   2   3   4   5   6   7   >