Re: [R] Boxplot BUT with Mean, SD, Max & Min ?

2011-09-26 Thread ONKELINX, Thierry
Dear Phil, Have a look at the ggplot2 package. library(ggplot2) #classic boxplot ggplot(mtcars, aes(x = factor(cyl), y = mpg)) + geom_boxplot() #custom boxplot myboxplot <- cast(cyl ~ ., value = "mpg", data = mtcars, fun = c(min, max, sd, mean)) ggplot(myboxplot, aes(x = factor(cyl))) + geom_bo

Re: [R] How to analyse this type of data...?

2011-09-30 Thread ONKELINX, Thierry
Dear Luc, IMHO a multinomial mixed model is appropriate for your data. It allows you to model tree species with bird id and period as covariates. Have a look at the vignette of the MCMCglmm package. You will find an example on hornets. Best regards, Thierry PS R-sig-mixed models is a better l

Re: [R] new standardised variable based on group membership

2011-10-03 Thread ONKELINX, Thierry
Dear John, You need to combine scale with a grouping function. data(Orange) library(plyr) Orange <- ddply(Orange, .(Tree), function(x){ x$ddplyAge <- scale(x$age)[, 1] x }) Orange$aveAge <- ave(Orange$age, by = Orange$Tree, FUN = scale) all.equal(Orange$ddplyAge, Orange$aveAge)

Re: [R] (no subject)

2011-10-05 Thread ONKELINX, Thierry
Dear William, Please use a more informative subject line (as the posting guide asks you to do). Backslash have a special function. In file paths you need to use either double backslashes or forward slashes. 'C:\\Users\\Bill\\Desktop\\DMwR_0.2.1.zip' 'C:/Users/Bill/Desktop/DMwR_0.2.1.zip' Bes

Re: [R] optimize R code: replace for loop

2011-10-05 Thread ONKELINX, Thierry
You can vectorize it using cumsum. cumsum(c(1, testvec)) all.equal(final.sum, cumsum(c(1, testvec))) > -Oorspronkelijk bericht- > Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > Namens Chris82 > Verzonden: woensdag 5 oktober 2011 11:50 > Aan: r-help@r-project.or

Re: [R] Editor for RD file?

2011-10-17 Thread ONKELINX, Thierry
Eclipse with the Stat-ET plugin does syntax highlighting for .R, .Rd and .Rnw files. Best regards, Thierry > -Oorspronkelijk bericht- > Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > Namens Joshua Wiley > Verzonden: zondag 16 oktober 2011 22:09 > Aan: Bogaso C

Re: [R] ggplot2 reorder factors for faceting

2011-11-08 Thread ONKELINX, Thierry
Dear Iain, RSiteSearch("ggplot2 reorder", restrict = c("Rhelp10", "Rhelp08")) gives you the solution. Best regards, Thierry > -Oorspronkelijk bericht- > Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > Namens Iain Gallagher > Verzonden: dinsdag 8 november 2011 1

Re: [R] Statistical Histograms in R

2012-03-02 Thread ONKELINX, Thierry
Have a look at http://had.co.nz/ggplot2/stat_density.html You'll find some exampled and the code to generate them. ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance Kliniek

Re: [R] lme code help

2012-03-15 Thread ONKELINX, Thierry
You want lme(logSSP~logM + K,random=~logM + K|species,data=data1) Best regards, ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance Kliniekstraat 25 1070 Anderlecht Belgium +

Re: [R] gam - Y axis probability scale with confidence/error lines

2012-03-15 Thread ONKELINX, Thierry
I find plogis() is easier to remember all.equal(binomial()$linkinv(seq(-2, 2, length = 101)), plogis(seq(-2, 2, length = 101))) ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assu

Re: [R] Comples Boxplots in R . Resources

