Re: [R] Run script automatically on several input files in the directory and produce separate outputs?

2014-12-05 Thread ONKELINX, Thierry
Dear Thomas, list.files() will be your new best friend. 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 + 32 2 525

Re: [R] R - Aggregate 3-Hourly Block Data into Weekly (Melt)

2014-12-19 Thread ONKELINX, Thierry
You are looking for the round_date(), floor_date() or ceiling_date() functions from the lubridate package. Those functions can round timestamps to weeks. ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie & Kwaliteitszorg / team

Re: [R] nlme package: changing reference for varIdent parameter estimates in summary.gls

2014-12-23 Thread ONKELINX, Thierry
Dear John, R-sig-mixed-models is more suited for this kind of questions. All follow-up mail should be posted only to that mailing list. It seems like varIdent() by default relevels the grouping factor and that the user cannot control this. Best regards, ir. Thierry Onkelinx Instituut voor nat

Re: [R] ggplot with sparse layout

2015-01-06 Thread ONKELINX, Thierry
Dear Tom, Does ggplot(data,aes(x=x,y=y))+geom_point(aes(color=group))+facet_wrap(~group + id) gives what you need? Note that facet_grid by design aligns the subplots into rows and columns with the same level. Best regards, ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research

Re: [R] ggplot with sparse layout

2015-01-07 Thread ONKELINX, Thierry
r can be extracted from a given body of data. ~ John Tukey Van: Tom Wright [mailto:t...@maladmin.com] Verzonden: woensdag 7 januari 2015 15:43 Aan: ONKELINX, Thierry CC: R. Help Onderwerp: Re: [R] ggplot with sparse layout Thanks, this is pretty good. Unfortunately I made an error in generating th

Re: [R] Suggestions for workaround for R Markdown problem with data() ?

2015-01-12 Thread ONKELINX, Thierry
Dear Molly, Is the package in which the data is stored loaded in the Rmd? If not try library(yourPackage) data(yourData) or data(yourData, package = "yourPackage") If this doesn't solve your problem, please provide a minimal reproducible example of the problem. Best regards, Thierry ir. Th

Re: [R] Prediction of response after glm on whitened data

2015-01-28 Thread ONKELINX, Thierry
Dear Xochitl, Have a look at gls() from the nlme package. It allows you to fit auto correlated errors. gls(k ~ NPw, correlation = corAR1(form = ~ Time)) Best regards, ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie & Kwalit

Re: [R] Trying to change a qplot() to a ggplot()+

2014-07-23 Thread ONKELINX, Thierry
It is ggplot (double G), not qqplot (double Q) 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 525 02 51 + 32 54 43 61 85 th

Re: [R] How to avoid the three loops in R?

2014-08-01 Thread ONKELINX, Thierry
It is possible to do without loops if you start by calculating the totals. Then is just aggregating and merging data. Best regards, Thierry set.seed(21) n.country <- 5 average.price <- runif(n.country, max = 200) price <- expand.grid( Product = 1:10, Country = factor(LETTERS[seq_len(n.coun

Re: [R] Performance (speed) of ggplot

2014-09-26 Thread ONKELINX, Thierry
You are using ggplot2 very inefficiently. Many geom's plot only one data point. You can combine several of them in a single geom. Have a look at this gridExtra package which has some useful functions like grid.arrange and tableGrob. Best regards, ir. Thierry Onkelinx Instituut voor natuur- en b

Re: [R] How to get rid of my for loop

2014-09-29 Thread ONKELINX, Thierry
Dear Barry, You have to rethink the input format. This is easy if you use a matrix. A <- cbind(A_01, A_02, A_03, A_04) index <- cbind(seq_along(VFD_ID), VFD_ID) A[index] Best regards, ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Bi

Re: [R] Dealing with NAs in lm or gmm

2014-10-21 Thread ONKELINX, Thierry
You want na.action = na.exclude. Or remove rows with NA values from your dataset. Which is IMHO the safest way to build a model. ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assu

Re: [R] Dealing with NAs in lm or gmm

2014-10-21 Thread ONKELINX, Thierry
pm miao [mailto:miao...@gmail.com] Verzonden: dinsdag 21 oktober 2014 11:35 Aan: ONKELINX, Thierry CC: r-help Onderwerp: Re: [R] Dealing with NAs in lm or gmm I tries "na.action = na.exclude" but it returns a fitted vector with NAs removed. Is there any way to return the fitted vector wit

Re: [R] rgdal: Convert ESRI ArcGis geo database (gdb directory) to geojson, or shapefile map

2014-10-27 Thread ONKELINX, Thierry
Dear Guido, Do you know how the gdb is stored? I had problems reading for a gdb on our networkdrive. Reading from a local copy worked. It turned out that the original copy on the networkdrive was indexed. Reading an unindexed gdb from the networkdrive was no problem. Best regards, ir. Thierry

Re: [R] the bug of function base::order

2014-11-10 Thread ONKELINX, Thierry
No that is not a bug. You are confusing order() with sort(). Please do read the helpfiles. 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

Re: [R] ggplot facet and subsetting

2014-11-27 Thread ONKELINX, Thierry
Dear Petr, You need to use aes_string() instead of aes(). The.cols <- colnames(data)[n:m] for (i in The.cols) { p<-ggplot(data, aes_string(x="x", y= i, colour="f"))), ...} Best regards, ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team

Re: [R] "Spreading risk" in a matrix

2008-07-18 Thread ONKELINX, Thierry
Have a look at the buffer function in the adehabitat package. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwalitei

Re: [R] "Spreading risk" in a matrix

2008-07-19 Thread ONKELINX, Thierry
Buffer works on a 2D dataset like a matrix. Have a look at the examples in ?buffer. But you probably will have to create a set of coordinaten of the points you want to buffer. HTH, Thierry ir. Thierry Onkelinx Instit

Re: [R] scatter plot using ggplot

2008-07-23 Thread ONKELINX, Thierry
Dear Megh, You need to use the ggplot2 package instead of ggplot. Use the size argument in geom_point() to get bigger circles. Have a look at Hadley's website for more info (and examples) on ggplot2: http://had.co.nz/ggplot2/ library(ggplot2) library(mnormt) Sigma = matrix(c(1, 0.6, 0.6, 1), 2,

Re: [R] experimental semivariogram

2008-07-23 Thread ONKELINX, Thierry
Alessandro, Have a look at the gstat package. library(gstat) demo(examples) demo(krige) HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biomet

Re: [R] Indicator Kriging?

2008-07-23 Thread ONKELINX, Thierry
Sascha, Have a look at ?krige in the gstat package. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg /

Re: [R] Simple... but...

2008-07-23 Thread ONKELINX, Thierry
Something like sort(c(x, y)) should do the trick. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Sec

Re: [R] A easy way to write formula

2008-07-27 Thread ONKELINX, Thierry
(x1 + x2 + x3) ^2 will give you the main effects and the interactions. So this will shorten your equation to ft <- lm(y ~ (x1 + x2 + x3) ^2 + I(x1 * x1)+ I(x2 * x2) + I(x3 * x3), mydata) HTH, Thierry ir. Thierry Onke

Re: [R] Retain plot?

2008-07-27 Thread ONKELINX, Thierry
Kevin, Open a new plot window before plotting the second plot. plot(rnorm(10), runif(10)) X11() plot(rnorm(10), runif(10)) HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Instit

Re: [R] speeding up loop and dealing wtih memory problems

2008-07-28 Thread ONKELINX, Thierry
Dear Denise, It looks like you want to replace all NA with 0 in the dataset? The code below should do that trick without loops. And it will be rather fast. dat[is.na(dat)] <- 0 > dat <- matrix(rbinom(40, 1, 0.75), ncol = 4, nrow = 10) > dat[dat == 0] <- NA > dat [,1] [,2] [,3] [,4] [1,]

Re: [R] 'for' loop, two variables

2008-07-29 Thread ONKELINX, Thierry
Dear Frederike, #Both your functions are vectorized. So you don't need loops. Working with vectorized functions is much faster than looping. fn <- function (x) { ifelse(x>46 & x<52, 1, 0) } res <- fn(40:60) fn <- function (x,y) { ifelse(x>46 & x<52 & y<12, 1, 0) } datagrid <- exp

Re: [R] combinations with replications

2008-07-31 Thread ONKELINX, Thierry
Or simply Datagrid <- expand.grid(rep(list(0:1), 8)) apply(Datagrid, 1, paste, collapse = "") HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel bi

Re: [R] anisotropy in vgm model. HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

2008-08-01 Thread ONKELINX, Thierry
Dear Alessandro, For the vgm-helpfile: "Anisotropy parameters define which direction this is (the main axis), and how much shorter the range is in (the) direction(s) perpendicular to this main axis." Notice that the directions should be perpendicular. 90° and 45° are not perpendicular. Please

Re: [R] Function to check the presence of an Item in an array

2008-08-01 Thread ONKELINX, Thierry
Look at %in% or match "foo" %in% x HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,

Re: [R] Newbie question: How to use tapply() on several vectorssimultaneously

2008-08-01 Thread ONKELINX, Thierry
Another option is ?by test <- as.data.frame(cbind(c(rep(1,5),rep(2,5)), rnorm(10), rnorm(10))) names(test)[1] <- "groupID" test$groupID <- factor(test$groupID) by(test[, -1], test$groupID, mean) HTH, Thierry ir. Thie

Re: [R] Sweave and ggplot2

2008-08-04 Thread ONKELINX, Thierry
Dear Sorn, It's hard to guess what your problem is, as you don't provide any sample code. My guess is that the graphics are empty. Did you use print(qplot(...)) or just qplot(). The latter won't work. You need print(qplot(...)) HTH, Thierry -

Re: [R] help with longitudinal data plot

2008-08-08 Thread ONKELINX, Thierry
Dear Robert, Try ggplot2 library(ggplot2) ggplot(your.dataframe.name, aes(x = age, y = score, group = subject)) + geom_line() HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Inst

Re: [R] Newbie programming help

2008-08-25 Thread ONKELINX, Thierry
Dear Steven, Take a look at the lmList function in the nlme package. It does what you want to do. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest C

Re: [R] parse and eval character vector

2008-08-26 Thread ONKELINX, Thierry
Just use as.numeric. Non numeric will be NA. So the solution of your problem is na.omit(as.numeric(temp1)) HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and

Re: [R] processing subset lists and then plot(density())

2008-08-26 Thread ONKELINX, Thierry
Here's a solution with ggplot2 library(ggplot2) ggplot(na.omit(d), aes(x = EPT.Taxa, colour = Site)) + geom_density() ggplot(na.omit(d), aes(x = EPT.Taxa)) + geom_density() + facet_grid(Site ~ .) HTH, Thierry ir. Th

Re: [R] Upgrading R means I lose my packages

2008-08-28 Thread ONKELINX, Thierry
On a windows machine you get the same problem. Useless one uses tha same trick as Rolf suggested: don't install the packages in the default directory and set R_LIBS to that directory. Then all you need to do after an upgrade is to set R_LIBS in the new version and run update.package(checkBuilt = T

Re: [R] Updating a list.

2008-08-28 Thread ONKELINX, Thierry
Kevin, Notice the subtle difference between Hadley's and your code: Hadley m2008$DayOfYear <- factor(m2008$DayOfYear, levels = 1:365) Kevin m2007$DayOfYear <- factor(m2008$DayOfYear, levels = 1:365) Your are using the m2007 object instead of the suggested m2008 object! HTH, Thierry --

Re: [R] ggplot2: problem with large fonts and overlapping labels

2008-08-28 Thread ONKELINX, Thierry
Dear Paul, How are you generating (saving) your plots? I tend to play with the pointsize argument of the graphical device, something in conjunction with the size argument in ggplot2 (size of points and lines). Working like that I get plots with nicely propotioned labels without overlaps. HTH, T

Re: [R] give all combinations

2008-09-01 Thread ONKELINX, Thierry
A more generic solution is allComb <- expand.grid(rep(list(letters[1:5]), 7)) whichComb <- sapply(seq_len(ncol(allComb) - 1), x = allComb, function(i, x){ whichCombination <- sapply(seq(i + 1, ncol(x)), y = x, function(j, y){ as.numeric(y[, i]) <= as.numeric(y[, j]) }) apply(w

Re: [R] Avoiding factors and levels in data frames

2008-09-01 Thread ONKELINX, Thierry
Try to add options(stringsAsFactors = FALSE) in your Rprofile.site (in the etc directory). Using as.is = TRUE seems safer than stringsAsFactors = FALSE in the read.fwf function. Because as.is is set to FALSE by default and stringsAsFactors is not set. HTH, Thierry -

Re: [R] Avoiding factors and levels in data frames

2008-09-01 Thread ONKELINX, Thierry
an: r-help@r-project.org Onderwerp: Re: [R] Avoiding factors and levels in data frames On 01-Sep-08 08:20:25, ONKELINX, Thierry wrote: > > Try to add options(stringsAsFactors = FALSE) in your Rprofile.site > (in the etc directory). Using as.is = TRUE seems safer than > stringsAs

Re: [R] another histogram question

2008-09-01 Thread ONKELINX, Thierry
Antje, Have a look at ?hist. It seems like you want this: data <- rnorm(100) hist(data, xlim = c(0,6)) HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and F

Re: [R] ANCOVA/glm missing/ignored interaction combinations

2008-09-03 Thread ONKELINX, Thierry
Lara, The first category is nor missing, nor ignored. It is used as the reference. So the temperature effect for semio1 is only temperature. The temperature effect for semio2 is temperature + temperature:semio2. For semio3 it is temperature + temperature:semio3. Hence the main effect of temperatur

Re: [R] ggplot2: line plot with gaps in time axis

2008-09-04 Thread ONKELINX, Thierry
Brian, The easiest way is to create the entire timeseries and then set the missing values to NA. The NA values will lead to the gaps you want. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek

Re: [R] Coefficient of skewness

2008-09-04 Thread ONKELINX, Thierry
Dear Robin, RSiteSearch("skewness", restrict = "functions") gave me 222 hits. There are several functions that calculate skewness. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research I

Re: [R] obtain linear regression parameters from qplot

2009-08-11 Thread ONKELINX, Thierry
It's much easier to extract that info from lm itself. Model <- lm(Intensity ~ Time, data = totalD, subset = Name == "increase1") coef(Model) HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek /

Re: [R] ggplot: colours to geom_segments

2009-08-11 Thread ONKELINX, Thierry
Dear John, You need to change colour = "darkgreen" into aes(colour = Food). This will give a different colour along Food. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute

Re: [R] How do I plot: regression line, regression line + s.d, regression line - s.d on the same chart?

2009-08-11 Thread ONKELINX, Thierry
Another option is to use ggplot2 Dataset <- data.frame(x = runif(100, -5, 5)) Dataset$y <- 3 + 2 * Dataset$x + rnorm(100, sd = 2) library(ggplot2) ggplot(Dataset, aes(x = x, y = y)) + geom_smooth(method = "lm") + geom_point() -

Re: [R] ggplot: colours to geom_segments

2009-08-11 Thread ONKELINX, Thierry
hat a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: John Kane [mailto:jrkrid...@yahoo.ca] Verzonden: dinsdag 11 augustus 2009 16:38 Aan: r-h...@stat.math.ethz.ch; ONKELINX, Thierry Onderwerp: RE: [R] ggplot: colours to geom_segments &

Re: [R] A function for plotting a boxplot with added dot and bars (formean and SE) - please help improve my code

2009-08-12 Thread ONKELINX, Thierry
This can be done much easier and transparent with ggplot2 library(ggplot2) ggplot(mtcars, aes(x = factor(round(wt)), y = mpg, colour = factor(am))) + geom_boxplot() + geom_point(stat = "summary", fun.y = "mean", position = position_dodge(width = 0.75)) HTH, Thierry

Re: [R] A function for plotting a boxplot with added dot and bars (formean and SE) - please help improve my code

2009-08-12 Thread ONKELINX, Thierry
not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey Van: Tal Galili [mailto:tal.gal...@gmail.com] Verzonden: woensdag 12 augustus 2009 12:48 Aan: ONKELINX, Thierry CC: r-help@r-project.org Onderwerp: Re: [R] A fun

Re: [R] un run run...

2009-08-13 Thread ONKELINX, Thierry
Here is an example in pseudo code. Instead of Object <- function that can generate error Other things to do Do something like Object <- try(function that can generate error) if(class(Object) == "try-error"){ things to do when an error occures } else { other things to do } HTH,

[R] Matching two series

2009-08-18 Thread ONKELINX, Thierry
Dear all, I am struggling with a problem and I am hoping that somebody could point me in the right direction. I am trying to match the locations of two peak patterns. A is the true pattern. B is the measured pattern. Hence A and B have a very strong linear relationship. The problem is that B can

Re: [R] Reshape package: Casting data to form a grid

2009-08-18 Thread ONKELINX, Thierry
Dear Steve, You need something like this. cast(Latitude ~ Longitude, data = finalframe, value = "Blaney", fun = mean) HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for

Re: [R] ggplot 2 semi-transparency error

2009-08-19 Thread ONKELINX, Thierry
ggplot2 has it's own build in wrapper-function to store plots: ggsave. p <- ggplot(a,aes(x=V1,colour=V2,fill=V2)) + geom_density(alpha = 0.2,xlim=c(-10,10),ylim=c(0,0.5)) ggsave(p, filename = "/alpha/dtc.pdf") HTH, Thierry

Re: [R] lmer with random slopes for 2 or more first-level factors?

2009-08-19 Thread ONKELINX, Thierry
Dear Jason, Both models have a correct syntax. Although I would write the last model rather as lmer(DV ~ IV1 + IV2 + (1|Subject) + (IV1 - 1| Subject) + (IV2 - 1| Subject)) The only difference is indeed the correlation between the random effects. The random effects in the model I wrote are all ind

Re: [R] ggplot2 legend problem

2009-08-19 Thread ONKELINX, Thierry
Dear Chris, First of all I would go for the density plot. The 'extra' info from the histogram is just noise. So I guess you are not interessed in it. ggplot(xy, aes(x=value, colour=case, group=case)) + geom_density() But is you want to stick with a histogram then I would use one of the two below

Re: [R] ggsave to .png bug in ggplot2 (?)

2009-08-20 Thread ONKELINX, Thierry
Dear Chris, That problem is due to the fact that ggsave() and png() use different default for the resolution. ggsave() uses 300 dpi and png() 72 dpi. If you set the resolution in ggsave() to 72 then you get exactly the same output as on the screen. But the resolution is way to low for publication

Re: [R] nested, repeated measure lme

2009-08-20 Thread ONKELINX, Thierry
Dear Christoph, Why should (1) not work? As long as you have enough levels, it should not be a problem. You need at least 6 levels for each random effect. When you have less than six levels, then you better move those variables to the fixed effects. An example: 2 blocks with each 2 plots. Each pl

Re: [R] 2d color coded line plot

2009-08-21 Thread ONKELINX, Thierry
Have a look at the ggplot2 package. You will find a lot of examples at http://had.co.nz/ggplot2/ library(ggplot2) dataset <- data.frame(x = seq(-1, 1, length = 101)) dataset$y <- dataset$x + dataset$x^2 dataset$z <- 10 * dataset$x + 1 ggplot(dataset, aes(x = x, y = y, colour = z)) + geom_point()

Re: [R] how to add 95% confidential interval as vertical lines to x axein density plot

2009-08-24 Thread ONKELINX, Thierry
Show us how you extract the confidence interval from the functions in the hdrcde library and then we might be able to help you. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Ins

Re: [R] counting subgroup sums within a data frame

2009-08-26 Thread ONKELINX, Thierry
Have a look at the reshape package. Assuming that your data is in a data.frame called "dataset". cast(Date ~ ., data = dataset, value = "count", fun = sum) cast(Date ~ class, data = dataset, value = "count", fun = sum) cast(Date + class ~ ., data = dataset, value = "count", fun = sum) Or the

Re: [R] lme: how to nest a random factor in a fixed factor?

2009-08-26 Thread ONKELINX, Thierry
Dear Robert, Since you have only 4 sites, a random effect is not so good. You would need at least 6 sites for a good estimate of the variance. You have enough data to treat site as a fixed effects. It only costs 2 extra degrees of freedom. Therefore I would model this like: lm(response ~ (area/s

Re: [R] problem plotting with ggplot2

2009-08-28 Thread ONKELINX, Thierry
Remove the y=c2 from your histogram plot. ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, metho

Re: [R] help on ar(1)

2009-08-31 Thread ONKELINX, Thierry
Have a look at the gls() function from the nlme package. The helpfile of gls() contains an example of an AR1 structure. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute fo

Re: [R] Howto Superimpose Multiple Density Curves Into One Plot

2009-09-02 Thread ONKELINX, Thierry
Have a look at the ggplot2 package. library(ggplot2) dat <- read.table("mydat.txt") ggplot(dat, aes(x = V1, colour = factor(V2))) + geom_density() #or a few alternatives ggplot(dat, aes(x = V1, fill = factor(V2))) + geom_density(alpha = 0.2) ggplot(dat, aes(x = V1)) + geom_density() + facet_wrap(

Re: [R] Howto Superimpose Multiple Density Curves Into One Plot

2009-09-02 Thread ONKELINX, Thierry
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: Gundala Viswanath [mailto:gunda...@gmail.com] Verzonden: woensdag 2 september 2009 14:33 Aan: ONKELINX, Thierry CC

Re: [R] Howto Superimpose Multiple Density Curves Into One Plot

2009-09-02 Thread ONKELINX, Thierry
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: Gundala Viswanath [mailto:gunda...@gmail.com] Verzonden: woensdag 2 september 2009 14:47 Aan: ONKELINX, Thier

Re: [R] Howto Superimpose Multiple Density Curves Into One Plot

2009-09-02 Thread ONKELINX, Thierry
.com] Verzonden: woensdag 2 september 2009 14:54 Aan: ONKELINX, Thierry CC: r-h...@stat.math.ethz.ch Onderwerp: Re: [R] Howto Superimpose Multiple Density Curves Into One Plot > str(dat) 'data.frame': 200 obs. of 2 variables: $ V1: num 0.98 0.19 1.09 0.21 0.26 0.98 0.31 0.88 0.23 0.2 ..

Re: [R] Howto Superimpose Multiple Density Curves Into One Plot

2009-09-02 Thread ONKELINX, Thierry
- Van: Gundala Viswanath [mailto:gunda...@gmail.com] Verzonden: woensdag 2 september 2009 15:21 Aan: ONKELINX, Thierry CC: r-h...@stat.math.ethz.ch Onderwerp: Re: [R] Howto Superimpose Multiple Density Curves Into One Plot Which version of ggplot2 you use? Mine is: Version: 0.7 Date:

Re: [R] Average over data sets

2009-09-02 Thread ONKELINX, Thierry
Here is a solution assuming that all files have the same structure and a variable TimePoint which contains the time info. CombinedData <- do.call(rbind, lapply(seq_len(20), function(i){ fileName <- paste("output", i, ".dat", sep="") read.table(fileName, header=TRUE) })) library(ply

Re: [R] Howto fit normal curve into histogram using GGPLOT2

2009-09-02 Thread ONKELINX, Thierry
That is not very complex with densities instead of counts. library(ggplot2) ggplot(mtcars, aes(x = mpg)) + geom_histogram(aes(y = ..density..), fill = "red") + stat_function( fun = dnorm, args = with(mtcars, c(mean = mean(mpg), sd = sd(mpg)))

Re: [R] Easy way to get top 2 items from vector

2009-09-04 Thread ONKELINX, Thierry
Using tail() for the selection is more elegant and slightly faster. > N<- 100 > x <- runif(N) > system.time(x[order(x)[c(N-1,N)]]) user system elapsed 1.080.011.10 > system.time(sort(x)[c(N-1,N)]) user system elapsed 0.360.000.35 > system.time(tail(sort(x), 2)

Re: [R] plot positive predictive values

2009-09-04 Thread ONKELINX, Thierry
You could use a glm with the binomial family to model that. A solution with ggplot2 library(ggplot2) ggplot(dataset, aes(x = x, y = y, weights = n)) + geom_smooth(method = "glm", family = binomial) geom_point()

Re: [R] Linear Contrasts in GLM - Query

2009-09-04 Thread ONKELINX, Thierry
Have a look at glht() from the multcomp package. That will allow you to specify the contrasts for posthoc tests. A more direct approach is the create the required dummy variables yourself. HTH, Thierry ir. Thierry Onk

Re: [R] linear mixed model question

2009-09-07 Thread ONKELINX, Thierry
Dear Wen, Since each worker only works on one machine, your model fm2 does not make sense. Your random effects tries to model how the effect of each worker differs between machines. But you don't have that kind of information if a work only works one machine. HTH, Thierry

Re: [R] barplot with lines instead of bars

2009-09-08 Thread ONKELINX, Thierry
Here is a solutions using ggplot2 and reshape library(reshape) library(ggplot2) data <- data.frame(k = 0:3, fk = c(11, 20,7,2), f0k = c(13.72, 17.64, 7.56, 1.08), fkest = c(11.85, 17.78, 8.89, 1.48)) Molten <- melt(data, id.vars = "k") ggplot(Molten, aes(x = k, y = value, colour = variable)) + g

Re: [R] gstat---2 basic plot questions

2009-09-09 Thread ONKELINX, Thierry
Dear Steve, Here are a fex examples for empirical variograms using ggplot2 library(gstat) library(ggplot2) data(meuse) coordinates(meuse) = ~x+y vgIso <- variogram(log(zinc)~x+y, meuse) vgIso$id <- "iso" vgAniso <- variogram(log(zinc)~x+y, meuse, alpha=c(0,45,90,135)) vgAniso$id <- "aniso" Empir

Re: [R] ggplot, ribbon not showing up properly

2009-09-15 Thread ONKELINX, Thierry
Dear Sock, I'm wondering if that mean_sdl function is return what you are expecting. I would calculate the statistics outside ggplot. RibbonData <- ddply(dat.less, "Day", function(x){ mean(x$Y) + c(ymin = -1, ymax = 1) * sd(x$Y) }) p + stat_summary(data=dat.less, aes(group=1), geom="cross

Re: [R] use of class variable in r as in Proc means of sas

2009-09-23 Thread ONKELINX, Thierry
You might need to change the type quantile. The default is type = 7, whereas default for SAS is type = 3 and for SPSS type = 6. Have a look at the helpfile of quantile() for more details on the type. HTH, Thierry ir.

Re: [R] Longitudinal analysis: contrasting time points

2010-02-23 Thread ONKELINX, Thierry
Dear Denis, Have a look at the lme() and nlme() functions, both in the nlme package. You find more details in Pinheiro & Bates (2000). A linear trend over time: lme(Y ~ Year, random = ~1|Department/Person) Contrasts between years: lme(Y ~ factor(Year), random = ~1|Department/Person) You might w

Re: [R] is there an inverse method for table()?

2010-03-09 Thread ONKELINX, Thierry
rep() is your friend. HTH, Thierry > x <- c(86, 90, 94, 98, 102, 106, 110, 114, 118, 122, 126, 130, 134, 138, > 142, 146, 150, 154, 158, 162, 166, 170, 174) > y <- c(2, 5, 10, 17, 26, 60, 94, 128, 137, 128, 77, 68, 65, 60, 51, 26, 17, > 9, 5, 2, 3, 7, 3) > rep(x, y) [1] 86 86 90 90

Re: [R] simple plot in ggplot2, wrong error bars

2010-03-12 Thread ONKELINX, Thierry
Dear Beto, The code below gives a correct result. library(ggplot2) df <- data.frame( trt = factor(c("intact", "intact", "removed", "removed")), coon = c(0.093, 0.06, 0.057, 0.09), group = factor(c("veget", "fruit", "veget", "fruit")), se = c(0.01, 0.01, 0.02, 0.0

Re: [R] Care to share an R presentation?

2010-03-18 Thread ONKELINX, Thierry
Have a look at this presentation of Matthew Keller: http://www.matthewckeller.com/Lecture1.ppt Best regards, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek team Biometrie & Kwaliteitszorg Gaverstra

Re: [R] lmer (or lme) with heteroscedasticity

2009-06-30 Thread ONKELINX, Thierry
Dear Daryl, 1) use pdDiag to get indepedent random effects. lme(Y ~ disease, random = list(radiologist = pdDiag(~disease)), weight = varGroup(~disease)) 2) lmer can't handle variance structures like nlme can. I believe it is on Douglas Bates to do list. But rather at the bottom of it. HTH, Thie

Re: [R] (no subject)

2009-07-02 Thread ONKELINX, Thierry
Andriy, It does exactly what you want it to do. So if the result is not what you expected, then you are supplying R with a wrong command. If you would have read the helpfile of read.csv you would have noticed the sep and dec argument would be very useful in this case. Thierry -

Re: [R] hi friends, is there any wait function in R

2009-07-14 Thread ONKELINX, Thierry
Dear Deepak, You'll need to clarify what EXACTLY is happening? If empty plots are created then try to wrap the plot() in print() statements. print(plot(...)). Furthermore I would recommend to avoid attach. HTH, Thierry

Re: [R] Help needed in identifying type of plot

2009-07-14 Thread ONKELINX, Thierry
It is a plot with pointranges. Here is an example with the ggplot2 package library(ggplot2) #use the diamond data set from ggplot2 diamonds$A <- diamonds$depth < 60 dmod <- lm(price ~ cut * A, data=diamonds) cuts <- unique(diamonds[, c("cut", "A")]) cuts <- cbind(cuts, predict(dmod, cuts, se=T)[c

Re: [R] Save results

2009-07-16 Thread ONKELINX, Thierry
Have a look at ?write.table ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and qua

[R] Cryptic error with Roxygen

2009-07-16 Thread ONKELINX, Thierry
Dear all, I'm using Roxygen for the first time and I'm getting a rather cryptic error message. I must be doing something wrong but I have no clue what is it. Any suggestions? Regards, Thierry roxygenize("AFLP", roxygen.dir = "AFLP", copy.package = FALSE, unlink.target = FALSE) Writing AFLP.outl

Re: [R] PROBIT REGRESSION FOR GROUPED/CLUSTERED DATA

2009-07-16 Thread ONKELINX, Thierry
Dear Saurav, I get the feeling that you are looking for mixed models. Try something like. library(lme4) glmer(s ~ age + gender + gemedu + gemhinc + es_gdppc + imf_pop + estbbo_m + (1|yearctry), family = binomial(link = "probit"), data = adpopdata) HTH, Thierry

Re: [R] how to evaluate character vector within pnorm()

2009-07-17 Thread ONKELINX, Thierry
Dear Thomas, You don't need parse() X <- c(mean = 2, sd = 3) pnorm(0, mean = X["mean"], sd = X["sd"]) Have a look at library(fortunes) fortune(106) HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en boso

Re: [R] param:qsec in ggplot2

2009-07-23 Thread ONKELINX, Thierry
Dear Mo You only need to use the name of a variable in your dataframe. The example below lets the size of the points depend on the variable carat. library(ggplot2) ggplot(diamonds, aes(x = table, y = price, size = carat)) + geom_point() HTH, Thierry ---

Re: [R] contour plot

2009-07-23 Thread ONKELINX, Thierry
Have a look at the reshape and ggplot2 package. ds <- matrix(rnorm(100), nrow = 10) library(reshape) molten <- melt(data = ds) library(ggplot2) ggplot(molten, aes(x = X1, y = X2, z = value)) + geom_contour() HTH, Thierry ---

Re: [R] Another question on gplot

2009-07-23 Thread ONKELINX, Thierry
Well, you did not specify the dataset. You want: ds <- data.frame(dat1 = rsn(1000, 0, 1, 0)) ggplot(ds, aes(x = dat1)) + geom_histogram(aes(y = ..density.., fill = ..count..)) + xlab("Distribution") + scale_y_continuous("") HTH, Thierry

Re: [R] ggplot question

2009-07-24 Thread ONKELINX, Thierry
Have a look at the colour argument of geom_line() http://had.co.nz/ggplot2/geom_line.html You need colour = A_Factor_With_Names_Of_Timeseries I recommend to you read the first chapters of Hadley's book on ggplot2 (it's on the ggplot2 website). That will answer much of your basic ggplot2 questions

Re: [R] storing output in html or pdf table format.

2009-07-28 Thread ONKELINX, Thierry
Have a look at Sweave (in the utils package) or the R2HTML package. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en k

Re: [R] Fwd: randomized block design analysis in R

2009-07-28 Thread ONKELINX, Thierry
Dear Alisia, These are not very easy questions to answer without detailed knowledge on your design. That's probably why you did not get any responses so far (I've seen your mail pop-up several times). I would recommend that you seek guidance with your supervisor or with the local statistician. Ha

Re: [R] Installing lme4 package in Windows Vista

2009-07-29 Thread ONKELINX, Thierry
Dear Angela, lme() is a part of the nlme package. The lme4 package has the function lmer() which is the equivalent of lme() from nlme. Both function differ in their capabilities. Briefly: lmer() can (easly) do crossed random effects and GLMM, lme() can handle variance and correlation structures.

Re: [R] Newbie in R: Reading .txt files and storing the 'numbers' in avector

2009-07-29 Thread ONKELINX, Thierry
Have a look at ?read.table HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, method

  1   2   3   4   5   6   7   >