2012-03-23 Thread ONKELINX, Thierry
Dear Alex, Have a look at the ggplot2 package n <- 3502 junk <- list(list(matrix(rnorm(n), ncol = 1), matrix(rnorm(n, sd = 2), ncol = 1)), list(matrix(rnorm(n, mean = 1), ncol = 1), matrix(rnorm(n, mean = 1, sd = 2), ncol = 1)), list(matrix(rnorm(n, mean = 1), ncol = 1), matrix(rnorm(n, mean =

Re: [R] Help - Importing data from txt and xlsx files

2012-04-13 Thread ONKELINX, Thierry
Dear Tom, R does not searches your entire file system for the file. It only looks in the working directory. Have a look at ?setwd() and ?getwd() So you will need to set the working directory, use a relative path to the file or use and absolute path to the file. Best regards, ir. Thierry Onkel

Re: [R] How do I convert factors to numeric? It's an FAQ but...

2012-04-13 Thread ONKELINX, Thierry
f is a dataframe of factor, not a factor use either as.numeric(levels(f$your.factor))[f$your.factor] or if f only contains factors apply(f, 2, function(x){as.numeric(levels(x))[x]}) ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Bio

Re: [R] quick question about lme()

2012-04-14 Thread ONKELINX, Thierry
Both specifications are the same model. An intercept is added by default unless you use +0 or -1 like ~0 + LEAD|GRP or ~ -1 + LEAD|GRP Van: r-help-boun...@r-project.org [r-help-boun...@r-project.org] namens YA [xinxi...@163.com] Verzonden: zaterdag 14 apri

Re: [R] error

2012-01-20 Thread ONKELINX, Thierry
This is discussed in the help of seq(). See the details section of ?sec Best regards, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance Kliniekstraat 25 1070 Anderl

Re: [R] Calling update on an lm-object inside a function

2012-01-23 Thread ONKELINX, Thierry
Dear Soren, I would try adding the new variable to the dataset and use the data = argument of lm foo <- function(mod, data){ data$y3 <- c(1,3,3,4,6) update(mod, y3 ~ ., data = data) } x <- 1:5 y <- c(1,2,3,3,6) dataset <- data.frame(x = x, y = y) mm <- lm(y~x, data = dataset) foo(mm, datas

Re: [R] 3 variables - GLM -- Warning Message ?

2012-01-24 Thread ONKELINX, Thierry
J, For at least one combination of Aeventexhumed:HTL:Sector Shell is either 0 or equal to TotalEggs. Best regards, ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance Klinie

Re: [R] ggplot theme_update

2012-02-03 Thread ONKELINX, Thierry
Hi Nameless, You would have to add your code to the source of the ggplot2 package to make it permanent. But that not a vary good idea. Just add the line to your script and rerun it when you restart your analysis. Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research I

Re: [R] Weighted mad

2012-02-07 Thread ONKELINX, Thierry
You could try something like this. library(plyr) ddply(pool, .(ym), function(z){ weighted.mean(x= z$SMM, w = z$wght) }) ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assur

Re: [R] how to exclude rows with not-connected coalitions

2012-02-09 Thread ONKELINX, Thierry
This can be done without nested loops. a <- expand.grid(rep(list(c(0,1)),7)) tmp <- apply(a, 1, function(x){ var(cumsum(x == 0)[x == 1]) }) a[is.na(tmp) | tmp == 0, ] ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie & Kwalit

Re: [R] ggplot2-Problem (plot different variables)

2012-04-20 Thread ONKELINX, Thierry
Try something like this library(ggplot2) data<-as.data.frame(cbind(a=c(1,1,2,2,2,2,3,3,4), b=c(1,2,3,3,4,4,4,4,4))) library(reshape) Molten <- melt(data) ggplot(Molten, aes(x = value, colour = variable)) + geom_density() Best regards, Thierry ir. Thierry Onkelinx Instituut voor natuur- en boson

Re: [R] HOw compare 2 models in logistic regression

2012-04-30 Thread ONKELINX, Thierry
Dear Santos, Since your models are nested you can apply a likelihood ratio test. M0 <- glm(formula = Spend_bucket ~ Freq + Address_is_res + last_update_days_ago, data = qdataset, family = binomial) M1 <- glm(formula = Spend_bucket ~ Freq + Address_is_res, data = qdataset, family = binomial) ano

Re: [R] How to plot stacked histogram in R?

2012-05-07 Thread ONKELINX, Thierry
Have a look at this example h1 <- cut(rnorm(1000, 4), breaks = seq(0, 8, by = 2)) h2 <- cut(rnorm(1000, 3), breaks = seq(0, 8, by = 2)) h3 <- cut(rnorm(1000, 5), breaks = seq(0, 8, by = 2)) dataset <- data.frame(Set = rep(c("A", "B", "C"), each = 100), value = c(h1, h2, h3)) dataset$fvalue <- fac

Re: [R] please help!

2012-05-08 Thread ONKELINX, Thierry
>From the posting guide of this mailing list: Basic statistics and classroom >homework: R-help is not intended for these. Ask your fellow students or your teacher. ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie & Kwaliteitsz

Re: [R] ANOVA question

2012-05-11 Thread ONKELINX, Thierry
Dear Robert, It is easier to use lm instead of aov if you want coefficients for each group. Note that you can use rnorm vectorised. set.seed(0) N <- 100 # sample size MEAN <- c(10, 20, 30, 40, 50) VAR <- c(20,20,1, 20, 20) LABELS <- factor(c("A", "B", "C", "D", "E")) # create a data frame with

Re: [R] Outcome~predictor model evaluation, repeated measurements

2012-05-11 Thread ONKELINX, Thierry
Dear nameless, A mixed model seems reasonable for your kind of data. lme() from nlme or lmer() from lme4 are good starting points. Please note that there is R-sig-mixed-models: a R mailing list dedicated to mixed models. Best regards, ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoe

Re: [R] problem with get() inside of lme()

2012-05-16 Thread ONKELINX, Thierry
You can achieve that with a combination of as.formula and paste. library(nlme) data(petrol, package = "MASS") lme(as.formula(paste(Y.VAR, "~EP")), random= ~1|No, data=petrol) Best regards, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and F

Re: [R] What's wrong with MEAN?

2012-05-22 Thread ONKELINX, Thierry
You'll need to pass the data as a vector. mean(16, 18) is asking the mean of 16. 18 is passed to the second argument which is trim. So you are doing mean(16, trim = 18) What you want is mean(c(16, 18)) Best regards, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Resear

Re: [R] setting parameters equal in lm

2012-05-29 Thread ONKELINX, Thierry
offset() fixes the parameter to 1. So offset(I(.5*X2)) should do the trick. ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance Kliniekstraat 25 1070 Anderlecht Belgium + 32 2

Re: [R] GLMMPQL spatial autocorrelation

2012-05-30 Thread ONKELINX, Thierry
Dear Alex, I'm cc'ing this to the mixed models list which is more appropriate for the question. Please send all follow up posts only to that list. First a few more general remarks. - You are using the data argument of glmmPQL. So there is no need to attach() the data.frame. I recommend avoid to

Re: [R] alternative generator for normal distributed variables

2012-05-30 Thread ONKELINX, Thierry
Please give a reproducible example when making bold statements. I find no evidence of autocorrelation in set.seed(12345) x <- rnorm(100, mean = 0, sd = 1) acf(x) x <- rnorm(1e6, mean = 0, sd = 1) acf(x) ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature

Re: [R] Problems with lme

2008-05-24 Thread ONKELINX, Thierry
That's because you have not specified the random effect. I think you want lme(Error ~ Sequence + Temperature + Tumour, random = ~1|ID, data = YourDataset) HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en

Re: [R] cbind results to original data frame

2008-05-29 Thread ONKELINX, Thierry
Have you tried to merge the two datasets? See ?merge for the details. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en

Re: [R] estimate phase shift between two signals

2008-06-05 Thread ONKELINX, Thierry
Dylan, You can write r sin(x + alfa) as a sin(x) + b cos(x). Then you just have to fit a linear model. r = sqrt(a^2 + b^2) and tan(alfa) = b / a HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzo

Re: [R] ggplot2-barplot

2008-06-23 Thread ONKELINX, Thierry
Dear Felipe, Is this what you want? library(ggplot2) mydata <- data.frame(PondName = factor(LETTERS[1:5]), avgWt = rnorm(5, mean = 10, sd = 3)) ggplot(mydata, aes(x = PondName, y = avgWt)) + geom_bar() ggplot(mydata, aes(x = PondName, y = avgWt, fill = PondName)) + geom_bar() HTH, Thierry --

Re: [R] expand.grid() function

2008-06-23 Thread ONKELINX, Thierry
Expand.grid works with lists too. > expand.grid(rep(list(c("u", "l")), 3)) Var1 Var2 Var3 1uuu 2luu 3ulu 4llu 5uul 6lul 7ull 8lll This is probably as concise as is can get. HTH, Thierry --

Re: [R] T and P Statistics

2008-06-25 Thread ONKELINX, Thierry
If you would have tried help.search("t-test") It would have listed the function t.test() ?t.test Will give you the helpfile with instructions. ir. Thierry Onkelinx Instituut voor natuur- en bosonderz

Re: [R] stuck on making a line graph across time, with 4 categories

2008-06-27 Thread ONKELINX, Thierry
A solution with ggplot2 would be dataset <- data.frame(cat = factor(rbinom(1000, 1, prob = .33), labels = LETTERS[1:2]), startyear = floor(runif(1000, 2001, 2009)), studentid = 1:1000) library(ggplot2) ggplot(dataset, aes(x = startyear, colour = cat)) + stat_bin(aes(y = ..count..), geom="line", b

Re: [R] Regression and fitting

2008-07-01 Thread ONKELINX, Thierry
Try to set your own starting values. Use the values that you would expect for S0, mu and sigma. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel

Re: [R] trivial list question

2008-07-01 Thread ONKELINX, Thierry
Use lapply on a costum function. lapply(1:92, function(i){ (i - 1) * 2 + 1:2 }) HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie,

Re: [R] Optimal lag selection in Granger Causality tests

2008-07-02 Thread ONKELINX, Thierry
RSiteSearch("Granger Causality", restrict = "functions") yields two hits. ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitsz

Re: [R] Correlation structures in gls with repeated measurements

2008-07-02 Thread ONKELINX, Thierry
Emma, It looks like there is at least one location that has been sampled at least twice in some year. A co-worker of me got similar errors. After checking his data carefully he found a duplicate row. Removing the duplicate row solved his problem. HTH, Thierry --

Re: [R] Matrix set value problem

2008-07-03 Thread ONKELINX, Thierry
This is similar to FAQ 7.31. my is *printed* as 1, but in fact it is slightly smaller. Try print(my, digits = 15). Rounding my works. m<-matrix(nrow=10,ncol=10) i<-1001 mx<-trunc(i/1000) my<-round((i/1000-mx)*1000, 0) m[mx, my]<-1 Thierry ---

Re: [R] RODBC Access limit?

2008-07-03 Thread ONKELINX, Thierry
Have you checked your data at row 3277? It could be that there is something odd in that row. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biom

Re: [R] How can I optimize this piece of code ?

2008-07-07 Thread ONKELINX, Thierry
Try aggregate. It takes only 8 seconds for the 80 rows in the example below. m <- as.data.frame(matrix(rnorm(1600), ncol = 20)) m$ID <- rbinom(nrow(m), 10, prob = 0.5) system.time( aggregate(m[, 5:20], list(ID = m$ID), sd) ) user system elapsed 6.141.377.55 > HTH, Th

Re: [R] A quick question about lm()

2008-07-07 Thread ONKELINX, Thierry
Or str(summary(lm(..))) ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and qualit

Re: [R] Histogram with colors according to factor

2008-07-08 Thread ONKELINX, Thierry
Is this what you want? dataset <- data.frame(x = c(rnorm(100), runif(100), rchisq(100, 1)), y = gl(3, 100, labels = LETTERS[1:3])) ggplot(dataset, aes(x = x, fill = y)) + geom_histogram() ggplot(dataset, aes(x = x, fill = y)) + geom_histogram(position = "dodge") HTH, Thierry -

Re: [R] Histogram with colors according to factor

2008-07-08 Thread ONKELINX, Thierry
After reading your question again I came up with these plots. dataset <- data.frame(x = c(rnorm(1000), rnorm(200, mean = 1)), y = gl(2, 100, labels = LETTERS[1:2])) ggplot(dataset, aes(x = x, group = y)) + stat_bin(aes(fill = ..count..), width = 0.2) + scale_fill_gradient(low = "red", high = "gree

Re: [R] ggplot2 - legend for fill coulours

2008-03-25 Thread ONKELINX, Thierry
Dear Pedro, Sorting your data before plotting it will probably sort your problem. plotdata2 <- plotdata2[order(plotdata2$group), ] HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research I

Re: [R] ggplot2 - facetting

2008-03-25 Thread ONKELINX, Thierry
Hi Pedro, I think that the code below gives you the plot you want. Notice that you don't have to add everthing seperatly. But you can if you feel the need to do so. ggplot(plotdata2, aes(x = x, y = y)) + geom_point() + facet_grid(group ~ .) plot0 <- ggplot(plotdata2, aes(x = x, y = y)) layer1 <

Re: [R] Combining several mappings in ggplot2

2008-03-26 Thread ONKELINX, Thierry
Tribo, It looks like geom_line() accepts only 4 linetypes and you asked for 5. library(ggplot2) Tree_v <- rep(c(1:5),each = 5) age_v <- rep(seq(1,25, by = 5),5) + 10*runif(25) circumference_v <- rep(seq(21,45, by = 5), 5)*Tree_v + 25*runif(25) #This will work Orange2 <- data.frame(Tree = as.fact

Re: [R] Combining several mappings in ggplot2

2008-03-27 Thread ONKELINX, Thierry
~ Roger Brinner The combination of some data and an aching 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: Tribo Laboy [mailto:[EMAIL PROTECTED] Verzonden: woensdag 26 maart 2008 17:42 Aan:

Re: [R] spatial cross-correlation

2008-04-01 Thread ONKELINX, Thierry
Dear Javier, It seems to me that you want to calculate cross variograms. You can do that with the gstat package. Have a look at the example in ?gstat libary(gstat) data(meuse) # let's do some manual fitting of two direct variograms and a cross variogram g <- gstat(id = "ln.zinc", formula = log(zi

Re: [R] set the lower bound of normal distribution to 0 ?

2008-04-01 Thread ONKELINX, Thierry
Dear Tom, In my opinion you should first transform your data to the log-scale and then calculate the mean and st.dev. of the log-transformed data. Because mean(log(x)) is not equal to log(mean(x)). HTH, Thierry ir.

Re: [R] need help with understanding stepAIC

2008-04-03 Thread ONKELINX, Thierry
Dear Balavelan, First I would suggest to include the main effects of all variables in an interaction. So you model with interaction should be y ~ a + b + c + d + c:d. Which can be abbreviated to y ~ a + b + c*d. Futhermore you should take a look at ?predict.glm and pay attention to the newdata an

Re: [R] sorting matrix for rownames

2008-04-07 Thread ONKELINX, Thierry
X[order(rownames(X)), ] ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality

Re: [R] permutation test assumption?

2008-04-08 Thread ONKELINX, Thierry
Dear João, You can do permutation tests on an unbalanced design. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwa

Re: [R] two graphs in one figure?

2008-04-10 Thread ONKELINX, Thierry
Dear Anne-Katrin, You could use ggplot to do this. The example below works, although it generates some warnings. library(ggplot2) dataset <- data.frame(x = 0:55, y = rnorm(56, 10), z = runif(56, 9, 11)) ggplot(data = dataset) + geom_bar(aes(x = factor(x), y = y), position = "dodge") + geom_line

Re: [R] Variogram problem

2008-04-29 Thread ONKELINX, Thierry
Nicolas, I think you better have a look at the gstat package. install.packages("gstat") library(gstat) example(gstat) ?variogram ?krige HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Rese

Re: [R] ggplot2: labels and breaks order does not match and I can't usescale_fill_identity

2008-04-30 Thread ONKELINX, Thierry
Mikhail, Have you tried sorting your dataframe according to the levels on the x-axis? HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie

Re: [R] Stepwise regression

2008-05-09 Thread ONKELINX, Thierry
Berthold, stepAIC does model selected based on AIC (or a similar criterion like BIC). So it does not uses the alpha levels. Hence it's pointless to specify them in stepAIC. HTH, Thierry ir. Thierry Onkelinx Instituu

Re: [R] Using lme() inside a function

2008-05-09 Thread ONKELINX, Thierry
Jorunn, This solutions works with R 2.7.0 under windows library(MASS) library(nlme) PredRes <- function(cal, val){ cal <<- cal lmemod <- lme(distance ~ age * Sex, random = ~1|Subject, data = cal, method="ML") themod <- stepAIC(lmemod, dir="both", trace = FALSE) prs <- predict(them

Re: [R] Permutations

2008-05-13 Thread ONKELINX, Thierry
Dear Elke, I think you need something like this. It's only for 3 variables, but I think you know how to expand it for more variables. mat <- expand.grid(a = 0:4, b = 0:4, c = 0:4) write.table(mat, file="C:/Documents and Settings/My Documents/permutations.txt",sep=";",col.names=FALSE, row.names=FA

Re: [R] Dividing Two Dataframes

2008-05-14 Thread ONKELINX, Thierry
Dear Bert, Another option is to replicate SDF2 so the number of rows matches with those of SDF1. SDF1 <- data.frame(matrix(rnorm(144 * 2), nrow = 144)) SDF2 <- data.frame(matrix(rnorm(12 * 2), nrow = 12)) SDF1 / SDF2 #yields the error SDF2a <- do.call(rbind, rep(list(SDF2), nrow(SDF1) / nrow(SD

Re: [R] autocorrelation in nlme; Error: cannot allocate vector of size

2008-05-16 Thread ONKELINX, Thierry
Dear Julia, You'll need to give more details on your model and the structure of your dataset. The problem will probably be in the specification of the random effects. But without the detail we can't check that. Thierry ---

Re: [R] sequence of vectors

2007-11-19 Thread ONKELINX, Thierry
expand.grid() is what you are looking for. expand.grid(x1, x2, x3) HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kw

Re: [R] xy.coords and log10

2007-11-20 Thread ONKELINX, Thierry
Have a look at scale_x_log10() and scale_y_log10() from the ggplot2 package. The helpfile with some examples is at http://had.co.nz/ggplot2/scale_continuous.html HTH, Thierry ir. Thierry Onkelinx Instituut voor natu

Re: [R] PCA with NA

2007-11-23 Thread ONKELINX, Thierry
Dear Birgit, You need to think about why you have that many NA's. In case of vegetation data, it is very common to have only a few species present in a site. So how would you record the abundance of a species that is absent? NA or 0 (zero)? One could argument that it needs to be NA because you

Re: [R] Fwd: Empty list to use in a for cycle

2007-11-26 Thread ONKELINX, Thierry
You could try something like this (untested). lapply(unique(elio2$id), function(i){ sub.mu <- exp.mu[exp.mu$id==i, ] n <- nrow(sub.mu) D <- matrix(0, n, n) diag(D) <- sub.mu$deriv.link A <- mat.cov[seq_len(n), seq_len(n)] R <- corstr[seq_len(n), seq_len(n)] SolveD <- solve(D) Solv

[R] ggplot2: Choosing colours

2007-12-03 Thread ONKELINX, Thierry
Dear useRs, I'm trying to specify the colour of a factor with ggplot2. The example below gets me close to what I want, but it's missing a legend. Any ideas? Thanks, Thierry library(ggplot2) dataset <- data.frame(x = rnorm(40), y = runif(40), z = gl(4, 10, labels = LETTERS[1:4])) ggplot(data =

Re: [R] ggplot2: Choosing colours

2007-12-03 Thread ONKELINX, Thierry
~M.J.Moroney -Oorspronkelijk bericht- Van: Domenico Vistocco [mailto:[EMAIL PROTECTED] Verzonden: maandag 3 december 2007 14:08 Aan: ONKELINX, Thierry CC: r-help@r-project.org Onderwerp: Re: [R] ggplot2: Choosing colours qplot(data=dataset, x, y, colour=z) ONKELINX, Thierry wrote: > Dear us

Re: [R] ggplot2: Choosing colours

2007-12-03 Thread ONKELINX, Thierry
icht- Van: hadley wickham [mailto:[EMAIL PROTECTED] Verzonden: maandag 3 december 2007 15:23 Aan: ONKELINX, Thierry CC: r-help@r-project.org Onderwerp: Re: [R] ggplot2: Choosing colours Hi Thierry, Have a look at http://had.co.nz/ggplot2/scale_identity. (The way you are currently doing it only w

Re: [R] Sweave : change value in rnw file to generate multiple "single"reports ?

2007-12-10 Thread ONKELINX, Thierry
I think something like this would work. Change your query to rs <- dbSendQuery(con, statement = paste("select * from treatdata where name='", whichDevice,"'", sep = "")) And then create a script like. whichDevice <- "Device1" Sweave("myfile.rnw") whichDevice <- "Device2" Sweave("myfile.rnw")

Re: [R] ggplot-How to define fill colours?

2007-12-18 Thread ONKELINX, Thierry
Pedro, I've had a similar problem. See this post for the solution: http://thread.gmane.org/gmane.comp.lang.r.general/100649/focus=100673 Cheers, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek /

Re: [R] geom_hline

2007-12-25 Thread ONKELINX, Thierry
Felipe, You'll need to define the limits yourself with scale_y_continuous. library(ggplot2) p <- ggplot(mtcars, aes(x = wt, y=mpg)) + geom_point() p + geom_hline(intercept=0) + scale_y_continuous(limits = c(0, max(mtcars$mpg))) Cheers, Thierry Van: [EMAIL P

Re: [R] how to make read-only data frames?

2008-01-11 Thread ONKELINX, Thierry
Dan, You could write a function that just creates the data. And call this function each time you need the data. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature

Re: [R] How to add rowSums into list?

2008-01-11 Thread ONKELINX, Thierry
a <- list(one=matrix(rnorm(20), 5, 4), two=matrix(rnorm(20, 3, 0.5),5,4)) lapply(a, function(x){ cbind(x, rowSums(x)) }) Cheers, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Insti

Re: [R] Problems with lattice plot

2008-01-18 Thread ONKELINX, Thierry
Dear Francesc, This is rather easy to do with the ggplot2 package. library(ggplot2) dataset <- expand.grid(x = 1:10, y = 1:50) dataset$z <- runif(nrow(dataset)) ggplot(data = dataset, aes(x = x, y = y, fill = z)) + geom_tile() + scale_fill_gradient(low="white", high="black") + coord_equal() Hav

Re: [R] Converting plots to ggplot2

2008-01-18 Thread ONKELINX, Thierry
Dear David, Try this solution. The data are stored is a dataframe instead of a list but they should be the same. Once you have this dataframe, thinks get rather easy. library(ggplot2) a <- seq(0, 360, 5)*pi/180 s <- seq(5, 45, 10)*pi/180 dataset <- expand.grid(a = a, s = s) d

Re: [R] geometric transformation

2008-01-22 Thread ONKELINX, Thierry
Javier, You can use two lm-models for that. One for each coordinate. Then use predict() to calculate the coordinates of the other points. And by the way: four points is not very much data to calculate a transformation. I mlight work if the image is not very much distorted and you have precise meas

Re: [R] restricted bootstrap

2008-09-05 Thread ONKELINX, Thierry
Grant, Have you considered a gls model instead of a lm model? In a gls model one can model the correlation between the measures. So you won't need to select a subset of your data. You can kind gls in the nlme package. HTH, Thierry ---

Re: [R] correct lme syntax for this problem?

2008-09-09 Thread ONKELINX, Thierry
Dear Matthew, First of all I'm forwarding this to R-SIG-Mixed, which is a more appropriate list for your question. Using a mixed effect with only 5 levels is a borderline situation. Douglas Bates recommends at least 6 levels in order to get a more or less reliable estimate. So I would consider the

Re: [R] plotting group means

2008-09-09 Thread ONKELINX, Thierry
Dear Erich, Have a look at ggplot2 library(ggplot2) dataset <- expand.grid(x = 1:20, y = factor(LETTERS[1:4]), value = 1:10) dataset$value <- rnorm(nrow(dataset), sd = 0.5) + as.numeric(dataset$y) plotdata <- aggregate(dataset$value, list(x = dataset$x, y = dataset$y), mean) plotdata <- merge(plo

Re: [R] randomly sample within clustered data?

2008-09-15 Thread ONKELINX, Thierry
Something like this? do.call("rbind", lapply( split(Dataf, Dataf$id), function(x){ x[sample(seq_len(nrow(x)), size=2), ] } ) ) HTH, Thierry

Re: [R] Use of colour in plots

2008-09-18 Thread ONKELINX, Thierry
Steve, Have a look at the ggplot2 package: library(ggplot2) ggplot(Jan, aes(x = PopDensity, y = Average.Burnt.Area.Fraction, colour = factor(Urban.Rural > 1.25))) + geom_point() ir. Thierry Onkelinx Instituut voor na

Re: [R] Mixed effects model with binomial errors - problem

2008-09-19 Thread ONKELINX, Thierry
First of all I'm forwarding this mail to the R-SIG-mixed-models, which is more appropriate to your question. Remember that family = bionomial uses by default the logit link. Hence all parameters will be on the logit scale. So you will need to backtransform them for comparison. Then you'll see tha

Re: [R] Use of colour in plots

2008-09-19 Thread ONKELINX, Thierry
John Tukey -Oorspronkelijk bericht- Van: Steve Murray [mailto:[EMAIL PROTECTED] Verzonden: donderdag 18 september 2008 19:08 Aan: r-help@r-project.org; ONKELINX, Thierry; [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED] Onderwerp: RE: [R] Use of colour in plots Dear Thierry and all, I've t

Re: [R] Use of colour in plots

2008-09-19 Thread ONKELINX, Thierry
:[EMAIL PROTECTED] Verzonden: vrijdag 19 september 2008 16:01 Aan: ONKELINX, Thierry; r-help@r-project.org Onderwerp: RE: [R] Use of colour in plots Sorry - I should've maybe also pointed out that the command I've been trying to use is: alpha(col="green", 1/10) On its own this res

Re: [R] Multiple hist(ograms) - One plot

2008-10-02 Thread ONKELINX, Thierry
Dear Michael, Try ggplot2. Use something like install.packages("ggplot2") library(ggplot2) recov <- 0:2 n <- 1000 all <- data.frame(bbED = rnorm(3 * n, mean = recov), recov = factor(rep(recov, n))) ggplot(data = all, aes(x = bbED)) + geom_histogram() + facet_grid(. ~ recov) ggplot(data = all, aes

Re: [R] Multiple hist(ograms) - One plot

2008-10-02 Thread ONKELINX, Thierry
a, varnames) : > Formula contains variables not in list of known variables > > How can I select cases? > > Any ideas or suggestions? > Thanks, > M Just > > On Thu, Oct 2, 2008 at 2:42 AM, ONKELINX, Thierry < > [EMAIL PROTECTED]> wrote: > >> Dear M

Re: [R] Multiple hist(ograms) - One plot

2008-10-03 Thread ONKELINX, Thierry
ohn Tukey Van: Michael Just [mailto:[EMAIL PROTECTED] Verzonden: vrijdag 3 oktober 2008 6:52 Aan: ONKELINX, Thierry CC: r-help@r-project.org; [EMAIL PROTECTED] Onderwerp: Re: [R] Multiple hist(ograms) - One plot Dieter and Thierry: Per you suggestions I have tried: ggp

Re: [R] ignore error in for-loop

2008-10-06 Thread ONKELINX, Thierry
Dear Erich, Have a look at the try()-function. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Sect

Re: [R] Plot grouped histograms

2008-10-10 Thread ONKELINX, Thierry
Another solution would be faclevels<-c("Not","Little","Somewhat","Very", NA) group <- factor(1:6) svdf<-data.frame(value = sample(group, 400, TRUE), category = sample(faclevels,400,TRUE)) library(ggplot2) ggplot(svdf, aes(x = value, fill = category)) + geom_histogram(position = "dodge") HTH, Thi

Re: [R] ggplot adding points

2008-10-10 Thread ONKELINX, Thierry
Dear Stephen, You need the data in long format. Try melt()ing it first. River.Mile <-c(202, 198, 190, 185, 179, 148, 119, 61) TSS <- c(1:8) DOC <- seq(2, by= 0.6, length.out=8) z <- data.frame(River.Mile, TSS, DOC) zMelt <- melt.data.frame(z, id.vars = "River.Mile") library(ggplot2) ggplot(zMelt,

Re: [R] apply model predictions over larger area with predict()

2008-10-15 Thread ONKELINX, Thierry
Dear Katrin, Store the "old" data in a dataframe instead of vectors and supply the name of that dataframe to your model. eg Model <- glm(species ~ temp + prec + elev, data = your.data.frame, family = binomial(link = logit)) Notice that I've added some spaces which makes your code more easy to r

[R] Automating citations in Sweave

2008-10-23 Thread ONKELINX, Thierry
Dear all, Is there an elegant way to add citations of packages when using Sweave? Ideally I'd like a function which creates a Bibtex-file with the packagenames as keys. The idea is to use \cite{packagename} or \cite{R} in LaTeX. I know you can get the Bibtex entry with toBibtex(citation("packagen

Re: [R] Automating citations in Sweave

2008-10-24 Thread ONKELINX, Thierry
. Berry [mailto:[EMAIL PROTECTED] Verzonden: donderdag 23 oktober 2008 18:54 Aan: ONKELINX, Thierry CC: r-help@r-project.org Onderwerp: Re: [R] Automating citations in Sweave On Thu, 23 Oct 2008, ONKELINX, Thierry wrote: > Dear all, > > Is there an elegant way to add citations of packages w

Re: [R] Prediction intervals for zero inflated Poisson regression

2008-12-17 Thread ONKELINX, Thierry
or an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: Achim Zeileis [mailto:achim.zeil...@wu-wien.ac.at] Verzonden: dinsdag 16 december 2008 16:45 Aan: ONKELINX, Thierry CC: r-help@r-project.org Onderwerp: R

Re: [R] Model building using lmer

2008-12-17 Thread ONKELINX, Thierry
Dear Luciano, The "1" in (1|NestID) indicates only a random intercept. Note that in most models in R, a "1" on the righthandside of the formula indicates the intercept, "-1" or "0" indicates no intercept. ~X, which is equivalent to ~X + 1, indicates a slope along X and an intercept. Hence a random

Re: [R] Problem with ggplot2

2008-12-18 Thread ONKELINX, Thierry
Are you sure that you have all your packages updated? Because qplot(mpg, wt, data=mtcars) works without a problem on my machine. Please add the info of sessionInfo() when reporting bugs. The posting guide asked you to do so. Thierry >sessionInfo() R version 2.8.0 (2008-10-20) i386-pc-mingw32

<    1   2   3   4   5   6   7   >