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 02 51
+ 32 54 43 61 85
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: R-help [mailto:r-help-boun...@r-project.org] Namens Thomas Barningham
Verzonden: vrijdag 5 december 2014 14:41
Aan: r-help@r-project.org
Onderwerp: [R] Run script automatically on several input files in the directory 
and produce separate outputs?

Hi,

I have written a script that currently reads in a .txt file where I specify the 
name e.g

mydata<-read.table("a_date.txt", header=TRUE)

The script eventually produces a plot, e.g:

pdf(file="myfilename.txt")
plot(etc)
dev.off

What I want to do is run this script on several input files in my directory, 
without having to manually change the input file name each time, and produce 
the output plot pdf with the input file name as the output file name. It would 
also be handy if my plot title is also the input file name.

I'm relatively new to R so i'm not sure how to approach this. I presume it's 
some sort of loop function, but i've never implemented one of these before - 
any advice would be greatly appreciated!

Thanks in advance!
Thomas
--
Thomas Barningham
Centre for Ocean and Atmospheric Sciences School of Environmental Sciences 
University of East Anglia Norwich Research Park Norwich
NR4 7TJ

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
 D I S C L A I M E R 
Bezoek onze website/Visit our 
website

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium
+ 32 2 525 02 51
+ 32 54 43 61 85
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: R-help [mailto:r-help-boun...@r-project.org] Namens Shouro Dasgupta
Verzonden: donderdag 18 december 2014 16:13
Aan: r-help@r-project.org
Onderwerp: [R] R - Aggregate 3-Hourly Block Data into Weekly (Melt)

I am trying to compute max, min, and mean from Global Circulation Models
(GCM) for the US. The data is in 3-hour blocks for 2026-2045 and 2081-2100.
Sample Data:

tmp1 <- structure(list(FIPS = c(1001L, 1003L, 1005L), X2026.01.01.1 = 
c(285.5533142,
  285.5533142, 286.2481079), X2026.01.01.2 = c(283.4977112, 283.4977112,
  285.0860291), X2026.01.01.3 = c(281.9733887, 281.9733887, 284.1548767
  ), X2026.01.01.4 = c(280.0234985, 280.0234985, 282.6075745),
  X2026.01.01.5 = c(278.7125854, 278.7125854, 281.2553711),
  X2026.01.01.6 = c(278.5204773, 278.5204773, 280.6148071)), .Names = 
c("FIPS",
  "X2026.01.01.1", "X2026.01.01.2", "X2026.01.01.3", "X2026.01.01.4",
  "X2026.01.01.5", "X2026.01.01.6"), class = "data.frame", row.names = c(NA,
  -3L))

I have extracted the data by FIPS code and reshaped the yearly data files using 
melt();

for (i in filelist) {
  tmp1 <- as.data.table(read.csv(i,header=T, sep=","))
  tmp2 <- melt(tmp1, id="FIPS")
  tmp2$year <- as.numeric(substr(tmp2$variable,2,5))
  tmp2$month <- as.numeric(substr(tmp2$variable,7,8))
  tmp2$day <- as.numeric(substr(tmp2$variable,10,11))}

I have added datestring and weekdays using the following code:
Inserting Date Variable

tmp2$date <- with(tmp2, ymd(sprintf('%04d%02d%02d', year, month, day)))

Inserting Day Variable

tmp2$day <- weekdays(as.Date(tmp2$date))

sample.tmp2 <- "FIPS xdate temp year month  day
date  dates weekdays
+ 5599311  1003 X2045.08.14.2 304.5995 2045 8   Monday 2045-08-14
2036-01-292
+ 468406  39093 X2045.01.19.7 267.8483 2045 1 Thursday 2045-01-19
2028-06-040
+ 5022078 21167 X2045.07.21.8 314.6772 2045 7   Friday 2045-07-21
2035-09-134
+ 186822   9005 X2045.01.08.5 269.0803 2045 1   Sunday 2045-01-08
2037-06-280
+ 3998678 13295 X2045.06.10.7 307.2408 2045 6 Saturday 2045-06-10
2033-10-134"

Data <- read.table(text=sample.tmp2, header = TRUE)

My goal is to aggregate these 3-hourly blocks into weekly data, however, GCM 
data is not consistent and the blocks vary between 7 and 8. I want to clip the 
data to start on the first Monday of 2026 and end on the last Sunday of 2045 
and then use rep() to assign week numbers for the whole epoch.

I know I can count the number of each day using something like this;

length(which(weekdays == '0'))

Where 0, 1, 2..., 6 represent Sunday, Monday,...

My question is am I doing anything wrong in trying to aggregate the data to 
begin with? But importantly, I would be grateful for any help to clip the 
dataset to begin on the first Monday and end on the last Sunday. Thank you very 
much!

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Disclaimer Bezoek onze website / Visit our 
website

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 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
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: R-help [mailto:r-help-boun...@r-project.org] Namens Kornak, John
Verzonden: dinsdag 23 december 2014 22:29
Aan: r-help@R-project.org
Onderwerp: [R] nlme package: changing reference for varIdent parameter 
estimates in summary.gls


Dear R experts,

I am running gls models with heterogeneous group variances using the glm 
function in the nlme package with varIdent weights. I am interested in 
controlling the baseline level for the group variance function standard 
deviation estimates by applying the relevel function to the group variable. 
When I use relevel, the baseline level in the coefficient table changes as 
expected, but the baseline level does not change for the variance function 
table; for example, see the fitted models gls1 vs. gls2 in the contrived 
example below. Does anyone have a suggestion as to how I can change the 
baseline level for the variance function output please? In addition to the 
example below, I have tried specifying the value argument as per the varIdent 
help page, e.g. variIdent(c(no=0.5), form = ~1|group) and have google searched 
/ checked help pages for solutions without success.

I am running R version 3.1.0 on an iMac OSX v. 10.9.5

Thank you in advance

John Kornak

> library(nlme)
> group <- factor(c(rep("no",20),rep("yes",20)))
> set.seed(2)
> outcome <- c(rnorm(20,0,2),rnorm(20,5,4)) dataTest <-
> data.frame(outcome,group)

# Original model fit before releveling
> gls1 <- gls(outcome ~ group, weights=varIdent(form = ~1|group),
> data=dataTest)
> summary(gls1)

  snip

Variance function:
 Structure: Different standard deviations per stratum
 Formula: ~1 | group
 Parameter estimates:
 no yes
1.0 2.23034

Coefficients:
   Value Std.Error  t-value p-value
(Intercept) 0.390922 0.4734001 0.825775  0.4141
groupyes4.607951 1.1571140 3.982279  0.0003

  snip

Residual standard error: 2.11711
Degrees of freedom: 40 total; 38 residual


# relevel the group so that  yes  is the reference
> dataTest$group <- relevel(dataTest$group,"yes")
> gls2 <- gls(outcome ~ group, weights=varIdent(form = ~1|group),
> data=dataTest)
> summary(gls2)

  snip

Variance function:
 Structure: Different standard deviations per stratum
 Formula: ~1 | group
 Parameter estimates:
 no yes
1.0 2.23034 ###  no" is still the reference group here for 
the variance function

Coefficients:
Value Std.Error   t-value p-value
(Intercept)  4.998873  1.055843  4.734484   0e+00
groupno -4.607951  1.157114 -3.982279   3e-04  #  yes  has become the 
reference for the coefficients

   snip

Residual standard error: 2.11711
Degrees of freedom: 40 total; 38 residual
>

---
John Kornak, PhD
Associate Professor in Residence
Department of Epidemiology and Biostatistics University of California, San 
Francisco Mission Hall: Global Health & Clinical Sciences Building
550 16th St, 2nd floor, Box #0560
San Francisco, CA 94158-2549
Tel: 415-514-8028
Fax: 415-514-8150
Email: john.kor...@ucsf.edu




[[alternative HTML version deleted]]

Disclaimer Bezoek onze website / Visit our 
website
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 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
thierry.onkel...@inbo.be
www.inbo.be
To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ 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


Van: R-help [r-help-boun...@r-project.org] namens Tom Wright [t...@maladmin.com]
Verzonden: dinsdag 6 januari 2015 22:13
Aan: R. Help
Onderwerp: [R] ggplot with sparse layout

Hi,

I would like to plot the following data such that each plot represents the
data from a single id and the plots are grouped according to the group
variable.

data<-data.frame(id=factor(rep(1:6,each=3)),
 group=factor(c('a','a','b','c','c','c')),
 x=runif(18,0,10),
 y=rnorm(18,0,1))

The following ggplot nearly works but I would prefer to not plot the
missing combinations, i.e. each row will be a different length.

ggplot(data,aes(x=x,y=y))+geom_point(aes(color=group))+facet_grid(group~id)

Is this possible using ggplot or will I need to craft something using grid?

Thanks for any ideas.
Tom

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Disclaimer

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] ggplot with sparse layout

2015-01-07 Thread ONKELINX, Thierry
Dear Tom,

You can’t do that with facet_grid() or facet_wrap(). You could try combine 
several plots with grid.arrange().

p1 <-
  ggplot(subset(data, group == 
"a"),aes(x=x,y=y))+geom_point(aes(color=group))+facet_wrap(~id, nrow = 1) + 
scale_colour_discrete(drop = FALSE)
p2 <-
  ggplot(subset(data, group == 
"b"),aes(x=x,y=y))+geom_point(aes(color=group))+facet_wrap(~id, nrow = 1) + 
scale_colour_discrete(drop = FALSE)
p3 <-
  ggplot(subset(data, group == 
"c"),aes(x=x,y=y))+geom_point(aes(color=group))+facet_wrap(~id, nrow = 1)  + 
scale_colour_discrete(drop = FALSE)
library(gridExtra)
grid.arrange(p1, p2, p3)

If those solutions are not good enough, then you'll need to craft it in grid. 
Or look at the source code of ggplot2 and change that to get what you want.

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 02 51
+ 32 54 43 61 85
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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

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 the 
sample dataframe, this code better represents the situation:
data<-data.frame(id=factor(rep(1:6,each=3)),
  group=factor(rep(c('a','a','b','c','c','c'),each=3)),
  x=runif(18,0,10),
  y=rnorm(18,0,1))
I would like the first row to contain plots for id=1 & id=2, the second row 
plots for id=3 and the third row for id=4:6



On Tue, Jan 6, 2015 at 5:58 PM, ONKELINX, Thierry  
wrote:
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 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
thierry.onkel...@inbo.be
www.inbo.be
To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ 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


Van: R-help [r-help-boun...@r-project.org] namens Tom Wright [t...@maladmin.com]
Verzonden: dinsdag 6 januari 2015 22:13
Aan: R. Help
Onderwerp: [R] ggplot with sparse layout

Hi,

I would like to plot the following data such that each plot represents the
data from a single id and the plots are grouped according to the group
variable.

data<-data.frame(id=factor(rep(1:6,each=3)),
 group=factor(c('a','a','b','c','c','c')),
 x=runif(18,0,10),
 y=rnorm(18,0,1))

The following ggplot nearly works but I would prefer to not plot the
missing combinations, i.e. each row will be a different length.

ggplot(data,aes(x=x,y=y))+geom_point(aes(color=group))+facet_grid(group~id)

Is this possible using ggplot or will I need to craft something using grid?

Thanks for any ideas.
Tom
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Disclaimer<https://drupal.inbo.be/nl/disclaimer-mailberichten-van-het-inbo>

Disclaimer<https://drupal.inbo.be/nl/disclaimer-mailberichten-van-het-inbo>
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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. 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
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: R-help [mailto:r-help-boun...@r-project.org] Namens Molly Elliott
Verzonden: maandag 12 januari 2015 7:06
Aan: r-help@r-project.org
Onderwerp: [R] Suggestions for workaround for R Markdown problem with data() ?

R version: 3.1.2 (2014-10-31)
RStudio version: 0.98.1091
MacOS X Yosemite v. 10.10.1

When I run the following in the console, all is well:
data(IlluminaHumanMethylation450kanno.ilmn12.hg19)

Yet, when I compile in my .Rmd file, in RStudio (knit to PDF), I get the 
following error:
Error in file(file, "rt") : cannot open the connection
Calls:  ... withVisible -> eval -> eval -> read.delim -> read.table 
-> file Execution halted

From what I have read, this could be alleviated by pointing the the source file 
for data(IlluminaHumanMethylation450kanno.ilmn12.hg19) as opposed to 
LazyLoading with the data() function.  Yet, I’m not sure how to work around 
this. (This is my first R project ever) The 
data(IlluminaHumanMethylation450kanno.ilmn12.hg19) is just loading an 
annotation file from library(IlluminaHumanMethylation450kanno.ilmn12.hg19), and 
I’m not sure of the file type the data are stored under (.txt, .csv, etc).

Thanks in advance!

Molly

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Disclaimer
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium
+ 32 2 525 02 51
+ 32 54 43 61 85
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: R-help [mailto:r-help-boun...@r-project.org] Namens Xochitl CORMON
Verzonden: woensdag 28 januari 2015 15:09
Aan: Rlist; Rlist
Onderwerp: [R] Prediction of response after glm on whitened data

Hi all,

Here is a description of my case. I am sorry if my question is also statistic 
related but it is difficult to disentangle. I will however try to make it only 
R applied.

My response is a growth constant "k" and my descriptor is prey biomass "NP" and 
time series is of 21 years.

I applied a gaussiam GLM (or LM) to this question. After the regression I 
tested the residuals for autocorrelation using acf(). Because autocorrelation 
was significant I decided to whiten my data using
{car}dwt() in order to obtain rho (an estimation of my correlation) and then 
applying the following to my data in order to remove autocorrelation:
kw_i = k_i - rho * k_i-1
NPw_i = NPw_i - rho * NPw_i-1
(method from Jonathan Taylor,
http://statweb.stanford.edu/~jtaylo/courses/stats191/correlated_errors.html).

After that I fitted a model on this whitened data (kw_i ~ NPw_i), realised an 
F-test and obtained classical results such as deviance explained, pvalues and 
of course the intercept and coefficient of the last regression. However doing 
that and coming to prediction using
predict() I can only obtained predictions of deltaK (kw_i) in function of 
deltaNP (NPw_i) but I am actually interested in being able to predict k in 
function of NP...

Is there a solution to predict directly k and its associated variance using R 
without having to detail in the script all the mathematical process necessary 
to come back to something like k_i = mu + rho * k_i-1
+ beta(NPw_i - rho * NPw_i-1) + epsilon
with mu being the intercept, beta the regression coefficient and epsilon the 
error, ?

Thank you for your help,

Best,

Xochitl C.


--

<>< <>< <>< <><

Xochitl CORMON
+33 (0)3 21 99 56 84

Doctorante en écologie marine et science halieutique PhD student in marine 
ecology and fishery science

<>< <>< <>< <><

IFREMER
Centre Manche Mer du Nord
150 quai Gambetta
62200 Boulogne-sur-Mer

<>< <>< <>< <><

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Disclaimer

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens 
John McKown
Verzonden: woensdag 23 juli 2014 15:48
Aan: r-help
Onderwerp: [R] Trying to change a qplot() to a ggplot()+

I'm trying to change a qplot to a ggplot. The reason is because I want two 
plots of the same data. One a bar char, the other a line graph.
What I'm trying:

#MSU_graph_m1b <-
qplot(Int_Start,LicPrLsys4HMSU,data=cpprdald2_m1,geom="bar",stat="identity",color=System_alias);

MSU_graph_m1   <-
qqplot(cpprdald2_m1,aes(x=Int_Start,y=LicPrLsys4HSMU,colour=System_alias));

MSU_graph_m1b  <- MSU_graph_m1+geom_bar();

#MSU_graph_m1l <- qplot(Int_Start,LicPrLsys4HMSU,data=cpprdald2_m1,geom="line");

MSU_graph_m1l  <- MSU_graph_m1+geom_line();

The commented lines are what works. What fails is the first ggplit() like:

> MSU_graph_m1   <- 
> qqplot(cpprdald2_m1,aes(x=Int_Start,y=LicPrLsys4HSMU,colour=System_alias));
Error in as.matrix.data.frame(x) :
  dims [product 9912] do not match the length of object [9923]
>

cpprdald2_m1 is:
> str(cpprdald2_m1)
'data.frame':   168 obs. of  60 variables:

and Int_Start and LicPrLsys4HSMU are variables in cpprdald2_m1.
Int_Start is a POSIXlt. LicPrLsys4HSMU is a number. I have also tried with 
x=as.character(Int_Start) in the aes().

I am using the book "R GRAPHICS COOKBOOK" as my source of examples. I am 
obviously oblivious to something.

--
There is nothing more pleasant than traveling and meeting new people!
Genghis Khan

Maranatha! <><
John McKown

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
* * * * * * * * * * * * * D I S C L A I M E R * * * * * * * * * * * * *
Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en 
binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is 
door een geldig ondertekend document.
The views expressed in this message and any annex are purely those of the 
writer and may not be regarded as stating an official position of INBO, as long 
as the message is not confirmed by a duly signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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.country)]),
  Year = 2000:2010
)
price$Price <- rnorm(nrow(price), mean = average.price[price$Country], sd = 30)
#number and sum of all prices of the product over all countries and years
total.product <- aggregate(
  cbind(Price, N = 1) ~ Product,
  data = price,
  FUN = sum
)
#number and sum of all prices of the product per country over all years
total.product.country <- aggregate(
  cbind(Pricec = Price, Nc = 1) ~ Product + Country,
  data = price,
  FUN = sum
)
#merge both tables
combined.price <- merge(total.product, total.product.country)
with(combined.price, Price / N) #average price
with(combined.price, Pricec / Nc) #average price per country
with(combined.price, (Price - Pricec)/ (N - Nc)) #average price in the other 
countries



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
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens 
PIKAL Petr
Verzonden: vrijdag 1 augustus 2014 15:18
Aan: Lingyi Ma
CC: r-help@r-project.org
Onderwerp: Re: [R] How to avoid the three loops in R?

Hi

I do not see any solution without loops but maybe others find it.

I think that you can do it in one loop. Best structure for loop will be list.

In each cycle you will compute matrix with diagonal NA

mat<-matrix(1,nrow=number of items, ncol=number of items)
diag(mat) <- NA

apply(price chunk * mat, 2, mean, na.rm=T)


So when I named your example as temp I get

fac <- interaction(factor(temp$Product), factor(temp$Year_Month), drop=T) lll 
<- split(temp, fac) for( i in 1:length(lll)) {  mat <- matrix(1,  
nrow=nrow(lll[[i]]), ncol= nrow(lll[[i]]))
 diag(mat) <- NA
 lll[[i]]$others <- apply(mat*lll[[i]][,3], 2, mean, na.rm=T)  }

> lll
$`1.201204`
  Country Product Price Year_Month others
1  AE   120 201204 24
2  DE   120 201204 24
3  CN   128 201204 20

$`2.201204`
  Country Product Price Year_Month others
4  AE   228 201204 25
5  DE   228 201204 25
6  CN   222 201204 28

$`3.201204`
  Country Product Price Year_Month others
7  AE   328 201204 28
8  CN   328 201204 28

$`1.201205`
   Country Product Price Year_Month others
9   AE   120 201205 24
10  DE   120 201205 24
11  CN   128 201205 20

$`2.201205`
   Country Product Price Year_Month others
12  AE   228 201205 28
13  DE   228 201205 28

I did not check speed but it shall be OK.

Regards
Petr

> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Lingyi Ma
> Sent: Friday, August 01, 2014 1:42 PM
> To: r-help@r-project.org
> Subject: [R] How to avoid the three loops in R?
>
> I have the following data set:
>
>   Country  Product   Price  Year_Month
>  AE 1   20201204
>  DE 1   20201204
>  CN 1   28201204
>  AE 2   28201204
>  DE 2   28201204
>  CN 2   22201204
>  AE 3   28201204
>  CN 3   28201204
>  AE 1   20201205
>  DE 1   20201205
>  CN 1   28201205
>  AE 2   28201205
>  DE 2   28201205
>
> I want to create the one more column which is "The average price of
> the product in other areas".
> in other word, for each month, for each product, I calculate the
> average of such product in the other area.
>
> I want sth like:
>
>   Country  Product   Price  Year_MonthPrice_average_In_Other_area
>  AE 1   20201204  14
>  AE 2   28201204  25
>
> Please avoid the three for loop, I have tried and it never end. I have
>  1070427 rows.  Is there better way to speed up my program?
>

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 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
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens 
Christopher Battles
Verzonden: donderdag 25 september 2014 20:30
Aan: r-help@r-project.org
Onderwerp: [R] Performance (speed) of ggplot

Hello list,

I have been working on learning ggplot for its extraordinary flexibility 
compared to base plotting and have been developing a function to create a 
"Minitab-like" process capability chart.

*sigh* some of the people I interface with can only understand the data when it 
is presented in Minitab format

The function creates a ggplot container to hold 10 ggplot items which are the 
main process capability chart, a Q-Q plot, and the text boxes with all the 
capabilities data.  When I run the function, the elapsed time is on the order 
of 3 seconds, the gross majority of which is user time.  sys time is very 
small.  A bit of hacking shows that the calls to

gt1 <- ggplot_gtable(ggplot_build(p)),

etc., each take on the order of 1/3 of a second. These times are on a 3.2GHz 
Xeon workstation.  I'd like to see the entire function complete in less than a 
second.  My questions are: 1) Am I misusing ggplot, hence the performance hit? 
2) Is there any way to increase the speed of this portion of the code? 3) Am I 
simply asking ggplot to crunch so much that it is inevitable that it will take 
a while to process?

To that end, the function, vectis.cap(), can be downloaded from 
http://pastebin.com/05s5RKYw .  It runs to 962 lines of code, so I won't paste 
it here.  The offending ggplot_gtable calls are at lines 909 - 918.

Usage:
vectis.cap(chickwts$weight, target = 300, USL = 400, LSL = 100)

Thank you,

Christopher Battles

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
* * * * * * * * * * * * * D I S C L A I M E R * * * * * * * * * * * * *
Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en 
binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is 
door een geldig ondertekend document.
The views expressed in this message and any annex are purely those of the 
writer and may not be regarded as stating an official position of INBO, as long 
as the message is not confirmed by a duly signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium
+ 32 2 525 02 51
+ 32 54 43 61 85
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens 
Barry King
Verzonden: maandag 29 september 2014 11:59
Aan: r-help@r-project.org
Onderwerp: [R] How to get rid of my for loop

# Here are sample data, sample vectors, and a for loop # that I am using now. I 
wish to get rid of the for loop # and use functions and one of the apply 
functions to # perform the work without needing a many iteration for loop.
A_01 <- 1:5
A_02 <- 6:10
A_03 <- 11:15
A_04 <- 16:20

B_01 <- 101:105
B_02 <- 106:110
B_03 <- 111:115
B_04 <- 116:120

# I am showing just two pairs, A_x with A_array and B_x with B_array.
# In actuality there are about a dozen such pairings.
A_array <- array(NA, dim=5)
B_array <- array(NA, dim=5)

VFD_ID <- c(3, 2, NA, 1, 3)
nobs <- length(VFD_ID)

# This for loop works fine but is not appropriate for # a large number of 
observations in VFD_ID.
for (i in 1:nobs){
  if (is.na(VFD_ID[i])){
A_array[i]<- 0
B_array[i]<- 0
  } else if (VFD_ID[i] == 1){
A_array[i]<-A_01[i]
B_array[i]<-B_01[i]
  } else if (VFD_ID[i] == 2){
A_array[i]<-A_02[i]
B_array[i]<-B_02[i]
  } else if (VFD_ID[i] == 3){
A_array[i]<-A_03[i]
B_array[i]<-B_03[i]
  } else if (VFD_ID[i] == 4){
A_array[i]<-A_04[i]
B_array[i]<-B_04[i]
  }
}

# This does NOT work. It returns the entire vector, # not just the 
corresponding element in VFD_ID.
# (Note: It seems like a switch function would work here # but I was unable to 
get it to work correctly.) A_array_fnc <- function(x){
  if (is.na(x)) return (0) else
if (x == 1) return (A_01) else
  if (x == 2) return (A_02) else
if (x == 3) return (A_03) else
  if (x == 4) return (A_04)
}

B_array_fnc <- function(x){
  if (is.na(x)) return (0) else
if (x == 1) return (B_01) else
  if (x == 2) return (B_02) else
if (x == 3) return (B_03) else
  if (x == 4) return (B_04)
}

A_array <- sapply(VFD_ID,A_array_fnc)
B_array <- sapply(VFD_ID,B_array_fnc)

# Is there a way to write the functions correctly so that # the return value 
for, say A_array[4] is A_03[4] if VFD_ID == 3?
# Any assistance is greatly appreciated.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
* * * * * * * * * * * * * D I S C L A I M E R * * * * * * * * * * * * *
Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en 
binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is 
door een geldig ondertekend document.
The views expressed in this message and any annex are purely those of the 
writer and may not be regarded as stating an official position of INBO, as long 
as the message is not confirmed by a duly signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium
+ 32 2 525 02 51
+ 32 54 43 61 85
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens 
jpm miao
Verzonden: dinsdag 21 oktober 2014 10:29
Aan: r-help
Onderwerp: [R] Dealing with NAs in lm or gmm

Hi,

   My question is about NAs in the function "gmm", but I believe that the same 
issues occur in the case of "lm".

   I try to estimate a model by "gmm" function (GMM, generalized method of 
moments). Each of the  variables has 94 rows, but the resulting fitted model 
has only 89 rows. Then the function removes the rows with NAs.  I want to add a 
94*1 vector, ONI, to the resulting fitted values; I want to find the fitted 
value with NAs kept. How can I do it? na.action?

   Code:

   > gmm8<-gmm(y~RDR1+xx, xiv)
Warning message:
In getDat(object$g, object$x) :
  There are missing values. Associated observations have been removed

> ONI.gmm8<-fitted(gmm8)+0.85*ONI
Error in NextMethod(.Generic) :
  dims [product 89] do not match the length of object [94] In addition: Warning 
message:
In `+.default`(fitted(gmm8), 0.85 * ONI) :
  longer object length is not a multiple of shorter object length

Help on na.action:
na.action
a function which indicates what should happen when the data contain NAs.
The default is set by the na.action setting of options, and is na.fail if that 
is unset. The ‘factory-fresh’ default is na.omit. Another possible value is 
NULL, no action. Value na.exclude can be useful.

Thanks!

Miao

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
* * * * * * * * * * * * * D I S C L A I M E R * * * * * * * * * * * * *
Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en 
binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is 
door een geldig ondertekend document.
The views expressed in this message and any annex are purely those of the 
writer and may not be regarded as stating an official position of INBO, as long 
as the message is not confirmed by a duly signed document.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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

2014-10-21 Thread ONKELINX, Thierry
It looks like gmm is not handling na.exclude correctly. You should contact the 
package maintainer.

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
thierry.onkel...@inbo.be<mailto:thierry.onkel...@inbo.be>
www.inbo.be<http://www.inbo.be/>

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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

Van: jpm 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 with NAs (In my case, 94*1 matrix)?

> gmm8<-gmm(y~RDR1+xx, xiv, na.action = na.exclude)
Warning message:
In getDat(object$g, object$x) :
  There are missing values. Associated observations have been removed
> nrow(fitted(gmm8))
[1] 89
> nrow(xx)
NULL
> nrow(as.matrix(xx))
[1] 94
> nrow(RDR1)
[1] 94
> nrow(y)
[1] 94

2014-10-21 17:27 GMT+08:00 ONKELINX, Thierry 
mailto:thierry.onkel...@inbo.be>>:
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 Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium
+ 32 2 525 02 51
+ 32 54 43 61 85
thierry.onkel...@inbo.be<mailto:thierry.onkel...@inbo.be>
www.inbo.be<http://www.inbo.be>

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org<mailto:r-help-boun...@r-project.org> 
[mailto:r-help-boun...@r-project.org<mailto:r-help-boun...@r-project.org>] 
Namens jpm miao
Verzonden: dinsdag 21 oktober 2014 10:29
Aan: r-help
Onderwerp: [R] Dealing with NAs in lm or gmm

Hi,

   My question is about NAs in the function "gmm", but I believe that the same 
issues occur in the case of "lm".

   I try to estimate a model by "gmm" function (GMM, generalized method of 
moments). Each of the  variables has 94 rows, but the resulting fitted model 
has only 89 rows. Then the function removes the rows with NAs.  I want to add a 
94*1 vector, ONI, to the resulting fitted values; I want to find the fitted 
value with NAs kept. How can I do it? na.action?

   Code:

   > gmm8<-gmm(y~RDR1+xx, xiv)
Warning message:
In getDat(object$g, object$x) :
  There are missing values. Associated observations have been removed

> ONI.gmm8<-fitted(gmm8)+0.85*ONI
Error in NextMethod(.Generic) :
  dims [product 89] do not match the length of object [94] In addition: Warning 
message:
In `+.default`(fitted(gmm8), 0.85 * ONI) :
  longer object length is not a multiple of shorter object length

Help on na.action:
na.action
a function which indicates what should happen when the data contain NAs.
The default is set by the na.action setting of options, and is na.fail if that 
is unset. The ‘factory-fresh’ default is na.omit. Another possible value is 
NULL, no action. Value na.exclude can be useful.

Thanks!

Miao
[[alternative HTML version deleted]]

__
R-help@r-project.org<mailto:R-help@r-project.org> mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
* * * * * * * * * * * * * D I S C L A I M E R * * * * * * * * * * * * *
Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en 
binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is 
door een geldig ondertekend document.
The views expressed in this message and any annex are purely those of the 
writer and may not be regarded as stating an official position of INBO, as long 
as the message is not confirmed by a duly signed document.

* * * * * * * * * * * * * D I S C L A I M 

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 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
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens 
Guido Biele
Verzonden: maandag 27 oktober 2014 9:20
Aan: Michael Sumner
CC: r-help@r-project.org
Onderwerp: Re: [R] rgdal: Convert ESRI ArcGis geo database (gdb directory) to 
geojson, or shapefile map

Thanks,
Now I found the driver in the current rgdal version!

Unfortunately I still can't open the database, even though the OpenfileGDB 
driver is used.
When I list the layers
and then try to load one of the layers, I get the error message that no 
features are found:

ogrListLayers("Stoy.gdb")
[1] "veg_storbyomrader" "veg_traffikert_veg"
 "flyplass_store_flyplasser" "bane_storbyomrader"
[5] "bane_traffikert_bane"
attr(,"driver")
[1] "OpenFileGDB"
attr(,"nlayers")
[1] 5
> m = readOGR("Stoy.gdb",layer = "veg_storbyomrader")
Error in readOGR("Stoy.gdb", layer = "veg_storbyomrader") :
  no features found
In addition: Warning message:
In ogrFIDs(dsn = dsn, layer = layer) : no features found


Is this likely due to the database, or could this be a problem with the driver?

In case that helps, here is the link to the map layer I want to extrac (the 
link is to a web page, but I have the data base file).
http://www.miljostatus.no/kart/?lang=no&extent=152517|6532562|210570|6557188&layers=147:46;20:100;138:100;&basemap=KART&opacity=71&saturation=90

Best - Guido


On Sun, Oct 26, 2014 at 7:21 AM, Michael Sumner  wrote:

> This driver is present in the Windows binary on CRAN (at least it was
> in July):
> https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20140710/5dda6bc4
> /attachment.pl
>
> I'm not sure about on Linux, I thought it was there but I may have
> inadvertently switched to an older GDAL on some systems. I can try
> this out on a test VM though, I'm keen to have rgal-recipes for
> installing on various systems.
>
> Let me know if:
> 1) you want Windows or Linux
> 2) you want help building / installing on Linux (Ubuntu)
>
> (Compiling the Windows binary is hard and mysterious, but I'd love to
> be able to do that too. I can do all of it except the final .zip
> package bundle which I don't understand yet)
>
> Cheers, Mike.
>
> On Fri, Oct 24, 2014 at 9:06 PM, Guido Biele
>  wrote:
> > Hello,
> >
> > I have an ESRI  ArGis geo database directory which I would like to
> convert
> > to geojson or a shape file (or anything else that I can read into R).
> >
> > Unfortunately that does not work out of the box with rgdal, because
> > it
> does
> > not come with the fileGDB or openfileGDB driver.
> > I could successfully install gdal and the fileGDB driver/extension,
> > but
> it
> > seems that i can use gdal only to convert the gdb file to a SQL database.
> >
> > So before I start to learn about SQL, I thought I ask if anybody can
> point
> > me to a tutorial or similar that explains how to convert the
> > contents of
> a
> > GDB folder to a R-readable format.
> >
> > I also wondered if it would be possible to let rgdal know that it
> > could access the required drivers because I installed them manually.
> > I would appreciate any hint about this too!
> >
> > Thanks in advance!
> > Best Guido
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
>
>
> --
> Michael Sumner
> Software and Database Engineer
> Australian Antarctic Division
> Hobart, Australia
> e-mail: mdsum...@gmail.com
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
* * * * * * * * * * * * *

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
Belgium
+ 32 2 525 02 51
+ 32 54 43 61 85
thierry.onkel...@inbo.be
www.inbo.be
To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ 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


Van: r-help-boun...@r-project.org [r-help-boun...@r-project.org] namens 岳�S 
[yue...@139.com]
Verzonden: maandag 10 november 2014 8:55
Aan: r-help@r-project.org
Onderwerp: [R] the bug of function base::order

Hi, all:

  I find a bug of the function base::order. For example,

y = rep(9, 9:1); rbind(y,order(y, decreasing=FALSE));

the result is:

  [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]

y998765432 1

1098765431 2

The last two numbers have the wrong orders!



Is there any one met the same situation?




[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
* * * * * * * * * * * * * D I S C L A I M E R * * * * * * * * * * * * *
Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en 
binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is 
door een geldig ondertekend document.
The views expressed in this message and any annex are purely those of the 
writer and may not be regarded as stating an official position of INBO, as long 
as the message is not confirmed by a duly signed document.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium
+ 32 2 525 02 51
+ 32 54 43 61 85
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: R-help [mailto:r-help-boun...@r-project.org] Namens PIKAL Petr
Verzonden: woensdag 26 november 2014 14:40
Aan: R help
Onderwerp: [R] ggplot facet and subsetting

Dear all

I encountered strange behaviour of ggplot with combination of facet and 
subsetting. I use for creating plots sometimes a for cycle, something like this

for (i in n:m) { p<-ggplot(data, aes(x=x, y=data[,i], colour=f))), ...}

However I found strange result with this combination

This is OK but only in BW
p<-ggplot(vec.c, aes(x=fi, y=nad1mi))
p+geom_point(size=5)+geom_line()+facet_grid(.~stroj)

this is OK with colour
p<-ggplot(vec.c, aes(x=fi, y=nad1mi, colour=as.factor(cas)))
p+geom_point(size=5)+geom_line()+facet_grid(.~stroj)

Here results in facets are mismatched
p<-ggplot(vec.c, aes(x=fi, y=vec.c[,2], colour=as.factor(cas)))
p+geom_point(size=5)+geom_line()+facet_grid(.~stroj)

and this is mismatched too
p<-ggplot(vec.c, aes(x=fi, y=vec.c[,2]))
p+geom_point(size=5)+geom_line()+facet_grid(.~stroj)

Doeas anybody know what I am doing wrong?

> dput(vec.c)
structure(list(cas = c(1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 0L, 1L, 2L, 0L, 
1L, 2L, 0L, 1L, 2L, 0L, 1L, 2L, 0L, 1L, 2L, 0L, 1L, 2L, 0L, 1L, 2L, 1L, 2L, 1L, 
2L, 1L, 2L, 1L, 2L, 1L, 2L),
nad1mi = c(3, 2.7, 0.3, 0.5, 1.9, 5.3, 0.4, 3, 5.4, 0.7,
20.6, 16.7, 16.6, 20.7, 16.1, 15.2, 20.5, 16.4, 14.8, 24.6,
19.3, 15.2, 26.9, 21.3, 20.6, 22.6, 16.3, 15.7, 19.3, 16.5,
15.5, 3.6, 3.4, 5.9, 4.6, 5.4, 4.2, 5.3, 5.6, 5.1, 5), stroj = 
structure(c(3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("mastersizer",
"odstredivka", "zetasizer"), class = "factor"), fi = c(341L,
341L, 285L, 285L, 401L, 401L, 231L, 231L, 190L, 190L, 341L,
341L, 341L, 285L, 285L, 285L, 401L, 401L, 401L, 231L, 231L,
231L, 190L, 190L, 190L, 167L, 167L, 167L, 161L, 161L, 161L,
341L, 341L, 285L, 285L, 401L, 401L, 231L, 231L, 190L, 190L
)), .Names = c("cas", "nad1mi", "stroj", "fi"), class = "data.frame", 
row.names = c(1L, 2L, 6L, 7L, 11L, 12L, 16L, 17L, 21L, 22L, 26L, 27L, 28L, 32L, 
33L, 34L, 38L, 39L, 40L, 44L, 45L, 46L, 50L, 51L, 52L, 56L, 57L, 58L, 62L, 63L, 
64L, 68L, 69L, 73L, 74L, 78L, 79L, 83L, 84L, 88L,
89L))
>

Regards
Petr

> sessionInfo(package = NULL)
R Under development (unstable) (2014-07-16 r66175)
Platform: i386-w64-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=Czech_Czech Republic.1250  LC_CTYPE=Czech_Czech Republic.1250 
[3] LC_MONETARY=Czech_Czech Republic.1250 LC_NUMERIC=C [5] LC_TIME=Czech_Czech 
Republic.1250

attached base packages:
[1] stats datasets  utils grDevices graphics  methods   base

other attached packages:
[1] ggplot2_1.0.0   lattice_0.20-29 fun_1.0

loaded via a namespace (and not attached):
 [1] colorspace_1.2-4 digest_0.6.4 grid_3.2.0   gtable_0.1.2
 [5] labeling_0.2 MASS_7.3-33  munsell_0.4.2plyr_1.8.1
 [9] proto_0.3-10 Rcpp_0.11.2  reshape2_1.4 scales_0.2.4
[13] stringr_0.6.2tools_3.2.0
>


Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny 
pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a 
to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce 
s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena tep

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 kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
[EMAIL PROTECTED] 
www.inbo.be 

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens ACroske
Verzonden: vrijdag 18 juli 2008 20:24
Aan: r-help@r-project.org
Onderwerp: [R] "Spreading risk" in a matrix


I have a binary matrix that represents a map of invasive species risk (1
=
infested; 0 = uninfested). It started as a matrix of probabilities
(developed in ArcMap) that I converted to binary with this R code:
binary.matrix<-matrix(rbinom(length(prob.matrix),prob=prob.matrix,size=1
),nrow=nrow(prob.matrix))

Now, I would like to "spread" the risk for year 2 of the invasion. I'd
like
to do this by location, so, for every cell that is currently a 1, next
year
it's immediate neighbors (above, below, to the right and left) would
also
become ones. Here is a function I came up with to attempt this (clearly,
my
function writing is rough, to say the least):

matrix.function<-function(N){
  
binary.matrix<-matrix(rbinom(length(prob.matrix),prob=prob.matrix,size=1
),nrow=nrow(prob.matrix))
   res<-numeric(N)
   for (i in 1:N){
   res[i]<-binary.matrix
if (res[i]==1){
res[,i+1]=1
res[,i-1]=1
}
   }
}

When I run this code, I get many messages saying "In
res[i]<-binary.matrix :
number of items to replace is not a multiple of replacement length"

I know that if I actually got this to work, it would be a string of
numbers
(because of the "numeric"), but I'm just working with my limited
function-writing knowledge, and I assumed it would be possible to
convert
the results to a matrix later on.

I'm aware that this function is probably a disaster, but that's why I'm
here!
-- 
View this message in context:
http://www.nabble.com/%22Spreading-risk%22-in-a-matrix-tp18535227p185352
27.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
[EMAIL PROTECTED] 
www.inbo.be 

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens ACroske
Verzonden: vrijdag 18 juli 2008 22:22
Aan: r-help@r-project.org
Onderwerp: Re: [R] "Spreading risk" in a matrix


How do I use the buffer function since I have more than the two columns
it
calls for? (I have 46!)


-- 
View this message in context:
http://www.nabble.com/%22Spreading-risk%22-in-a-matrix-tp18535227p185370
82.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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, 2)
x = rmnorm(20, c(0,0), Sigma)
xx = x[order(x[,1]),]
y = xx[,1]
z = xx[,2]
ggplot(data.frame(y,z), aes(y, z)) + geom_point(colour = "blue", size =
6) + scale_x_continuous("x") + opts(title = "x-y plot") 

HTH,

Thierry



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
[EMAIL PROTECTED] 
www.inbo.be 

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens Megh Dal
Verzonden: woensdag 23 juli 2008 4:31
Aan: hadley wickham
CC: [EMAIL PROTECTED]
Onderwerp: Re: [R] scatter plot using ggplot

Thanks for this mail. However I am getting following error on that :

Error in inherits(formula, "formula") : could not find function "aes"

And regarding my 3rd query I actually wanted to get "bigger circles" as
points, not intended to increase plot size.

Regards,


--- On Tue, 7/22/08, hadley wickham <[EMAIL PROTECTED]> wrote:

> From: hadley wickham <[EMAIL PROTECTED]>
> Subject: Re: [R] scatter plot using ggplot
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Date: Tuesday, July 22, 2008, 10:00 PM
> On Tue, Jul 22, 2008 at 3:42 AM, Megh Dal
> <[EMAIL PROTECTED]> wrote:
> > I used ggplot to create a scatter plot :
> >
> > library(ggplot)
> > library(mnormt)
> > Sigma = matrix(c(1, 0.6, 0.6, 1), 2, 2)
> > x = rmnorm(20, c(0,0), Sigma)
> > xx = x[order(x[,1]),]
> > y = xx[,1]
> > z = xx[,2]
> > qplot(z, y, type="point", main="x-y
> plot", xlab="x", col="blue")
> >
> > However I want following:
> >
> > 1. Plot color must be Blue (where it is displaying as
> red)
> > 2. There should not be any color platted
> 
> You can't currently do this with qplot (but will be
> able to in the
> next version).  Use ggplot() instead:
> 
> ggplot(data.frame(y,z), aes(y, z)) +
> geom_point(colour = "blue") +
> scale_x_continuous("x") +
> opts(title = "x-y plot")
> 
> > 3. Plot size must be larger than what it is displacing
> 
> Make the window bigger?
> 
> Hadley
> 
> -- 
> http://had.co.nz/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
[EMAIL PROTECTED] 
www.inbo.be 

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens Alessandro
Verzonden: dinsdag 22 juli 2008 2:19
Aan: r-help@r-project.org
Onderwerp: [R] experimental semivariogram

Hey all,

I am a PhD student and I have a points dataset with X, Y and Z (height)
to
create a Kriging Map. I am finding the code in R to create experimental
semivariogram, but I am a brand new in R and I did't find the code. 

Thank you 

Alessandro

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
[EMAIL PROTECTED] 
www.inbo.be 

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens Sascha Bellaire
Verzonden: zondag 20 juli 2008 18:13
Aan: r-help@r-project.org
Onderwerp: [R] Indicator Kriging?

Hello All!
I like to do some indicator kriging with R. 
So far I used geoR for simple and ordinary kriging.
Does anybody know which package I should use?
Thanks for your help!
Sascha!


-- 

Jetzt dabei sein:
http://www.shortview.de/[EMAIL PROTECTED]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
[EMAIL PROTECTED] 
www.inbo.be 

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens Shubha Vishwanath Karanth
Verzonden: woensdag 23 juli 2008 14:55
Aan: [EMAIL PROTECTED]
Onderwerp: [R] Simple... but...

Hi R,



If 

x=c(1,3,5)

y=c(2,4,6)



I need a vector which is c(1,2,3,4,5,6) from x and y.



How do I do it? I mean the best way



Thanks, Shubha



This e-mail may contain confidential and/or privileged
i...{{dropped:13}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
[EMAIL PROTECTED] 
www.inbo.be 

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens Jinsong Zhao
Verzonden: zondag 27 juli 2008 9:39
Aan: r-help@r-project.org
Onderwerp: [R] A easy way to write formula

Hi

I have a data frame, including x1, x2, x3, and y. I use lm() to fit
second-order linear model, like the following:

ft <- lm(y ~ x1 + x2 + x3 + I(x1 * x1) + I(x1 * x2) + I(x1 * x3) + I(x2
* x2) + I(x2 * x3) + I(x3 * x3), mydata)

if the independent variable number is large, the formula will be very
long. Is there a easy way to write formula like the above one? I have
read the R introduction, however, I don't find a easy way.

Any hints will be appreciated. Thanks,

Jinsong

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
[EMAIL PROTECTED] 
www.inbo.be 

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens [EMAIL PROTECTED]
Verzonden: zondag 27 juli 2008 9:34
Aan: r-help@r-project.org
Onderwerp: [R] Retain plot?

Every time I issue a plot command it removes the current plot and
replaces it with the plot that I just issued. I would like to keep both
plots. I looked in the documentation and found plot.new but was unable
to get it to work. I think I want that functionality. Any suggestions?

Thank you.

Kevin

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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,]1111
 [2,]11   NA1
 [3,]   NA1   NA   NA
 [4,]11   NA1
 [5,]111   NA
 [6,]111   NA
 [7,]1111
 [8,]111   NA
 [9,]   NA111
[10,]1111
> 
> dat[is.na(dat)] <- 0
> dat
  [,1] [,2] [,3] [,4]
 [1,]1111
 [2,]1101
 [3,]0100
 [4,]1101
 [5,]1110
 [6,]1110
 [7,]1111
 [8,]1110
 [9,]0111
[10,]1111
>

HTH,

Thierry


ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
[EMAIL PROTECTED] 
www.inbo.be 

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens Denise Xifara
Verzonden: maandag 28 juli 2008 15:15
Aan: r-help@r-project.org
Onderwerp: [R] speeding up loop and dealing wtih memory problems

 Dear All and Mark,

Given a dataset that I have called dat, I was hoping to speed up the
following loop:

for(i in 1:835353){
for(j in 1:86){
if  (is.na(dat[i,j])==TRUE){dat[i,j]<-0 }}}
Actually I am also having a memory problem.  I get the following:

Error: cannot allocate vector of size 3.2 Mb
In addition: Warning messages:
1: In dat[i, j] <- 0 :
  Reached total allocation of 1535Mb: see help(memory.size)
2: In dat[i, j] <- 0 :
  Reached total allocation of 1535Mb: see help(memory.size)
3: In dat[i, j] <- 0 :
  Reached total allocation of 1535Mb: see help(memory.size)
4: In dat[i, j] <- 0 :
  Reached total allocation of 1535Mb: see help(memory.size)

If I try and apply the loop just to a particular column, rather than the
whole dataset, so that I dont have the memory problem, ie

for(i in 1:835353){
if  (is.na(dat[i,4])==TRUE){dat[i,4]<-0 }}

it takes ridiculously long to process, so I was hoping that there would
be a
quicker way to do this.

Thank you all very much for the help,
Denise

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 <- expand.grid(i = 40:60, j = 0:20)
res <- fn(datagrid$i, datagrid$j)

#An other option is to use the functions for the apply-family

fn <- function (x) {
ifelse(x>46 & x<52, 1, 0)
}
res <- sapply(40:60, fn)

fn <- function (x,y) {
ifelse(x>46 & x<52 & y<12, 1, 0)
}
datagrid <- expand.grid(i = 40:60, j = 0:20)
res <- apply(datagrid, 1, function(z){
fn(z["i"], z["j"])
}) 

#or you can use a nested loop

res <-NULL 
for (i in 40:60){
for(j in 0:20){
res <-c(res,fn(i,j))
}
}

HTH,

Thierry



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
[EMAIL PROTECTED] 
www.inbo.be 

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens Oehler, Friderike (AGPP)
Verzonden: dinsdag 29 juli 2008 13:56
Aan: Oehler, Friderike (AGPP); r-help@r-project.org
Onderwerp: [R] 'for' loop, two variables

Dear Rusers,
I am still an unexperienced builder of functions and loops, so my
question is
very basic: Is it possible to introduce a second variable (j) into my
loop.
To examplify:

# This works fine:
fn <- function (x) {if (x>46 & x<52) 1 else 0}
res <-NULL 
for (i in 40:60) res <-c(res,fn(i))
res

# But here, there is an error in the "for" expression:
fn <- function (x,y) {if (x>46 & x<52 & y<12) 1 else 0 }
res <-NULL 
for (i in 40:60 & j in 0:20) res <-c(res,fn(i,j)) 
# How do I have to write the expression "i in 40:60 & j in 0:20"? Or is
there
no way to do that, i.e. I have to do the calculation in two steps?

Thanks in advance!
Friderike

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
[EMAIL PROTECTED] 
www.inbo.be 

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens Jim Lemon
Verzonden: donderdag 31 juli 2008 13:19
Aan: MarinaTarantini
CC: r-help@r-project.org
Onderwerp: Re: [R] combinations with replications

On Thu, 2008-07-31 at 02:29 -0700, MarinaTarantini wrote:
> Dear all,
> Is there a way to compute and list all combinations with replication
of two
> elements in sets of 8 elemnts?
> For example, I've two elements, 0 and 1, and I would to get all
possible
> combinations with replication such as, for example, ,
0001,
> 0010, and so on. They are 2^8 and it's very hard to list handly!!

Hi Marina,
Here's a Q&D solution for the specific problem that could easily be
extended to different numbers of elements (although it would blow out
very quickly)..

zero8<-rep(0,8)
oneto8<-1:8
cat(zero8,"\n")
for(i in 1:7) {
 combi<-combn(oneto8,i)
 combcol<-dim(combi)[2]
 for(comb in 1:combcol) {
  nextcomb<-zero8
  nextcomb[combi[,comb]]<-1
  cat(nextcomb,"\n")
 }
}
cat(rep(1,8),"\n")

Jim

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 don't forget to provide commented, minimal, self-contained, reproducible 
code as the posting guide requests. In this case it was not reproducible 
because we don't have the dataset. Futhermore R-sig-geo would be a more a 
propriate mailing list for this kind of questions.

HTH,

Thierry



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and 
Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology 
and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
[EMAIL PROTECTED] 
www.inbo.be 

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Alessandro
Verzonden: donderdag 31 juli 2008 23:23
Aan: r-help@r-project.org
Onderwerp: [R] anisotropy in vgm model. HELP!!!

Hi All,



I have this problem. I don't understand  the right code in R when I have an
anisotropy in the semivariogram model



plot(variogram(Z~1, subground, cutoff=1800, width=80, alpha=c(45, 135, 90,
135)))



I have a good model in 90° and eventually in 90° and 45°



v = variogram(Z~1, subground, cutoff=1800, width=80, alpha=c(0, 45, 90,
135))

v.fit = fit.variogram(v, vgm(model="Lin", anis=c(?)))





Thank you



Alessandro


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
[EMAIL PROTECTED] 
www.inbo.be 

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens Gundala Viswanath
Verzonden: vrijdag 1 augustus 2008 10:41
Aan: [EMAIL PROTECTED]
Onderwerp: [R] Function to check the presence of an Item in an array

Hi all,

Is there a way to do it?
For example:

> x
"foo" "bar" "bar2" "qux"

is there a function to return TRUE/FALSE
given a test variable

> func("foo")
TRUE

> func("GUNDALA")
FALSE

Is there such "func" in R?

- Gundala Viswanath
Jakarta - Indonesia

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and 
Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology 
and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
[EMAIL PROTECTED] 
www.inbo.be 

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens David Hajage
Verzonden: vrijdag 1 augustus 2008 15:21
Aan: Bertolt Meyer
CC: r-help@r-project.org
Onderwerp: Re: [R] Newbie question: How to use tapply() on several 
vectorssimultaneously

something like that should work :

aggregate(test, list(test[,1]), mean)


2008/8/1 Bertolt Meyer <[EMAIL PROTECTED]>

> Dear R users,
>
> I have a newbie-question that I couldn't resolve after reading through
> several pieces of documentation and searching the archive.
>
> I have a data.frame containing experimental data from a group experiment in
> psychology. Each line represents a single participant, but participants were
> assigned to groups of three or four persons. One variable indicates each
> participants' group number (groupID). For a large number of variables, I
> would like to obtain the mean group value. I figured I use tapply() in the
> fashion of tapply(variable, groupID, mean), but that would be a tiresome
> task for my 150 variables. I am thus looking for a way to obtain a
> data.frame that contains one row for each group with the group-mean
> variables as columns.
>
> Example:
>
> > test <- as.data.frame(cbind(c(rep(1,5),rep(2,5)), rnorm(10), rnorm(10)))
> > names(test)[1] <- "groupID"
> > test
>
>   groupID  V2  V3
> 11 -0.82990860 -0.61778919
> 21 -0.01379452  0.64609053
> 31 -2.64990839 -1.00570627
> 41 -0.07903878 -0.70864441
> 51  0.61483071 -1.32039565
> 62 -0.18913937  1.38490710
> 72 -0.60017953  0.15893421
> 82 -0.99901931  0.05963436
> 92 -1.46759515  0.35040283
> 10   2 -0.44650422 -0.08713162
>
> > tapply(test$V2, test$groupID, mean)
> 1  2
> -0.5915639 -0.7404875
>
> > tapply(test$V3, test$groupID, mean)
> 1  2
> -0.6012890  0.3733494
>
> I am now looking for something that gives me
>
>  groupID V2V3
> 1   1 -0.5915639-0.6012890
> 2   2 -0.74048750.3733494
>
> Any ideas?
>
> Thank you very much,
> Bertolt
>
> --
> Bertolt Meyer
> Oberassistent
> Sozialpsychologie, Psychologisches Institut der Universität Zürich
> Binzmühlestr. 14, Box 15
> CH-8050 Zürich
>
> [EMAIL PROTECTED]
> tel:   +41446357282
> fax:   +41446357279
> mob:   +41788966111
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
[EMAIL PROTECTED] 
www.inbo.be 

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens [EMAIL PROTECTED]
Verzonden: maandag 4 augustus 2008 6:55
Aan: r-help@r-project.org
Onderwerp: [R] Sweave and ggplot2

Hi all,

I've been trying to run Sweave with R code embedded - using the ggplot2 
package and in particular the qplot command. There appears to be a
problem 
in Sweave not picking up that qplot is a function. Has anybody else
tried 
to use qplot in Sweave and have you been successful? Any help would be 
very much appreciated.

Kind Regards,

Sorn


Notice:
This email and any attachments may contain information\ ...{{dropped:10}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
[EMAIL PROTECTED]
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens Robert Terwilliger
Verzonden: vrijdag 8 augustus 2008 0:02
Aan: r-help@r-project.org
Onderwerp: [R] help with longitudinal data plot

Dear R Help,

I am attempting to make a plot of longitudinal data, a sample data
frame of which is shown below.

I'd like to show all of the subjects in the same plot, with a set of
connecting line segments for each subject. 'age' would be the x-axis
and 'score' would be the y-axis.

subject age  score
1 10123  12  51.06
2 10123  14  50.00
3 10123  15  62.22
4 10124  12  74.42
5 10124  13  72.73
6 10124  14  63.41
7 10125  16  54.55
8 10125  17  50.00
9 10125  18  54.35
1010128  17  97.83
1110128  18  97.87
1210128  19 100.00
...

Any help would be appreciated.

Regards,

Robert Terwilliger

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en 
bindt het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is 
door een geldig ondertekend document.
The views expressed in  this message and any annex are purely those of the 
writer and may not be regarded as stating an official position of INBO, as long 
as the message is not confirmed bij a duly signed document

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
[EMAIL PROTECTED]
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens Ranney, Steven
Verzonden: vrijdag 22 augustus 2008 23:34
Aan: r-help@r-project.org
Onderwerp: [R] Newbie programming help

All -

Not sure if this is a real programming question, but here goes:

I have data that looks like

LakeLength  Weight
1   158 45
1   179 70
1   200 125
1   202 150
1   206 145
1   209 165
1   210 140
1   215 175
1   216 152
1   220 150
1   221 165
...

where lake goes from 1 - 84 and the number of rows for each lake is
variable (but > ~20). 
I'm trying to do two things: 1) build a simple linear model of the form

{lm(log10(Weight)~log10(Length)}

for every separate lake in the data set; 2) I'd like to save the
intercepts and slopes
from each of these linear regressions into a seperate data frame.  Any
ideas?  I think it would
probably require some kind of 'for' statement, but I'm just not that
smart.

Thanks for your help,

SR 

Steven H. Ranney
Graduate Research Assistant (Ph.D)
USGS Montana Cooperative Fishery Research Unit
Montana State University
PO Box 173460
Bozeman, MT 59717-3460

phone: (406) 994-6643
fax:   (406) 994-7479


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en 
binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is 
door een geldig ondertekend document.
The views expressed in  this message and any annex are purely those of the 
writer and may not be regarded as stating an official position of INBO, as long 
as the message is not confirmed by a duly signed document

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
[EMAIL PROTECTED]
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens Rob Foxall
Verzonden: dinsdag 26 augustus 2008 10:36
Aan: r-help@r-project.org
Onderwerp: [R] parse and eval character vector

Dear R-help,

I have a character vector, some elements will be numeric, some not,
and some even empty. E.g.:

temp1 <- c("abcd","  2 ","")

I'm only interested in the numeric elements, the rest I can just throw
away. It is easy enough to loop through the vector:

temp <- try(eval(parse(text=temp1[1])), silent=TRUE); class(temp) #
try-error
temp <- try(eval(parse(text=temp1[2])), silent=TRUE); class(temp) #
numeric
temp <- try(eval(parse(text=temp1[3])), silent=TRUE); class(temp) # NULL

and then throw away the non-numeric/NULL stuff. But, as this vector
will be long, I would really like to speed things up by not using a
loop, and I thought that "lapply" might do the trick. However:

temp.fn <- function(x)
  try(eval(parse(text=x)), silent=TRUE)

temp2 <- lapply(temp1, FUN=temp.fn)
class(temp2[2]) # list, for elements 1, 2, and 3

and I don't know how to extract the numeric elements from here. So,
can I either use lapply as above and somehow get the information I
need out of "temp2" (I've tried using "unlist" but had no success), or
is there some other function that I can apply to my character vector
to avoid looping?

Rob.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en 
binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is 
door een geldig ondertekend document.
The views expressed in  this message and any annex are purely those of the 
writer and may not be regarded as stating an official position of INBO, as long 
as the message is not confirmed by a duly signed document

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
[EMAIL PROTECTED]
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens stephen sefick
Verzonden: dinsdag 26 augustus 2008 15:51
Aan: R Help
Onderwerp: [R] processing subset lists and then plot(density())

d <- structure(list(Site = structure(c(8L, 12L, 7L, 6L, 11L, 5L, 10L,
4L, 3L, 2L, 1L, 9L, 8L, 12L, 7L, 6L, 11L, 5L, 10L, 4L, 3L, 2L,
1L, 9L, 8L, 12L, 7L, 6L, 11L, 5L, 10L, 4L, 3L, 2L, 1L, 9L, 8L,
12L, 7L, 6L, 11L, 5L, 10L, 4L, 3L, 2L, 1L, 9L, 8L, 12L, 7L, 6L,
11L, 5L, 10L, 4L, 3L, 2L, 1L, 9L, 8L, 12L, 7L, 6L, 11L, 5L, 10L,
4L, 3L, 2L, 1L, 9L, 8L, 12L, 7L, 6L, 11L, 5L, 10L, 4L, 3L, 2L,
1L, 9L, 8L, 12L, 7L, 6L, 11L, 5L, 10L, 4L, 3L, 2L, 1L, 9L, 8L,
12L, 7L, 6L, 11L, 5L, 10L, 4L, 3L, 2L, 1L, 9L, 8L, 12L, 7L, 6L,
11L, 5L, 10L, 4L, 3L, 2L, 1L, 9L, 8L, 12L, 7L, 6L, 11L, 5L, 10L,
4L, 3L, 2L, 1L, 9L, 8L, 12L, 7L, 6L, 11L, 5L, 10L, 4L, 3L, 2L,
1L, 9L), .Label = c("119", "148", "179", "185", "190", "198",
"202", "215", "61", "BC", "HC", "SC"), class = "factor"), EPT.Taxa =
c(NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, 1L, NA, 3L, 1L, 5L, 7L, 3L, 11L, 3L, 14L, 12L, 12L,
0L, 0L, 4L, 0L, 5L, 3L, 2L, 6L, 1L, 8L, 6L, 9L, 1L, 0L, 2L, 0L,
5L, 2L, 1L, 0L, 2L, 4L, 6L, 8L, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, 2L, 4L, 3L, 2L, 7L, 6L, 4L, 8L, 7L, 11L, 8L,
11L, 1L, 3L, 0L, 2L, 7L, 8L, 2L, 7L, 6L, 11L, 6L, 12L, 1L, 1L,
0L, 0L, 0L, 1L, 2L, 9L, 6L, 16L, 6L, 10L, 2L, 3L, 3L, 2L, 5L,
2L, 0L, 3L, 6L, 10L, NA, 10L, 1L, 0L, 3L, 1L, 4L, 2L, 3L, 2L,
3L, 11L, 10L, 6L)), .Names = c("Site", "EPT.Taxa"), class =
"data.frame", row.names = c(NA,
-144L))
subset(d, Site==215)
#I would like to plot(density()) of each of the Sites
#I tried
list<-levels(d$Site)
lapply(d, FUN=subset, Site==list)
#I would like to be able to make a list of the subsets based on Site
and then plot them all on one graphics window
# Am I working in the right direction- I have just discovered lists (I
know I know, I am a little slow)
--
Stephen Sefick
Research Scientist
Southeastern Natural Sciences Academy

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods. We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en 
binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is 
door een geldig ondertekend document.
The views expressed in  this message and any annex are purely those of the 
writer and may not be regarded as stating an official position of INBO, as long 
as the message is not confirmed by a duly signed document

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 = TRUE). Given Rolf's suggestion I suppose
this trick will work on a Mac too.

HTH,

Thierry




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
[EMAIL PROTECTED]
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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



I'm not sure --- I find Mac OS very confusing.  But I have the 
***impression*** that
(on my system) by default packages get installed into

~/Library/R/2.7/library

i.e. into a library inside the directory tree rooted in my login

directory.

I don't use this --- I've created my own library ~/Rlib and have
set up an environment variable to point to it.

(This works properly only if you start R from the command line;
for
reasons I don't understand if you start R by clicking on the
icon
then R doesn't know about the R_LIBS environment variable.  But
since
all civilized people start R from the command line .)

I have no idea why youse guys' systems would eschew using
~/Library/
.

cheers,

Rolf Turner

##
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en 
binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is 
door een geldig ondertekend document.
The views expressed in  this message and any annex are purely those of the 
writer and may not be regarded as stating an official position of INBO, as long 
as the message is not confirmed by a duly signed document

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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





ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
[EMAIL PROTECTED]
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens [EMAIL PROTECTED]
Verzonden: donderdag 28 augustus 2008 3:14
Aan: r-help@r-project.org
Onderwerp: Re: [R] Updating a list.

Since this didn't work:

> m2007$DayOfYear <- factor(m2008$DayOfYear, levels = 1:365)
Error in `$<-.data.frame`(`*tmp*`, "DayOfYear", value = c(1L, 1L, 1L,  :

  replacement has 432267 rows, data has 1592009

Perhaps I need to clarify how the m2007 object was generated.

t2007 <- read.csv("Total2007.dat", header = TRUE)
m2007 <- melt(t2007,
id.var=c("DayOfYear","Category","SubCategory","Sku"),
measure.var=c("Quantity"))

Kevin


 hadley wickham <[EMAIL PROTECTED]> wrote:
>
> Try this:
>
> m2008$DayOfYear <- factor(m2008$DayOfYear, levels = 1:365)
> r2007 <- cast(m2008, DayOfYear ~ variable | Sku, sum, fill = 0)
>
> Hadley
>
> --
> http://had.co.nz/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en 
binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is 
door een geldig ondertekend document.
The views expressed in  this message and any annex are purely those of the 
writer and may not be regarded as stating an official position of INBO, as long 
as the message is not confirmed by a duly signed document

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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,

Thierry




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
[EMAIL PROTECTED]
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens Paul Emberson
Verzonden: woensdag 27 augustus 2008 17:58
Aan: r-help@r-project.org
Onderwerp: [R] ggplot2: problem with large fonts and overlapping labels

Hi,

I am using ggplot2 to generate graphs for a paper I am writing in two
column format.  When I shrink the graphs to fit in a single column, the
graph is clear but the axis and tick labels are way too small.

I have increased the font sizes by manipulating the grid.  However, when

I do this the tick labels and axis labels get very close or even
overlap, especially on the y-axis.  Is there a way to increase the
margin between tick labels and axis labels with ggplot or by
manipulating the grid?

Regards,

Paul

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en 
binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is 
door een geldig ondertekend document.
The views expressed in  this message and any annex are purely those of the 
writer and may not be regarded as stating an official position of INBO, as long 
as the message is not confirmed by a duly signed document

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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(whichCombination, 1, all)
})
allComb[apply(whichComb, 1, all), ]

HTH,

Thierry





ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
[EMAIL PROTECTED]
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens Lucien Lemmens
Verzonden: zondag 31 augustus 2008 15:58
Aan: [EMAIL PROTECTED]
Onderwerp: Re: [R] give all combinations



Another solution requiring also a bit of programming is:

 l<-letters[1:3]
 c2<-c()
 for(i in 1:3){c2<-c(c2,paste(letters[i],letters[i:3],sep=""))}
 c2
[1] "aa" "ab" "ac" "bb" "bc" "cc"
 n<-length(c2)
 c3<-c();for(i in
1:n){c3<-c(c3,paste(c2[i],letters[ceiling(i/2):3],sep=""))}
 c3
 [1] "aaa" "aab" "aac" "aba" "abb" "abc" "acb" "acc" "bbb" "bbc" "bcc"
"ccc"

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en 
binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is 
door een geldig ondertekend document.
The views expressed in  this message and any annex are purely those of the 
writer and may not be regarded as stating an official position of INBO, as long 
as the message is not confirmed by a duly signed document

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
[EMAIL PROTECTED]
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens Asher Meir
Verzonden: zondag 31 augustus 2008 11:02
Aan: r-help@r-project.org
Onderwerp: [R] Avoiding factors and levels in data frames

Hello all.

I am an experienced R user, I have used R for many years for a wide
variety of applications. However, I keep on running into one obstacle:
I never want factors or levels in my data frames, but I keep on
getting them. Is there any way to globally turn this whole feature of
data frames off? Using options(stringAsFactors=FALSE) does not seem to
work.
Alternatively, if I have a data frame with levels, can I just get rid
of them in that data frame?

Here is an example: I have a large text file, of which part is in the
fixed-width tabular form I need. I created a widths vector and a
column names vector. I then read the file as follows:

raw1<-read.fwf(fn1,widths=widmax,col.names=headermax,stringsAsFactors=FA
LSE)

But raw1 still has factors! It is an old class data frame:

> is(raw1)
[1] "data.frame" "oldClass"

And it still has levels:
> raw1[1,1]
[1] Gustav wind
229 Levels: - - - - - - - - - - - WIN   - - - M ... Z INDICATES
C

My question is:
1. Can I get rid of the levels in raw1?
2. Even better -- can I stop it getting read in as a data frame with
factors?
3. Even better -- can I just tell R to never use factors in my data
frames?

Or any other solution that occurs to people -- maybe this is the wrong
way to go about reading in fixed width data in this kind of file.

I would appreciate any help.

Asher

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en 
binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is 
door een geldig ondertekend document.
The views expressed in  this message and any annex are purely those of the 
writer and may not be regarded as stating an official position of INBO, as long 
as the message is not confirmed by a duly signed document

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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

2008-09-01 Thread ONKELINX, Thierry

Dear Ted,

I noticed that as.is was set by default in read.fwf. So if the user sets
stringsAsFactor it is passed through ... to read.table. But I'm not sure
how as.is is passed to read.table when onlye stringsAsFactors is set. If
it's the default (FALSE) then it might be conflicting with
stringsAsFactor. Therefore my suggestion to use as.is instead of
stringsAsFactor in this case.

I suppose it might be a good idea to add stringsAsFactor to the
argumentlist of read.fwf and give it the same defaults as read.table.

Cheers,

Thierry




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
[EMAIL PROTECTED]
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens [EMAIL PROTECTED]
Verzonden: maandag 1 september 2008 11:23
Aan: 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
> stringsAsFactors = FALSE in the read.fwf function. Because as.is
> is set to FALSE by default and stringsAsFactors is not set.
>
> HTH,
>
> Thierry

Can I ask for some elucidation about how the code operates here?
Apparently read.fwf() calls read.table(), and ?read.fwf refers
you to ?read.table for things like 'as.is' and 'stringsAsFactors'.

When I look at the code for read.table, I see in the paramater
list:

function (file,  , as.is = !stringsAsFactors, ... ,
  stringsAsFactors = default.stringsAsFactors(), ... )

with *no further reference whatever* to 'stringsAsFactors' in the
body of the function. In particular, there is no test that I can
see of whether or not 'stringsAsFactors' has been set by the user
in the call.

The standard result of default.stringsAsFactors() is TRUE.

I've written a tiny test function:

  temp<-function(as.is = !stringsAsFactors,
stringsAsFactors = default.stringsAsFactors()){
  print(c(as.is=as.is, sAF=stringsAsFactors))
  }

  temp()
# as.is   sAF
# FALSE  TRUE

  temp(stringsAsFactors = FALSE)
# as.is   sAF
#  TRUE FALSE

  temp(as.is=FALSE,stringsAsFactors = FALSE)
# as.is   sAF
# FALSE FALSE

So, if read.table is called with 'as.is=FALSE' (which is the default
set by read.fwf(), with any reference to 'stringsAsFactors' in the
call being part of the "..." which is passed to read.table()), then
read.table will be called with 'as.is=FALSE' regardless of whether
'stringsAsFactors=FALSE' has been set explicitly in calling read.fwf().

The only way to get 'as.is' to be TRUE would be to set it explicitly
in the call to read.fwf() (and in that case one need not bother with
'stringsAsFactors', since its only purpose seems to be to determine
the value of 'as.is'). Or, of course, to set default.stringsAsFactors
to be FALSE; but in many case people will want to have per-case
control over what happens in cases like this.

Well, that's how it seems to me, on reading the code. Is this what
Thierry really means when he says "stringsAsFactors is not set"?

If that is the case, then it seems to indicate some conflict or
inconsistency between read.fwf() and read.table() in this respect.
In any case, it strikes me as something of an undesirable tangle!

With thanks for any comments,
Ted.

> -Oorspronkelijk bericht-
> Van: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
> Namens Asher Meir
> Verzonden: zondag 31 augustus 2008 11:02
> Aan: r-help@r-project.org
> Onderwerp: [R] Avoiding factors and levels in data frames
>
> Hello all.
>
> I am an experienced R user, I have used R for many years for a wide
> variety of applications. However, I keep on running into one obstacle:
> I never want factors or levels in my data frames, but I keep on
> getting them. Is there any way to globally turn this whole feature of
> data frames off? Using options(stringAsFactors=FALSE) does not seem to
> work.
> Alternatively, if I have a data frame with levels, can I just get rid
> of them in that data frame?
>
> Here is an e

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 Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
[EMAIL PROTECTED]
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens Antje
Verzonden: maandag 1 september 2008 15:44
Aan: [EMAIL PROTECTED]
Onderwerp: [R] another histogram question

Hi there,

I hope this question is not as stupid as the one before ...
I tried to shorten my histogram (because the distribution is quite
skewed and I
simply don't want to see the long tail but still use the histogram
plot). How
can I do something like this? (The example does not work but I don't
know why...)

data <- rnorm(100) # as example, of course this is not skewed...

h <- hist(data, plot=FALSE)
mh <- 5
hh <- list(h$breaks[0:(mh+1)],
h$counts[0:mh],h$intensities[0:mh],h$density[0:mh],h$mids[0:mh],h$xname,
h$equidist)
names(hh) <- names(h)
plot(hh)


Antje

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en 
binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is 
door een geldig ondertekend document.
The views expressed in  this message and any annex are purely those of the 
writer and may not be regarded as stating an official position of INBO, as long 
as the message is not confirmed by a duly signed document

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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
temperature is NOT the overall effect of temperature but the effect for
the reference category (in your case semio1).

It looks like you need to do some reading on ?contrasts and
?contr.treatment

HTH,

Thierry




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
[EMAIL PROTECTED] 
www.inbo.be 

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens lara harrup (IAH-P)
Verzonden: woensdag 3 september 2008 10:47
Aan: r-help@r-project.org
Onderwerp: [R] ANCOVA/glm missing/ignored interaction combinations

Hi

I am using R version 2.7.2. on a windows XP OS and have a question
concerning an analysis of covariance with count data I am trying to do,
I will give details of a scaled down version of the analysis (as I have
more covariates and need to take account of over-dispersion etc etc) but
as I am sure it is only a simple problem but I just can't see how to fix
it.

I have a data set with count data as the response (total) and two
continuous covariates and one categorical explanatory variable (semio).
When I run the following lines, after loading the data and assigning
'semio' as a factor, taking into account that I want to consider two way
interactions:

> model.a<-glm(total~(temperature+humidity+semio)^2,family=poisson)
> summary(model.a)

I get the output below. But not all interactions are listed there are 4
semio categories, 1,2,3 and 4 but only 2,3,and 4 are listed in the
summary (semio2,semio3,semio4). And I cant for the life of me work out
why category one (semio1) is being ignored, missing etc.

Any help or suggestions would be most appreciated. Thanks in advance

Lara
[EMAIL PROTECTED]

Call:
glm(formula = total ~ (temperature + humidity + semio)^2, family =
poisson)

Deviance Residuals: 
Min   1Q   Median   3Q  Max  
-22.212   -5.132   -2.4843.200   18.793 

Coefficients:
  Estimate Std. Error z value Pr(>|z|)
(Intercept)  23.848754   2.621291   9.098  < 2e-16 ***
temperature  -1.038284   0.150465  -6.901 5.18e-12 ***
humidity -0.264912   0.033928  -7.808 5.81e-15 ***
semio2   22.852664   1.291806  17.690  < 2e-16 ***
semio33.699901   1.349007   2.743   0.0061 ** 
semio4   -1.851163   1.585997  -1.167   0.2431
temperature:humidity  0.012983   0.001983   6.545 5.94e-11 ***
temperature:semio2   -0.870430   0.037602 -23.149  < 2e-16 ***
temperature:semio3   -0.060846   0.038677  -1.573   0.1157
temperature:semio40.055288   0.046137   1.198   0.2308
humidity:semio2  -0.114718   0.013369  -8.581  < 2e-16 ***
humidity:semio3  -0.031692   0.013794  -2.298   0.0216 *  
humidity:semio4   0.008425   0.016020   0.526   0.5990
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 

(Dispersion parameter for poisson family taken to be 1)

Null deviance: 10423.5  on 47  degrees of freedom Residual deviance:
2902.2  on 35  degrees of freedom
AIC: 3086.4

Number of Fisher Scoring iterations: 7

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en 
binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is 
door een geldig ondertekend document.%CRLF%The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document%CRLF%

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible 

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 / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
[EMAIL PROTECTED] 
www.inbo.be 

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens btcruiser
Verzonden: woensdag 3 september 2008 20:33
Aan: r-help@r-project.org
Onderwerp: [R] ggplot2: line plot with gaps in time axis


Hello, I'm trying to plot data that has gaps in the timeline because my
data
only has the business day in it. When I do a line plot I get the data
and
then a blank area where a line goes the tail of the last data point  to
the
head of the next data point. Is there a way I can do a line plot where
the
gaps are not plotted?

Thanks in advance, 

Brian

> names(utildf)
[1] "Date_and_Time" "Utilization"   "Direction"
> utildf
   Date_and_Time Utilization Direction
12008-08-25 05:00:005.862601   Inbound
22008-08-25 05:05:00   10.025328   Inbound
32008-08-25 05:10:005.794900   Inbound
42008-08-25 05:15:009.862726   Inbound
52008-08-25 05:20:004.150328   Inbound
62008-08-25 05:25:005.559362   Inbound
[...]

# startDateTime and stopDateTime is user entered
Start <- as.numeric(as.POSIXct(startDateTime))
End <- as.numeric(as.POSIXct(stopDateTime))
Period<-as.numeric(seq.POSIXt(as.POSIXct(Start,origin="1970-1-1"),
as.POSIXct(End,origin="1970-1-1"), by="DSTday"))
Labels<-as.Date(seq.POSIXt(as.POSIXct(Start,origin="1970-1-1"),
as.POSIXct(End,origin="1970-1-1"), by="DSTday"))
dt <-
qplot(as.numeric(utildf$Date_and_Time),Utilization,data=utildf,colour=Di
rection,geom="segment")
dt + scale_x_continuous(breaks=Period,label=Labels)

-- 
View this message in context:
http://www.nabble.com/ggplot2%3A-line-plot-with-gaps-in-time-axis-tp1929
5209p19295209.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en 
binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is 
door een geldig ondertekend document.%CRLF%The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document%CRLF%

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
[EMAIL PROTECTED] 
www.inbo.be 

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens Williams, Robin
Verzonden: donderdag 4 september 2008 9:55
Aan: r-help@r-project.org
Onderwerp: [R] Coefficient of skewness

Hi,
Is there a function in R to calculate the coefficient of skewness of
some data? I had expected there to be one, but can find no information
about it.
Thanks for any pointers.


Robin Williams
Met Office summer intern - Health Forecasting
[EMAIL PROTECTED] 



[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en 
binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is 
door een geldig ondertekend document.%CRLF%The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document%CRLF%

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Jong Hoon Choi
Verzonden: dinsdag 11 augustus 2009 3:26
Aan: r-help@r-project.org
Onderwerp: [R] obtain linear regression parameters from qplot

Hi,
My question is how to get linear regression parameters (e.g. slope,
y-intercept, etc.) from the fittings in qplot.

My code looks like this,

Fig1 = qplot(data=subset(totalD, (Name=="increase1"), x=Time,
y=Intensity, main="Total Data")
Fig1 + stat_smooth(method="lm")

I can get the linear regression fittings but I am not sure how to get
the parameters out of them.

Thanks for your help in advance.
JC

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens John Kane
Verzonden: maandag 10 augustus 2009 21:30
Aan: r-h...@stat.math.ethz.ch
Onderwerp: [R] ggplot: colours to geom_segments


Just as an exercise I am tying to add colours to a geom_segment command.
I can get one colour but not a sequence of colours.  
Can anyone suggest how I can get the green lines in the plot below to be
different colours?  I thought I could use a palatte of colours but that
did not seem to work.

Thanks


=

library(ggplot2)

xx <- structure(list(Food = structure(c(2L, 1L, 3L, 4L), .Label =
c("Bread", "Milk", "Potatoes", "Rice"), class = "factor"), Expense =
c(25, 49, 34, 15)), .Names = c("Food", "Expense"), row.names = c(NA,
-4L), class = "data.frame")

p <- ggplot(xx, aes(x = 0, xend = Expense,  y = Food, yend = Food)) pa
<- p + geom_point(aes(Expense, Food)) + 
   geom_segment(colour="darkgreen") + 
   xlab("Food") + geom_vline(xintercept=40, colour='red') pa

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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()




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Dimitris Rizopoulos
Verzonden: dinsdag 11 augustus 2009 11:24
Aan: Jorgy Porgee
CC: r-help@r-project.org
Onderwerp: Re: [R] How do I plot: regression line, regression line +
s.d, regression line - s.d on the same chart?

have a look at predict.lm() and specifically at the 'interval' argument
-- check also the following

x <- runif(100, -5, 5)
y <- 3 + 2 * x + rnorm(100, sd = 2)

fit <- lm(y ~ x)
xx <- seq(min(x), max(x), length.out = 30) pred <- predict(fit, newdata
= data.frame(x = xx), interval = "p")

plot(x, y)
matlines(xx, pred, lty = c(1, 2, 2), col = "red")


I hope it helps.

Best,
Dimitris


Jorgy Porgee wrote:
> Hello all,
> I've got a scatter plot, for which I create a regression line using:
> reg<- lm(yvars~xvars) and can plot the regression through the scatter 
> just fine.
> I'd like to add two additional lines on the scatter plot: one being
> regressionline+standard deviation, the other being
> regressionline-standard deviation, thus creating some kind of 'band'
> for the scatter.
> 
> Any help will be much appreciated. Thanking you in advance,
> 
> George.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] ggplot: colours to geom_segments

2009-08-11 Thread ONKELINX, Thierry
John,

Have a look at scale_colour_manual() 
(http://had.co.nz/ggplot2/scale_manual.html)

HTH,

Thierry


PS My solution was exactly the same as Paul's. 



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and 
Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology 
and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: 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


> Paul Emberson
> "You need to map colour to a variable.  Try
> geom_segment(mapping=aes(colour=Food)) "

That did it.  Apparently I have not gotten to 'mapping' yet in the book!

> Thierry.ONKELINX
> You need to change colour = "darkgreen" into aes(colour = Food). This 
> will give a different colour along Food.

Not exactly, Thierry, I wanted to change the line colours but your solution has 
solved my next problem which was to make the points and the lines have the same 
colours.

Thanks to both of you.

Next Question  

How do I select colours rather than using the predetermined ones? I know that I 
should, at least, be able to use RColorBrewer but I have not figured out how 
yet.

Thanks again.

John

--- On Tue, 8/11/09, ONKELINX, Thierry  wrote:

> From: ONKELINX, Thierry 
> Subject: RE: [R] ggplot: colours to geom_segments
> To: "John Kane" , r-h...@stat.math.ethz.ch
> Received: Tuesday, August 11, 2009, 5:35 AM Dear John,
> 
> You need to change colour = "darkgreen" into aes(colour = Food). This 
> will give a different colour along Food.
> 
> HTH,
> 
> Thierry
> 
> --
> --

> Just as an exercise I am tying to add colours to a geom_segment 
> command.
> I can get one colour but not a sequence of colours. Can anyone suggest 
> how I can get the green lines in the plot below to be different 
> colours?  I thought I could use a palatte of colours but that did not 
> seem to work.
> 
> Thanks
> 
> ==
> ==
> =
> 
> library(ggplot2)
> 
> xx <- structure(list(Food = structure(c(2L, 1L, 3L, 4L), .Label = 
> c("Bread", "Milk", "Potatoes", "Rice"), class = "factor"), Expense = 
> c(25, 49, 34, 15)), .Names = c("Food", "Expense"), row.names = c(NA, 
> -4L), class = "data.frame")
> 
> p <- ggplot(xx, aes(x = 0, xend = Expense,  y = Food, yend = Food)) pa
> <- p + geom_point(aes(Expense, Food)) +
>    
>    geom_segment(colour="darkgreen") +
>        xlab("Food") +
> geom_vline(xintercept=40, colour='red') pa



  __
Looking for the perfect gift? Give the gift of Flickr!

http://www.flickr.com/gift/

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Tal Galili
Verzonden: woensdag 12 augustus 2009 11:48
Aan: r-help@r-project.org
Onderwerp: [R] A function for plotting a boxplot with added dot and bars
(formean and SE) - please help improve my code

Hello people,

A while back I wanted to plot boxplots with interactions that will have
a dot for the mean of the sample + bars for the SE.
After searching for some code, I found something that did it for one
level, but couldn't find something that will allow for interactions the
way the original boxplot does.

After playing with the original code, I found a way for allowing the
boxplot code to introduce interactions to it. The price for that was
that I was forced to use a little different syntax for the function then
that of the original boxplot. In order to use the function, one must use
lists for the function input arguments, and until now I didn't find a
way for doing the same task from a formula input.
So for example, the original boxplot will be written like this:
boxplot(y ~ A*B)
Where as my function will look like this:
boxplot.2(y , list(A,B) )



In this e-mail I am giving away the code for:
1) helping out others searching for this solution. and
2) in hope to have more experienced R programmers come by and improve on
this code (by, for example, removing the for loop in it, or allowing to
use a formula instead of a list input)



Here is the code:


boxplot.2 <- function(fo.head, list.fo.tail = list(1), print.mean = T,
plot.CI = T, add.mean.sd.to.boxplot.names = T, plot.round.factor = 2
,...) {
  require(gplots)
  tmp   <- split(fo.head ,  list.fo.tail)
  means <- sapply(tmp, mean)
  stdev <- sqrt(sapply(tmp, var))  #IS right - because of the sqrt !!!
<- sqrt(sapply(tmp, var))  # was var, I changed it to sd
  n <- sapply(tmp,length)
  ciw   <- qt(0.975, n-1) * stdev / sqrt(n)
  old.names = attributes(tmp)$names
  length.of.names = length(old.names)
  new.names = as.list(old.names)
  for(i in c(1:length.of.names))
  {
new.names[[i]] <- paste(old.names[i], " (",
round(means[i],plot.round.factor) ,",", round(ciw[i],plot.round.factor)
,")", sep = "")
  }

  if(add.mean.sd.to.boxplot.names)
   {
   if(length(list.fo.tail) == 1)
   {
 sub.text = paste("mean:", round(means,3),
"(SE:",round(ciw,3), " ; N:" ,n, ")")
 boxplot(tmp, xlab = sub.text, cex.axis = min(1,
mean(c(1,12/
max(nchar(new.names)) ))  ), ...)
   } else {
 boxplot(tmp, names = new.names, cex.axis = min(1,
mean(c(1,12/
max(nchar(new.names)) ))  ), ...)
   }
  } else {  boxplot(tmp, ...) } # else - make boxplot without them

  # adding the points and the bars
  points(means, col = 'red', pch = 19)
  if(require(gplots) & plot.CI) {
  plotCI(x=means, uiw=ciw, col="white", barcol="blue",
 xaxt="n" , add = T)
 }

  if(print.mean) {
  small.mean.and.se.table <- rbind(round(means,3),round(ciw,3), n)
  rownames(small.mean.and.se.table) <- c("means:", "SE's:", "N")
  print(t(small.mean.and.se.table))
}
} # <-- end boxplot3


# Here is a small example:
data(mtcars)
head(mtcars)
attach(mtcars)
boxplot.2(mpg , list(round(wt), am) , data = mtcars, las = 2)






Hope this will benefit others, and also hope that others will improve on
this code and give it back to the community, Tal galili



--
--


My contact information:
Tal Galili
Phone number: 972-50-3373767
FaceBook: Tal Galili
My Blogs:
http://www.r-statistics.com/
http://www.talgalili.com
http://www.biostatistics.co.il

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commen

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
Two solutions with errorbars

library(ggplot2)
#option 1
lowCI <- function(x){mean(x) + qt(0.025, length(x) - 1) * sd(x) /
sqrt(length(x))}
highCI <- function(x){mean(x) + qt(0.975, length(x) - 1) * sd(x) /
sqrt(length(x))}
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)) + geom_errorbar(stat = "summary", fun.ymin
= lowCI, fun.ymax = highCI, position = position_dodge(width = 0.75),
linetype = 2)

#option2
mtcars$fwt <- factor(round(mtcars$wt))
MeanCI <- ddply(mtcars, c("fwt", "am"), function(z){
with(z, mean(mpg) + qt(c(low = 0.025, mean = 0.5, high = 0.975),
length(mpg) - 1) * sd(mpg) / sqrt(length(mpg)))
})
ggplot(mtcars, aes(x = fwt, y = mpg, colour = factor(am))) +
geom_boxplot() + geom_point(data = MeanCI, aes(y = mean), position =
position_dodge(width = 0.75)) + geom_errorbar(data = MeanCI, aes(ymin =
low, ymax = high), position = position_dodge(width = 0.75), linetype =
2)

 



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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
  





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 function for plotting a boxplot with added dot and
bars (formean and SE) - please help improve my code


Thanks Thierry, 
I didn't know about that, it's always nice to see different ways of
doing things.
Question: How would you add the bars ?


Hope to see more interesting replies,
Tal









On Wed, Aug 12, 2009 at 1:29 PM, ONKELINX, Thierry
 wrote:


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




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for
Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section
biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be
no more
than asking him to perform a post-mortem examination: he may be
able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org]
Namens Tal Galili
Verzonden: woensdag 12 augustus 2009 11:48
Aan: r-help@r-project.org
Onderwerp: [R] A function for plotting a boxplot with added dot
and bars
(formean and SE) - please help improve my code


Hello people,

A while back I wanted to plot boxplots with interactions that
will have
a dot for the mean of the sample + bars for the SE.
After searching for some code, I found something that did it for
one
level, but couldn't find something that will allow for
interactions the
way the original boxplot does.

After playing with the original code, I found a way for allowing
the
boxplot code to introduce interactions to it. The price for that
was
that I was forced to use a little different syntax for the
function then
that of the original boxplot. In order to use the function, one
must use
lists for the function input arguments, and until now I

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,

Thierry



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Nir Shachaf
Verzonden: donderdag 13 augustus 2009 11:00
Aan: r-help@r-project.org
Onderwerp: [R] un run run...

Hi All,

I am running an Rscript with a bunch of algorithms that are UNSTABLE
under some parameter settings.

At a certain point one of them sends error massage and my whole run
STOPS!

What I would like is to save the error massage in some file or variable
and carry on to the next command line without stopping this run...

Any help or ideas would be welcome, please, with a concrete example (not
just - "have you thought of using 'tryCatch' etc.).

Thanks all!
Nir

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[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 contain false positives:
peaks due to noise instead of the true pattern from A. An additional
problem is that some peaks from A could be missing in B.
So what I am looking for is a way to select the largest possible subsets
from A and B that give a good estimate of their relationship.

Here is some example data. Notice that both B's have a different length.
They should match both with A.

A <- c(50, 100, 145, 200, 204, 255, 300, 350, 364, 400, 460, 495, 500,
530, 565, 600, 650, 700)
B <- c(561, 622, 1050, 1290, 1574, 1594, 1613, 1910, 2165, 2438, 2520,
2706, 3013, 3182, 3203, 3343, 3496, 3645, 3844, 4026)
B <- c(573, 633, 671, 707, 1060, 1303, 1594, 1615, 1633, 1936, 2195,
2472, 2554, 2743, 3053, 3225, 3246, 3388, 3543, 3693, 3894, 4078)

Any suggestions?

Best regards,

Thierry



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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


Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Steve Murray
Verzonden: maandag 17 augustus 2009 18:53
Aan: r-help@r-project.org
Onderwerp: [R] Reshape package: Casting data to form a grid


Dear R Users,

I'm trying to use the 'cast' function in the 'reshape' package to
convert column-format data to gridded-format data. A sample of my
dataset is as follows:

head(finalframe)
  Latitude Longitude Temperature OrigLat  p-value Blaney
1  -90-38.75  NA  -87.75 17.10167 NA
2  -90135.75  NA  -87.75 17.10167 NA
3  -90 80.25  NA  -87.75 17.10167 NA
4  -90 95.75  NA  -87.75 17.10167 NA
5  -90 66.75  NA  -87.75 17.10167 NA
6  -90 75.75  NA  -87.75 17.10167 NA


I'm attempting to form a grid based on the OrigLat, Longitude and Blaney
columns, to form the rows, columns and values of the new grid
respectively.

The command I've been using is:

cast_test <- cast(finalframe, finalframe$OrigLat~variable,
finalframe$Longitude~variable, finalframe$Blaney~variable)
Error: Casting formula contains variables not found in molten data:
finalframe$OrigLat, variable

And I've tried removing the ~variable suffixes:

cast_test <- cast(finalframe, finalframe$OrigLat, finalframe$Longitude,
finalframe$Blaney)
Error: Casting formula contains variables not found in molten data:
-87.75-87.75-87.75-87.75-87.75-87.75-87.75-87.75-87.75-87.75-87.75-87.75
-87.75-87.75 [etc etc]


I'm not sure how to get round this error, nor what the 'molten data' is
that the error is referring to. I'm assuming it means the data frame
presented above, yet the variables are clearly present!

Any help or advice on this would be most welcomed.

Many thanks,

Steve


_

[[elided Hotmail spam]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens rajesh j
Verzonden: woensdag 19 augustus 2009 7:47
Aan: r-help@r-project.org
Onderwerp: [R] ggplot 2 semi-transparency error

Hi,
I used the command ggplot as follows...
p<-ggplot(a,aes(x=a$V1,colour=a$V2,fill=a$V2))
p +  geom_density(alpha = 0.2,xlim=c(-10,10),ylim=c(0,0.5))

when I say,
dev.print(device=postscript,file="/alpha/dct.pdf")
I get

Warning message:
In grid.Call.graphics("L_polygon", x$x, x$y,
list(as.integer(1L:length(x$x :
  semi-transparency is not supported on this device: reported only once
per page

the pdf has error
any help?
--
Rajesh.J

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 independent
(not correlated). In your first model all random effects are correlated.
In your second model the first random intercept is correlated with the
random slope of IV1. The second random intercept with the random slope
of IV2.

Depending on if you want your interaction to be indepentend or not your
can use either

lmer(DV ~ IV1 + IV2 + (IV1 * IV2 | Subject))
lmer(DV ~ IV1 + IV2 + (1 | Subject) + (IV1 -1 | Subject) + (IV2 - 1|
Subject) + (IV1:IV2 - 1| Subject))


Note that IV1 * IV2 is equivalent to 1 + IV1 + IV2 + IV1:IV2

HTH,

Thierry

PS R-Sig-mixed-models is a better list for this kind of questions. 




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Jason R. Finley
Verzonden: woensdag 19 augustus 2009 3:47
Aan: r-help@r-project.org
Onderwerp: [R] lmer with random slopes for 2 or more first-level
factors?

I have data from a design in which items are completely nested within
subjects.  Subject is the only second-level factor, but I have multiple
first-level factors (IVs).  Say there are 2 such independent variables
that I am interested in.  What is the proper syntax to fit a
mixed-effects model with a by-subject random intercept, and by-subject
random slopes for both the 2 IVs?

I can think of at least two possibilities:

lmer(DV ~ IV1 + IV2 + (1 + IV1 + IV2 | Subject))

lmer(DV ~ IV1 + IV2 + (1 + IV1 | Subject) + (1 + IV2 | Subject))

Or maybe there is some other way to do it?  Maybe the correct syntax
depends on whether the random effect of subjects on the intercept and
slopes are correlated or not?  (If so, how do I proceed?)

Finally, what would be the syntax if I wanted to include a random
subject effect for the INTERACTION of IV1 and IV2?

Thanks very much,
~jason

PS: additional search terms: multi-level linear model, MLM,
hierarchical, repeated measures

~~~
Jason R. Finley
Department of Psychology
University of Illinois, Urbana-Champaign
~~~

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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

ggplot(xy, aes(x=value, fill=case, group=case)) +
geom_histogram(binwidth=0.1, position = "identity", alpha = 0.2)
ggplot(xy, aes(x=value, fill=case, group=case)) +
geom_histogram(binwidth=0.1, position = "dodge") 

HTH,

Thierry



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens hadley wickham
Verzonden: woensdag 19 augustus 2009 14:18
Aan: Chris Friedl
CC: r-help@r-project.org
Onderwerp: Re: [R] ggplot2 legend problem

On Tue, Aug 18, 2009 at 11:10 PM, Chris Friedl
wrote:
>
> Still struggling with this. A further example using a slightly 
> different organisation of the data. The factors "A" and "B" are 
> included in the dataframe in an attempt to get ggplot to generate a
legend automatically.
>
> x <- data.frame(value=rnorm(5000, mean=0), case="A") y <- 
> data.frame(value=rnorm(5000, mean=3), case="B") xy <- rbind(x, y) 
> ggplot(xy, aes(x=value, fill=case, group=case)) +
> geom_histogram(binwidth=0.1)
> ggplot(xy, aes(x=value, fill=case, group=case)) + 
> geom_density(alpha=0.2)
>
> Whilst the legend is generated as expected the histogram and density 
> plots are different. The density plots overlap each other whereas the 
> histogram plots stack. I'm trying the get the histogram plots to 
> overlap, and retain the legend. Is the histogram stacking by design? 
> Can stacking be changed to overlapping?

I'm skeptical that this will create a useful plot, but

geom_histogram(binwidth=0.1, position = "identity")

will do what you want.  You might also want to look at geom_freqpoly.

Alternatively, to use your previous approach, you just need to make a
couple of small changes:

g + geom_histogram(aes(x=X, fill = "A"), colour="black", binwidth = 0.1)
+
   geom_histogram(aes(x=Y, fill = "B"), colour="black", binwidth = 0.1)
+
  scale_fill_manual("Case", c("A" = alpha("red", 0.5),
"B"=alpha("blue",0.5)))

Previously you weren't supplying the fill aesthetic so the scale had
nothing to work with.

Hadley

--
http://had.co.nz/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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. I have the feeling that everything scales rather nice when
using a different resolution, except for the fonts.

My workaround is to always save my plots to pdf. I use them as pdf (no
problem with that in LaTeX), unless the figure contains lots of points
(e.g. scatterplots). In that case I convert the pdf to png outside R.
The best tools I found for that are Ghostfriend
(http://www.noliturbare.com/index.php) and www.zamzar.com.

HTH,

Thierry



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Dieter Menne
Verzonden: donderdag 20 augustus 2009 9:13
Aan: r-help@r-project.org
Onderwerp: Re: [R] ggsave to .png bug in ggplot2 (?)




Chris Friedl wrote:
> 
> Text is really small and legend boxes are huge in this plot when saved

> to .png with ggsave. Plot is correct (i.e. looks the same as the 
> screen) when saved with dev.print. Saving to .pdf with ggsave give the
correct output.
> 
> 

You are not alone. Things like this always happen the day before the
deadline, when you want to make minor changes. It is not limited to
ggplot, but looking at the variant

require(ggplot2)
x <- data.frame(value=rnorm(5000, mean=0), case="A") y <-
data.frame(value=rnorm(5000, mean=3), case="B") xy <- rbind(x, y) p <-
ggplot(xy, aes(x=value, colour=case, group=case)) + geom_density() p
ggsave(p, width=4,height=4,filename = "xy_ggsave.png")

makes me believe that this function should be banned. You might also
check the output of the ggsave documentation page to learn what scaling
means in R. (Slightly modified below). 

ratings <- qplot(rating, data=movies, geom="histogram") qplot(length,
data=movies, geom="histogram")
ggsave(file="length-hist.pdf")
ggsave(file="length-hist.png")
ggsave(ratings, file="ratingsA.pdf")
ggsave(ratings, file="ratingsB.pdf", width=4, height=4) # make twice as
big as on screen ggsave(ratings, file="ratingsC.pdf", scale=2)


I never use these functions in final production, be it in standard
graphics or lattice, but always open a device and close it after all
plots have been produced.

Dieter




--
View this message in context:
http://www.nabble.com/ggsave-to-.png-bug-in-ggplot2-%28-%29-tp25055170p2
5057074.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 plot has 2 subplots. A
subplot contains 8 individuals.
In this case you have 2 blocks, 4 plots, 8 subplots and 64 individuals.
So the model will look like: 
y~explanatory.variables + block/plot, random=~time|subplot/individual

Another example: 6 blocks with each 2 plots. Each plot has 2 subplots. A
subplot contains 3 individuals.
In this case you have 6 blocks, 12 plots, 24 subplots and 72
individuals. So the model will look like: 
y~explanatory.variables, random=~time|block/plot/subplot/individual

HTH,

Thierry



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Christoph Scherber
Verzonden: donderdag 20 augustus 2009 11:33
Aan: r-h...@stat.math.ethz.ch
Onderwerp: [R] nested, repeated measure lme

Dear all,

Suppose I have a nested, repeated measure lme model. Which of the
following formulae is  correct?
(assuming data are sampled from several plots in an agricultural
experiment)

(1) y~explanatory.variables,random=~time|block/plot/subplot/individual
(2) y~explanatory.variables,random=~time|unique.ID.of.every.individual

I have read that (2) is the only approach that works. But how could I
then still include the nesting information from (1)?

Many thanks for your help!

Best wishes
Christoph


(using R 2.9.0 and the nlme library on Windows XP)




--
Dr. rer.nat. Christoph Scherber
University of Goettingen
DNPW, Agroecology
Waldweg 26
D-37073 Goettingen
Germany

phone +49 (0)551 39 8807
fax   +49 (0)551 39 8806

Homepage http://www.gwdg.de/~cscherb1

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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()
ggplot(dataset, aes(x = x, y = y, colour = z)) + geom_line()
ggplot(dataset, aes(x = x, y = y, colour = z)) + geom_line(size = 2) + 
scale_colour_gradient2(low = "blue", mid = "yellow", high = "red", breaks = 
seq(-9, 11, by = 1)) 

HTH,

Thierry


ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and 
Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology 
and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens 
Gonçalo Graça
Verzonden: vrijdag 21 augustus 2009 11:31
Aan: r-help@r-project.org
Onderwerp: [R] 2d color coded line plot

Hi! I'm not experienced very experienced with R and i'm looking for a way doing 
plots like in this example 
http://www.mathworks.de/matlabcentral/fx_files/23566/2/color_line3.png,
which basically it is a 2d plot in which the 3rd dimension (variable) is color 
coded. I have only seen elsewhere that it is possible to color code dots in a 
scatter plot and I tried it with success although I  I didn't find a way of 
including the color bar has legend to the plot.

I wonder if any one can give me some hint on this.

Thank you!

Gonçalo

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Druk dit bericht a.u.b. niet onnodig af.
Please do not print this message unnecessarily.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Mao Jianfeng
Verzonden: maandag 24 augustus 2009 9:40
Aan: r-help@r-project.org
Onderwerp: [R] how to add 95% confidential interval as vertical lines to
x axein density plot

Dear R-help listers,

I want to add 95% confidential interval as vertical lines to x axe in
density plot. I have found the library(hdrcde) can do this work, but I
do not know how to handle functions of this library when I used ggplot2
to draw the graph.

Thank you in advance.

The data and codes followed:

# dummy data
factor<-rep(c("Alice","Jone","Mike"),each=100)
factor<-factor(factor)
traits1<-c(rnorm(100, mean=1, sd=1), rnorm(100, mean=3, sd=3),
rnorm(100, mean=6, sd=6)) traits2<-c(rnorm(100, mean=1, sd=1),
rnorm(100, mean=3, sd=3), rnorm(100, mean=6, sd=6))
traits3<-c(rnorm(100, mean=1, sd=1), rnorm(100, mean=3, sd=3),
rnorm(100, mean=6, sd=6)) traits4<-c(rnorm(100, mean=1, sd=1),
rnorm(100, mean=3, sd=3), rnorm(100, mean=6, sd=6))
traits5<-c(rnorm(100, mean=1, sd=1), rnorm(100, mean=3, sd=3),
rnorm(100, mean=6, sd=6)) traits6<-c(rnorm(100, mean=1, sd=1),
rnorm(100, mean=3, sd=3), rnorm(100, mean=6, sd=6))
traits7<-c(rnorm(100, mean=1, sd=1), rnorm(100, mean=3, sd=3),
rnorm(100, mean=6, sd=6)) traits8<-c(rnorm(100, mean=1, sd=1),
rnorm(100, mean=3, sd=3), rnorm(100, mean=6, sd=6))
traits9<-c(rnorm(100, mean=1, sd=1), rnorm(100, mean=3, sd=3),
rnorm(100, mean=6, sd=6)) traits10<-c(rnorm(100, mean=1, sd=1),
rnorm(100, mean=3, sd=3), rnorm(100, mean=6, sd=6))
traits11<-c(rnorm(100, mean=1, sd=1), rnorm(100, mean=3, sd=3),
rnorm(100, mean=6, sd=6)) traits12<-c(rnorm(100, mean=1, sd=1),
rnorm(100, mean=3, sd=3), rnorm(100, mean=6, sd=6))
traits13<-c(rnorm(100, mean=1, sd=1), rnorm(100, mean=3, sd=3),
rnorm(100, mean=6, sd=6)) traits14<-c(rnorm(100, mean=1, sd=1),
rnorm(100, mean=3, sd=3), rnorm(100, mean=6, sd=6))
traits15<-c(rnorm(100, mean=1, sd=1), rnorm(100, mean=3, sd=3),
rnorm(100, mean=6, sd=6)) traits16<-c(rnorm(100, mean=1, sd=1),
rnorm(100, mean=3, sd=3), rnorm(100, mean=6, sd=6))
traits17<-c(rnorm(100, mean=1, sd=1), rnorm(100, mean=3, sd=3),
rnorm(100, mean=6, sd=6)) traits18<-c(rnorm(100, mean=1, sd=1),
rnorm(100, mean=3, sd=3), rnorm(100, mean=6, sd=6))
traits19<-c(rnorm(100, mean=1, sd=1), rnorm(100, mean=3, sd=3),
rnorm(100, mean=6, sd=6)) traits20<-c(rnorm(100, mean=1, sd=1),
rnorm(100, mean=3, sd=3), rnorm(100, mean=6, sd=6))
traits21<-c(rnorm(100, mean=1, sd=1), rnorm(100, mean=3, sd=3),
rnorm(100, mean=6, sd=6))

myda<-data.frame(factor,traits1,traits2,traits3,traits4,traits5,traits6,
traits7,traits8,traits9,traits10,traits11,traits12,traits13,traits14,tra
its15,traits16,traits17,traits18,
traits19,traits20,traits21)


library(ggplot2)
d = melt(myda, id = "factor")

str(d)

pdf("test33.pdf")
p =
ggplot(data=d, mapping=aes(x=value, y=..density..)) +
facet_wrap(~variable)+ stat_density(aes(fill=factor), alpha=0.5, col=NA,
position = 'identity') + stat_density(aes(colour = factor), geom="path",
position = 'identity')
print(p)
dev.off()

Mao J-F

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Druk dit bericht a.u.b. niet onnodig af.
Please do not print this message unnecessarily.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R

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 plyr package

ddply(dataset, c("Date"), function(x){c(Sum_of_counts = sum(x$count))})
ddply(dataset, c("Date", "class"), function(x){c(Sum_of_counts =
sum(x$count))})

HTH,

Thierry



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Shaun Grannis
Verzonden: woensdag 26 augustus 2009 15:07
Aan: r-help@r-project.org
Onderwerp: [R] counting subgroup sums within a data frame

Hi,

I'm sure there's an easy approach to this issue, I'm just not seeing it.

I have a data frame of the following form:

  Date classsubclass   count
8/1/2009AX  1
8/1/2009BX  2
8/1/2009AY  9
8/1/2009BY  3
8/2/2009AX  1
8/2/2009BX  5
8/2/2009AY  4
8/2/2009BY  2
8/3/2009AX  6
8/3/2009BX  4
8/3/2009AY  3
8/3/2009BY  4
8/4/2009AX  1
8/4/2009BX  9
8/4/2009AY  3
8/4/2009BY  5
8/5/2009AX  3
8/5/2009BX  7
8/5/2009AY  2
8/5/2009BY  1

I would like to create a data frame of the sum the daily counts for,
say, class 'A', like so:


  Date sum_of_counts
8/1/2009   10
8/2/20095
8/3/20099
8/4/20094
8/5/20095

I ultimately would like to do sum of counts on all classes and
subclasses.  It seems that this is equivalent to a GROUP BY query in
SQL.

I'm sure this is possible in R. Any suggestions?

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Druk dit bericht a.u.b. niet onnodig af.
Please do not print this message unnecessarily.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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/site)*treatment, data = data)

HTH,

Thierry



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Robert Buitenwerf
Verzonden: woensdag 26 augustus 2009 16:24
Aan: R Help
Onderwerp: [R] lme: how to nest a random factor in a fixed factor?


Dear all,



I have an experimental setup in which a random variable is nested within
a fixed variable; however I have troubles specifying the correct LMM
with lme. I have searched the lists but haven't been able to find an
example like my setup, which I unfortunately need to get this stuff
right. Pinheiro & Bates is great but I still can't figure out how to do
it. 



My experimental setup was as follows:

100 measurements per treatment plot

2 treatment plots per site

4 sites: 2 in one area and 2 in another area



Both treatment and area are fixed factors,while site is random. I am
interested in the significance of the fixed effects,less in the
magnitude of the random effect. 



I have tried:



mod1 <- lme(response ~ area*treatment, data=data,random= ~1|site)

but now site is not nested in area...



mod2 <- lme(response ~ area*treatment, data=data,random= ~1|area/site)

but now area is both a fixed and a random variable, which doesn't seem
to make sense, plus I run out of df for treatment



mod3 <- lme(response ~ area*treatment, data=data,random= ~1| plot)

but here plots are not grouped according to site



I hope someone would be willing to help me, thank you in advance!



Robert Buitenwerf

Ecologist

South African Environmental Observation Network
_
[[elided Hotmail spam]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Druk dit bericht a.u.b. niet onnodig af.
Please do not print this message unnecessarily.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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, methodology 
and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens 
romunov
Verzonden: vrijdag 28 augustus 2009 16:58
Aan: Gabor Grothendieck
CC: r-help@r-project.org
Onderwerp: Re: [R] problem plotting with ggplot2

Hello Gabor,

your suggestion running R in vanilla mode was fruitful. I can plot at least 
bars. How would you proceed. How can I root out "bad" package or whatever is 
causing this?

Cheers,
Roman



On Fri, Aug 28, 2009 at 4:48 PM, Gabor Grothendieck  wrote:

> A few things to try.
>
> Try starting R using the --vanilla flag.  From the Windows command 
> line:
>
> rem change next line appropriately if needed cd \Program 
> Files\R\R-2.9.1\bin Rgui --vanilla
>
> and see if it still happens.If that does not help
> try reinstalling R and all packages.
>
>
> On Fri, Aug 28, 2009 at 10:20 AM, romunov wrote:
> > As far as I know, the packages are up to date. I have had identical
> problems
> > on 2.9.1 as well as on 2.8.1. I did a fresh install of 2.9.1 to no avail.
> > Here is my sessionInfo():
> >
> >> sessionInfo()
> > R version 2.9.1 (2009-06-26)
> > i386-pc-mingw32
> >
> > locale:
> >
> LC_COLLATE=Slovenian_Slovenia.1250;LC_CTYPE=Slovenian_Slovenia.1250;LC
> _MONETARY=Slovenian_Slovenia.1250;LC_NUMERIC=C;LC_TIME=Slovenian_Slove
> nia.1250
> >
> > attached base packages:
> > [1] stats graphics  grDevices utils datasets  grid  methods
> > [8] base
> >
> > other attached packages:
> > [1] ggplot2_0.8.3 reshape_0.8.3 plyr_0.1.9proto_0.3-8
> >
> > loaded via a namespace (and not attached):
> > [1] tools_2.9.1
> >
> > Cheers,
> > Roman
> >
> >
> >
> >
> > On Fri, Aug 28, 2009 at 10:05 AM, baptiste auguie < 
> > baptiste.aug...@googlemail.com> wrote:
> >
> >> Hi,
> >>
> >> Have you checked that you have the latest version of ggplot2 and plyr?
> >> Please post your sessionInfo()
> >>
> >> HTH,
> >>
> >> baptiste
> >>
> >> 2009/8/28 romunov 
> >>
> >>> Dear R-Help subsribers,
> >>>
> >>>  upon running into a wonderful ggplot2 package by accident, I 
> >>> abruptly encountered another problem. Almost every command run 
> >>> with ggplot2
> results
> >>> in some sort of error. The one below is far the most common one. 
> >>> Kind people from ggplot2 mailing list couldn't manage to solve the 
> >>> problem, so I'm re-posting it here to try my luck. I will 
> >>> recommend myself for any tips
> on
> >>> how to solve this, as I would really benefit from using this package.
> >>>
> >>>  > head(cebelice)
> >>>   time c2
> >>> 1 00:00  0
> >>> 2 00:15  0
> >>> 3 00:30  0
> >>> 4 00:45  0
> >>> 5 01:00  0
> >>> 6 01:15  0
> >>> > dim(cebelice)
> >>> [1] 96  2
> >>> > ggplot(cebelice, aes(x=time, y=c2)) + geom_histogram()
> >>> Error in all.vars(as.formula(.$facets)) :
> >>>  could not find function "as.formula"
> >>>
> >>>
> >>> This is straight from ggplot2 sample page for barplots:
> >>>
> >>> > c <- ggplot(mtcars, aes(factor(cyl))) c + geom_bar()
> >>> Error in get("transform", env = ., inherits = TRUE)(., ...) :
> >>>  attempt to apply non-function
> >>>
> >>>
> >>> Sincerely yours,
> >>>
> >>> Roman
> >>>
> >>>[[alternative HTML version deleted]]
> >>>
> >>> __
> >>> R-help@r-project.org mailing list
> >>> https://stat.ethz.ch/mailman/listinfo/r-help
> >>> PLEASE do read the posting guide
> >>> http://www.R-project.org/posting-guide.html
> >>> and provide commented, minimal, self-contained, reproducible code.
> >>>
> >>
> >>
> >>
> >> --
> >> _
> >>
> >> Baptiste Auguié
> >>
> >> School of Physics
> >> University of Exeter
> >> Stocker Road,
> >> Exeter, Devon,
> >> EX4 4QL, UK
> >>
> >> http://newton.ex.ac.uk/research/emag
> >> __
> >>
> >>
> >
> >[[alternative HTML version deleted]]
> >
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> >
>


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 for Nature and 
Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology 
and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens 
Gaspar Núñez
Verzonden: maandag 31 augustus 2009 17:08
Aan: r-help@r-project.org
Onderwerp: [R] help on ar(1)

Hi

i´m trying to run a modelo of the form

y(t) = b1 + b2x(t) + b3x(t) + u(t)

and i need to introduce an ar(1) into the equation can anyone tell me about a 
reference with an example

thanks again



--
Gaspar

[[alternative HTML version deleted]]


Druk dit bericht a.u.b. niet onnodig af.
Please do not print this message unnecessarily.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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(~V2)

HTH,

Thierry




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Gundala Viswanath
Verzonden: woensdag 2 september 2009 12:10
Aan: r-h...@stat.math.ethz.ch
Onderwerp: [R] Howto Superimpose Multiple Density Curves Into One Plot

I have a data that looks like this:
http://dpaste.com/88561/plain/

And I intend to create multiple density curve into one plot, where each
curve correspond to the unique ID.

I tried to use "sm" package, with this code, but without success.

__BEGIN__
library(sm)
dat <- read.table("mydat.txt");
plotfn <- ("~/Desktop/flowgram_superimposed.pdf");
pdf(plotfn);

sm.density.compare(dat$V1,dat$V2, xlab = "Flow Signal") colfill <-
c(2:10); legend(locator(1), levels(dat$V2), fill=colfill)

dev.off();
__END__

Please advice what's the right way to do it or if  there is alternative
way to do it?
I am trying to get this kind of figure:
http://img524.imageshack.us/img524/2736/testl.png


- G.V.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Druk dit bericht a.u.b. niet onnodig af.
Please do not print this message unnecessarily.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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

2009-09-02 Thread ONKELINX, Thierry
It looks like the data has other columnnames than the samplecode you provided.

Use colnames(dat) to get the columnnames. Replace V1 with the columnname of the 
values and V2 with the column name of the ID's.

HTH,

Thierry



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and 
Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology 
and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: Gundala Viswanath [mailto:gunda...@gmail.com] 
Verzonden: woensdag 2 september 2009 14:33
Aan: ONKELINX, Thierry
CC: r-h...@stat.math.ethz.ch
Onderwerp: Re: [R] Howto Superimpose Multiple Density Curves Into One Plot

Hi Thierry,

Thanks for the reply. I tried this:
> dat <-   read.table("http://dpaste.com/88561/plain/";)

But I got such error:

> ggplot(dat, aes(x = V1, colour = factor(V2))) + geom_density()
Error in density.default(data$x, adjust = adjust, kernel = kernel, weight = 
data$weight,  :
  need at least 2 points to select a bandwidth automatically
> ggplot(dat, aes(x = V1, fill = factor(V2))) + geom_density(alpha = 
> 0.2)
Error in density.default(data$x, adjust = adjust, kernel = kernel, weight = 
data$weight,  :
  need at least 2 points to select a bandwidth automatically
> ggplot(dat, aes(x = V1)) + geom_density() + facet_wrap(~V2)
Error: could not find function "facet_wrap"
>
> ggplot(dat, aes(x = V1, fill = factor(V2))) + geom_density(alpha = 
> 0.2)
Error in density.default(data$x, adjust = adjust, kernel = kernel, weight = 
data$weight,  :
  need at least 2 points to select a bandwidth automatically
> ggplot(dat, aes(x = V1)) + geom_density() + facet_wrap(~V2)
Error: could not find function "facet_wrap"

Maybe I miss something? What could possibly go wrong?

- Edward


On Wed, Sep 2, 2009 at 8:30 PM, ONKELINX, Thierry 
wrote:
> 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(~V2)
>
> HTH,
>
> Thierry
>
>
> --
> --
> 
> ir. Thierry Onkelinx
> Instituut voor natuur- en bosonderzoek / Research Institute for Nature 
> and Forest Cel biometrie, methodologie en kwaliteitszorg / Section 
> biometrics, methodology and quality assurance Gaverstraat 4 9500 
> Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be 
> www.inbo.be
>
> To call in the statistician after the experiment is done may be no 
> more than asking him to perform a post-mortem examination: he may be 
> able to say what the experiment died of.
> ~ Sir Ronald Aylmer Fisher
>
> The plural of anecdote is not data.
> ~ 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: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org]
> Namens Gundala Viswanath
> Verzonden: woensdag 2 september 2009 12:10
> Aan: r-h...@stat.math.ethz.ch
> Onderwerp: [R] Howto Superimpose Multiple Density Curves Into One Plot
>
> I have a data that looks like this:
> http://dpaste.com/88561/plain/
>
> And I intend to create multiple density curve into one plot, where 
> each curve correspond to the unique ID.
>
> I tried to use "sm" package, with this code, but without success.
>
> __BEGIN__
> library(sm)
> dat <- read.table("mydat.txt");
> plotfn <- ("~/Desktop/flowgram_superimposed.pdf");
> pdf(plotfn);
>
> sm.density.compare(dat$V1,dat$V2, xlab = "Flow Signal") colfill <- 
> c(2:10); legend(locator(1), levels(dat$V2), fill=colfill)
>
> dev.off();
> __END__
>
> Please advice what's the right way to do it or if  there is 
> alternative way to do it?
> I am trying to get this kind of figure:
> http://img524.imageshack.us/img524/2736/

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

2009-09-02 Thread ONKELINX, Thierry
My orginal code should work with those colnames. Note that you must not use 
"variable.name" but just variable.name.

I guess that somethings wrong with your dataframe. What does str(dat) and 
summary(dat) gives?

Thierry



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and 
Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology 
and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: Gundala Viswanath [mailto:gunda...@gmail.com] 
Verzonden: woensdag 2 september 2009 14:47
Aan: ONKELINX, Thierry
CC: r-h...@stat.math.ethz.ch
Onderwerp: Re: [R] Howto Superimpose Multiple Density Curves Into One Plot

Hi Thierry,

I am sorry for coming back to you.
Maybe I misunderstood you, but I got this:

> colnames(dat)
[1] "V1" "V2"
> ggplot(dat, aes(x = "V1", colour = factor("V2"))) + geom_density()
Error in data.frame(..., check.names = FALSE) :
  arguments imply differing number of rows: 1, 200

> ggplot(dat, aes(x = V1, colour = factor(V2))) + geom_density()
Error in density.default(data$x, adjust = adjust, kernel = kernel, weight = 
data$weight,  :
  need at least 2 points to select a bandwidth automatically


- G.V

On Wed, Sep 2, 2009 at 9:35 PM, ONKELINX, Thierry 
wrote:
> It looks like the data has other columnnames than the samplecode you provided.
>
> Use colnames(dat) to get the columnnames. Replace V1 with the columnname of 
> the values and V2 with the column name of the ID's.
>
> HTH,
>
> Thierry
>
>
> --
> --
> ir. Thierry Onkelinx
> Instituut voor natuur- en bosonderzoek / Research Institute for Nature 
> and Forest Cel biometrie, methodologie en kwaliteitszorg / Section 
> biometrics, methodology and quality assurance Gaverstraat 4 9500 
> Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be 
> www.inbo.be
>
> To call in the statistician after the experiment is done may be no more than 
> asking him to perform a post-mortem examination: he may be able to say what 
> the experiment died of.
> ~ Sir Ronald Aylmer Fisher
>
> The plural of anecdote is not data.
> ~ 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: Gundala Viswanath [mailto:gunda...@gmail.com]
> Verzonden: woensdag 2 september 2009 14:33
> Aan: ONKELINX, Thierry
> CC: r-h...@stat.math.ethz.ch
> Onderwerp: Re: [R] Howto Superimpose Multiple Density Curves Into One 
> Plot
>
> Hi Thierry,
>
> Thanks for the reply. I tried this:
>> dat <-   read.table("http://dpaste.com/88561/plain/";)
>
> But I got such error:
>
>> ggplot(dat, aes(x = V1, colour = factor(V2))) + geom_density()
> Error in density.default(data$x, adjust = adjust, kernel = kernel, weight = 
> data$weight,  :
>  need at least 2 points to select a bandwidth automatically
>> ggplot(dat, aes(x = V1, fill = factor(V2))) + geom_density(alpha =
>> 0.2)
> Error in density.default(data$x, adjust = adjust, kernel = kernel, weight = 
> data$weight,  :
>  need at least 2 points to select a bandwidth automatically
>> ggplot(dat, aes(x = V1)) + geom_density() + facet_wrap(~V2)
> Error: could not find function "facet_wrap"
>>
>> ggplot(dat, aes(x = V1, fill = factor(V2))) + geom_density(alpha =
>> 0.2)
> Error in density.default(data$x, adjust = adjust, kernel = kernel, weight = 
> data$weight,  :
>  need at least 2 points to select a bandwidth automatically
>> ggplot(dat, aes(x = V1)) + geom_density() + facet_wrap(~V2)
> Error: could not find function "facet_wrap"
>
> Maybe I miss something? What could possibly go wrong?
>
> - Edward
>
>
> On Wed, Sep 2, 2009 at 8:30 PM, ONKELINX, Thierry 
> wrote:
>> 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

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

2009-09-02 Thread ONKELINX, Thierry
This code work without errors for me.

library(ggplot2)
dat <- read.table("http://dpaste.com/88561/plain/";)
ggplot(dat, aes(x = V1, colour = factor(V2))) + geom_density()
ggplot(dat, aes(x = V1, fill = factor(V2))) + geom_density(alpha = 0.5)

Have a look at table(dat$V2). Some classes have only 1 or 2 values, which in 
not enough to estimate the density. Therefore you get an error with 

ggplot(dat, aes(x = V1)) + geom_density() + facet_wrap(~V2)

Subsetting the data solves the problem

ggplot(subset(dat, V2 <= 2), aes(x = V1)) + geom_density() + facet_wrap(~V2)

HTH,

Thierry



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and 
Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology 
and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: Gundala Viswanath [mailto:gunda...@gmail.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 ...
 $ V2: int  1 0 1 0 0 1 0 1 0 0 ...
> summary(dat)
   V1   V2
 Min.   :0.   Min.   :0.000
 1st Qu.:0.1600   1st Qu.:0.000
 Median :0.2950   Median :0.000
 Mean   :0.7108   Mean   :0.635
 3rd Qu.:1.0600   3rd Qu.:1.000
 Max.   :5.4400   Max.   :5.000


- G.V.

On Wed, Sep 2, 2009 at 9:50 PM, ONKELINX, Thierry 
wrote:
> My orginal code should work with those colnames. Note that you must not use 
> "variable.name" but just variable.name.
>
> I guess that somethings wrong with your dataframe. What does str(dat) and 
> summary(dat) gives?
>
> Thierry
>
>
> --
> --
> ir. Thierry Onkelinx
> Instituut voor natuur- en bosonderzoek / Research Institute for Nature 
> and Forest Cel biometrie, methodologie en kwaliteitszorg / Section 
> biometrics, methodology and quality assurance Gaverstraat 4 9500 
> Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be 
> www.inbo.be
>
> To call in the statistician after the experiment is done may be no more than 
> asking him to perform a post-mortem examination: he may be able to say what 
> the experiment died of.
> ~ Sir Ronald Aylmer Fisher
>
> The plural of anecdote is not data.
> ~ 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: Gundala Viswanath [mailto:gunda...@gmail.com]
> Verzonden: woensdag 2 september 2009 14:47
> Aan: ONKELINX, Thierry
> CC: r-h...@stat.math.ethz.ch
> Onderwerp: Re: [R] Howto Superimpose Multiple Density Curves Into One 
> Plot
>
> Hi Thierry,
>
> I am sorry for coming back to you.
> Maybe I misunderstood you, but I got this:
>
>> colnames(dat)
> [1] "V1" "V2"
>> ggplot(dat, aes(x = "V1", colour = factor("V2"))) + geom_density()
> Error in data.frame(..., check.names = FALSE) :
>  arguments imply differing number of rows: 1, 200
>
>> ggplot(dat, aes(x = V1, colour = factor(V2))) + geom_density()
> Error in density.default(data$x, adjust = adjust, kernel = kernel, weight = 
> data$weight,  :
>  need at least 2 points to select a bandwidth automatically
>
>
> - G.V
>
> On Wed, Sep 2, 2009 at 9:35 PM, ONKELINX, Thierry 
> wrote:
>> It looks like the data has other columnnames than the samplecode you 
>> provided.
>>
>> Use colnames(dat) to get the columnnames. Replace V1 with the columnname of 
>> the values and V2 with the column name of the ID's.
>>
>> HTH,
>>
>> Thierry
>>
>>
>> -
>> -
>> --
>> ir. Thierry Onkelinx
>> Instituut voor natuur- en bosonderzoek / Research Institute for 
>> Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / 
>> Section biometrics, methodology a

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

2009-09-02 Thread ONKELINX, Thierry
I'm using the latest version: 0.8.3 on R 2.9.2 



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and 
Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology 
and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: 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:  2008-10-03

Somehow it can't recognize facet_wrap()

> ggplot(subset(dat, V2 <= 2), aes(x = V1)) + geom_density() + 
> facet_wrap(~V2)
Error: could not find function "facet_wrap"
>

- G.V.

On Wed, Sep 2, 2009 at 10:01 PM, ONKELINX, Thierry 
wrote:
> This code work without errors for me.
>
> library(ggplot2)
> dat <- read.table("http://dpaste.com/88561/plain/";)
> ggplot(dat, aes(x = V1, colour = factor(V2))) + geom_density() 
> ggplot(dat, aes(x = V1, fill = factor(V2))) + geom_density(alpha = 
> 0.5)
>
> Have a look at table(dat$V2). Some classes have only 1 or 2 values, 
> which in not enough to estimate the density. Therefore you get an 
> error with
>
> ggplot(dat, aes(x = V1)) + geom_density() + facet_wrap(~V2)
>
> Subsetting the data solves the problem
>
> ggplot(subset(dat, V2 <= 2), aes(x = V1)) + geom_density() + 
> facet_wrap(~V2)
>
> HTH,
>
> Thierry
>
>
> --
> --
> ir. Thierry Onkelinx
> Instituut voor natuur- en bosonderzoek / Research Institute for Nature 
> and Forest Cel biometrie, methodologie en kwaliteitszorg / Section 
> biometrics, methodology and quality assurance Gaverstraat 4 9500 
> Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be 
> www.inbo.be
>
> To call in the statistician after the experiment is done may be no more than 
> asking him to perform a post-mortem examination: he may be able to say what 
> the experiment died of.
> ~ Sir Ronald Aylmer Fisher
>
> The plural of anecdote is not data.
> ~ 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: Gundala Viswanath [mailto:gunda...@gmail.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 ...
>  $ V2: int  1 0 1 0 0 1 0 1 0 0 ...
>> summary(dat)
>       V1               V2
>  Min.   :0.   Min.   :0.000
>  1st Qu.:0.1600   1st Qu.:0.000
>  Median :0.2950   Median :0.000
>  Mean   :0.7108   Mean   :0.635
>  3rd Qu.:1.0600   3rd Qu.:1.000
>  Max.   :5.4400   Max.   :5.000
>
>
> - G.V.
>
> On Wed, Sep 2, 2009 at 9:50 PM, ONKELINX, Thierry 
> wrote:
>> My orginal code should work with those colnames. Note that you must not use 
>> "variable.name" but just variable.name.
>>
>> I guess that somethings wrong with your dataframe. What does str(dat) and 
>> summary(dat) gives?
>>
>> Thierry
>>
>>
>> -
>> -
>> --
>> ir. Thierry Onkelinx
>> Instituut voor natuur- en bosonderzoek / Research Institute for 
>> Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / 
>> Section biometrics, methodology and quality assurance Gaverstraat 4 
>> 9500 Geraardsbergen Belgium tel. + 32 54/436 185 
>> thierry.onkel...@inbo.be www.inbo.be
>>
>> To call in the statistician after the experiment is done may be no more than 
>> asking him to perform a post-mortem examination: he may be able to say what 
>> the experiment died of.
>> ~ Sir Ronald Aylmer Fisher
>>

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(plyr)
ddply(CombinedData, "TimePoint", colMeans) 


#another option
library(reshape)
recast(CombinedData, TimePoint + variable ~ ., id.var = TimePoint, fun =
mean)

HTH,

Thierry



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Ed Long
Verzonden: woensdag 2 september 2009 14:55
Aan: r-help@r-project.org
Onderwerp: [R] Average over data sets

Hello,

I have a number of files output1.dat, output2.dat, ... , output20.dat,
each of which monitors several variables over a fixed number of
timepoints. From this I want to create a data frame which contains the
mean value between all files, for each timepoint and each variable.

The code below works, but it seems like I should be able to do the
second part without a for loop. I played with sapply(myList, mean), but
that seems to take the mean between time points and files, rather than
just between files.

#Number of files to calculate mean value between numberOfRuns = 20;
myList = list(); for (i in 1:numberOfRuns) {
#Read in file
fileName = paste("output", i, ".dat", sep="");
myData = read.table(fileName, header=TRUE);
#Append data frame to list
myList[[i]] = myData;
}

#Create variable to store data means
myAverage = myList[[1]]/numberOfRuns;

for (i in 2:numberOfRuns) {
myAverage = myAverage + myList[[i]]/numberOfRuns; }

Is a list of data frames a sensible structure to store this or should I
use an array?

Any pointers gratefully received.

Ed Long

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Druk dit bericht a.u.b. niet onnodig af.
Please do not print this message unnecessarily.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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)))
) + 
scale_x_continuous("Miles per gallon") + 
opts(title = "Histogram with Normal Curve") 

Or with a bit more effort to get the counts.

ggplot(mtcars, aes(x = mpg)) + 
geom_histogram(fill = "red") + 
stat_function(
fun = function(x, mean, sd, n){
n * dnorm(x = x, mean = mean, sd = sd)
}, 
args = with(mtcars, c(mean = mean(mpg), sd = sd(mpg), n
= length(mpg)))
) + 
scale_x_continuous("Miles per gallon") + 
opts(title = "Histogram with Normal Curve")

HTH

Thierry

PS Have a look at the ggplot2 website (http://had.co.nz/ggplot2/).
You'll find tons of examples with the code the generate them.



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Gundala Viswanath
Verzonden: woensdag 2 september 2009 16:37
Aan: r-h...@stat.math.ethz.ch
Onderwerp: [R] Howto fit normal curve into histogram using GGPLOT2

Currently, I am doing it this way.

x <- mtcars$mpg
h<-hist(x, breaks=10, col="red", xlab="Miles Per Gallon",
   main="Histogram with Normal Curve")
xfit<-seq(min(x),max(x),length=40)
yfit<-dnorm(xfit,mean=mean(x),sd=sd(x))
yfit <- yfit*diff(h$mids[1:2])*length(x) lines(xfit, yfit, col="blue",
lwd=2)

But since, ggplot2  has more appealing graphics, I wonder how can it be
done.

-G.V.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Druk dit bericht a.u.b. niet onnodig af.
Please do not print this message unnecessarily.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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))
   user  system elapsed 
   0.330.000.33 

 
HTH,

Thierry


ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and 
Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology 
and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens 
andrew
Verzonden: vrijdag 4 september 2009 4:24
Aan: r-help@r-project.org
Onderwerp: Re: [R] Easy way to get top 2 items from vector

it is speedier to use sort than a combination of [] and order:

N<- 100
x <- runif(N)
> system.time(x[order(x)[c(N-1,N)]])
   user  system elapsed
   1.030.001.03
> system.time(sort(x)[c(N-1,N)])
   user  system elapsed
   0.280.000.28



On Sep 4, 11:17 am, Noah Silverman  wrote:
> Phil,
>
> That's perfect.  (For my application, I've never seen a tie.  While 
> possible, the likelihood is almost none.)
>
> Thanks!
>
> --
> Noah
>
> On 9/3/09 4:29 PM, Phil Spector wrote:
>
>
>
> > Noah -
> >    max(x[-which.max(x)]  will give you the second largest value, but 
> > it doesn't handle ties.
> >    x[order(x,decreasing=TRUE)[n]]  will give you the nth largest 
> > value, with the same caveat regarding ties.  For example, 
> > x[order(x,decreasing=TRUE)[1:3]] will give you the three largest 
> > values.
>
> >                     - Phil Spector
> >                      Statistical Computing Facility
> >                      Department of Statistics
> >                      UC Berkeley
> >                      spec...@stat.berkeley.edu
>
> > On Thu, 3 Sep 2009, Noah Silverman wrote:
>
> >> Hi,
>
> >> I use the max function often to find the top value from a matrix or 
> >> column of a data.frame.
>
> >> Now I'm looking to find the top 2 (or three) values from my data.
>
> >> I know that I could sort the list and then access the first two 
> >> items, but that seems like the "long way".  Is there some way to 
> >> access "max_2" or similar?
>
> >> Thanks!
>
> >> --
> >> Noah
>
> >> __
> >> r-h...@r-project.org mailing list
> >>https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide
> >>http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
>
>         [[alternative HTML version deleted]]
>
> __
> r-h...@r-project.org mailing 
> listhttps://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting 
> guidehttp://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Druk dit bericht a.u.b. niet onnodig af.
Please do not print this message unnecessarily.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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()




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens r2L
Verzonden: vrijdag 4 september 2009 13:04
Aan: r-help@r-project.org
Onderwerp: [R] plot positive predictive values

Hi,

I'm trying to fit a smooth line in a plot(y ~ x) graph.

x is continuous variable
y is a proportion of success in sub-samples, 0 <= y <= 1, from a Monte
Carlo simulation.

For each x there may be several y-values from different runs. Each run
produces several sub-samples, where "0" mean no success in any sub-
sample, "0.5" means success in half of the sub-samples, and "1" means
success in all sub-samples, and so on.

As x is increased, the y-value approaches 1, and may reach it; it can,
of course never bypass it.

>From my understanding of the data at hand, each point along the x-axis
has its own beta-distribution of the y-values, then as 0 <= y <= 1,
which shift gradually through distributions similar to

curve(dbeta(x,2, 2), add=F, col="red", xlim=c(0,1), ylim=c(0,4))
curve(dbeta(x,4, 2), add=T, col="red", xlim=c(0,1), ylim=c(0,4))
curve(dbeta(x,4, 1), add=T, col="red", xlim=c(0,1), ylim=c(0,4))
curve(dbeta(x,4, .1), add=T, col="red", xlim=c(0,1), ylim=c(0,4))

as x increases.

If I plot my data using boxplot it shows also very nicely how the the
data approaches 1 and variation decreases. However, my x-axis data are
continuous.

Is there a way to produce a regression line which would smoothly follow
that trend?

It may well be easier than I believe, but my head is at a full-stop...

Thanks for any help!

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Druk dit bericht a.u.b. niet onnodig af.
Please do not print this message unnecessarily.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Leo Guelman
Verzonden: vrijdag 4 september 2009 13:14
Aan: r-help
Onderwerp: [R] Linear Contrasts in GLM - Query

Hi,

Is there a way I can specify linear contrasts in glm? I'm looking for
something equivalent to SAS' contrast statement.

I'd like to do the following, suppose I have a categorical input with 4
levels (a,b,c,d), I'd like to test something like: (i)  a+b=c+d, (ii)
a=b,
(iii) a=b+d, etc...

Thanks in advance for your help!

Leo.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Druk dit bericht a.u.b. niet onnodig af.
Please do not print this message unnecessarily.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Wen Huang
Verzonden: zondag 6 september 2009 17:49
Aan: r-help@r-project.org
Onderwerp: [R] linear mixed model question

Hello,

I wanted to fit a linear mixed model to a data that is similar in terms
of design to the 'Machines' data in 'nlme' package except that each
worker (with triplicates) only operates one machine. I created a subset
of observations from 'Machines' data such that it looks the same as the
data I wanted to fit the model with (see code below).

I fitted a model in which 'Machine' was a fixed effect and 'Worker'  
was random (intercept), which ran perfectly. Then I decided to
complicate the model a little bit by fitting 'Worker' within 'Machine',
which was saying variation among workers was nested within each machine.
The model could be fitted by 'lme', but when I tried to get confidence
intervals by 'intervals(fm2)' it gave me an error:

Error in intervals.lme(fm2) :
   Cannot get confidence intervals on var-cov components: Non-positive
definite approximate variance-covariance

I am wondering if this is because it is impossible to fit a model like
'fm2' or there is some other reasons?

Thanks a lot!

Wen

#

library(nlme)
data(Machines)
new.data = Machines[c(1:6, 25:30, 49:54), ]
fm1 = lme(score ~ Machine, random = ~1|Worker, data = new.data)
fm1
fm2 = lme(score ~ Machine, random = ~Machine-1|Worker, data = new.data)
fm2
intervals(fm2)

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Druk dit bericht a.u.b. niet onnodig af.
Please do not print this message unnecessarily.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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)) + geom_line()

HTH,

Thierry


ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and 
Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology 
and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens 
Rafael Moral
Verzonden: dinsdag 8 september 2009 16:45
Aan: r-help
Onderwerp: [R] barplot with lines instead of bars

Dear useRs,

I want to plot the following barplot with lines instead of bars. Is there a way?

data <- data.frame(cbind(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)))
d <- t(data[,2:4])
barplot(d, beside=TRUE)

Regards,
Rafael.


  

[[elided Yahoo spam]]

[[alternative HTML version deleted]]


Druk dit bericht a.u.b. niet onnodig af.
Please do not print this message unnecessarily.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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"

Empirical <- rbind(vgIso, vgAniso)
ggplot(Empirical, aes(x = dist, y = gamma, weight = np / (dist ^ 2),
colour = id, shape = factor(dir.hor))) + geom_smooth() + geom_point()
ggplot(Empirical, aes(x = dist, y = gamma, weight = np / (dist ^ 2),
colour = id)) + geom_smooth() + geom_point() + facet_wrap(~dir.hor)

newVgIso <- merge(vgIso[, -4], expand.grid(dist = vgIso$dist, dir.hor =
unique(vgAniso$dir.hor)))
Empirical2 <- rbind(newVgIso, vgAniso)
ggplot(Empirical2, aes(x = dist, y = gamma, weight = np / (dist ^ 2),
colour = id)) + geom_smooth() + geom_point() + facet_wrap(~dir.hor)

HTH,

Thierry 




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens bevenro
Verzonden: dinsdag 8 september 2009 20:23
Aan: r-help@r-project.org
Onderwerp: [R] gstat---2 basic plot questions


Hi all--

I'm new to R, statistics and programming, so sorry if this is a really
basic question!

I have plotted a directional variogram, and I want to

a. overlay the omni-directional line over each directional panel

b. display the directional variograms in a single panel with a legend
that associated each line to each degree measurement.

The line I'm using is

plot(DirectionalVar,multipanel=FALSE,auto.key=TRUE)

this gives me the single panel, but I don't know how to bind the legend
to the lines (it's tricky to tell which is which) or to overlay the
omni-directional line.

Just looking to keep this as simple as I can--

Thanks!

Steve
--
View this message in context:
http://www.nabble.com/gstat---2-basic-plot-questions-tp25351553p25351553
.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Druk dit bericht a.u.b. niet onnodig af.
Please do not print this message unnecessarily.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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="crossbar",
fun.data="mean_sdl", mult=1) + geom_ribbon(data = RibbonData, aes(group
= 1, ymin = ymin, ymax = ymax), fill=alpha("blue", 1/10))

HTH,

Thierry 




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Sock Cheng
Verzonden: maandag 14 september 2009 20:58
Aan: r-help@r-project.org
Onderwerp: [R] ggplot, ribbon not showing up properly

Hi,

I'm trying to plot a longitudinal data set, using ggplot and adding some
summary info (eg. mean, 1 sd bounds) using geom=ribbon.  The summary
info is based on a subset of the original data (eg. less an outlier). 
But I'm having trouble getting the ribbons to show up correctly.  It's
probably something obvious that I'm missing as a novice at ggplot2, and
any help is much appreciated!

Here's a simple example.  I tried several things.  
- if I use geom=crossbar, everything is ok
- if Day is set as rep(c(1,2,3,8,9), each=8), then everything is ok,
which makes me wonder if the problem has to do with the ordering of Day?
 Day is supposed to be numeric.  

Thanks!
Sock

### Example data.  Ran using R version 2.9.2, ggplot2 version 0.8.3 ###

set.seed(13)

Day <- rep(c(1, 2, 3, 8, 20), each=8)  
# The plot is ok if Day <- rep(c(1,2,3,8,9), each=8)

ID <- rep(LETTERS[1:8], 5)
Y <- rnorm(length(Day), 100, 5)
dat <- data.frame(Day=Day, ID=ID, Y=Y)

 # outlier
dat$Y[dat$ID=="A" & dat$Day==8] <- 150 
dat.less <- dat[!(dat$ID=="A" & dat$Day==8),]   

# Longitudinal data plot.  Obs for each subject is connected by a line
over time

p <- ggplot(dat, aes(x=Day, y=Y, group=ID)) +
scale_x_continuous(breaks=sort(unique(dat$Day))) +
geom_line(colour=alpha("blue", 5/10))

# Adding mean, 1 sd bounds using crossbar geom is ok.  But the same info
using ribbon geom doesn't work. 

p + stat_summary(data=dat.less, aes(group=1), geom="crossbar",
fun.data="mean_sdl", mult=1) + stat_summary(data=dat.less, aes(group=1),
geom="ribbon", fun.data="mean_sdl", mult=1, fill=alpha("blue", 1/10))

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Druk dit bericht a.u.b. niet onnodig af.
Please do not print this message unnecessarily.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens premmad
Verzonden: woensdag 23 september 2009 10:56
Aan: r-help@r-project.org
Onderwerp: Re: [R] use of class variable in r as in Proc means of sas


Thanks for the help.I got the required quantiles by altering ur code as
follows 

qfu<-function(x,digits=3,sci=F,...)
{c(q=quantile(x,probs=c(5,90)/100))
}
and my result of the R system is different from my sas system output for
the same function  .could anyone help me in this and what is the reason
for difference in results .I have attached both outputs R output:
zip price.q.5%  price.q.90%
1 6   567000.0  567000
2 60001   709184.4  390626852
3 60002 20349692.4  358154046
4 60003 49847874.0  49847874
5 60004   469447.9  3972289
6 60005  5431407.0  88118012
7 60006 23457082.6  341022805

SAS output:
 zipObs5th Ptcl   90th Pctl  
   
 6  1   567000.00   567000.00  


 60001  3   478654.00   487587575  


60002  2   478848.00   397895735  


60003  1 49847874.00 49847874.00  


60004  3   467648.00  4843949.00  


60005  2   567489.00 97845848.00  


60006  2  4776746.00   378383478
I have already checked that SAS and SPSS produces the same output.Do i'm
missing anything when using the function quantile
--
View this message in context:
http://www.nabble.com/use-of-class-variable-in-r-as-in-Proc-means-of-sas
-tp25530654p25531047.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Druk dit bericht a.u.b. niet onnodig af.
Please do not print this message unnecessarily.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 want to add a correlation structure:
lme(Y ~ Year, random = ~1|Department/Person, correlation =
CorAR1(form~Year))

HTH,

Thierry

PS R-sig-mixed-models is a better list for questions on longitudinal
data

@BOOK{PinheiroBates2000,
  title = {Mixed-Effects Models in {S} and {S-Plus}},
  publisher = {Springer},
  year = {2000},
  author = {Pinheiro, Jose C. and Bates, Douglas M.},
  note = {{ISBN 0-387-98957-0}},
  abstract = {A comprehensive guide to the use of the `nlme' package for
linear
and nonlinear mixed-effects models.},
  orderinfo = {springer.txt},
  publisherurl =
{http://www.springeronline.com/sgw/cda/frontpage/0,11855,4-10129-22-2102
822-0,00.html?changeHeader=true}
}



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie & Kwaliteitszorg
Gaverstraat 4
9500 Geraardsbergen
Belgium

Research Institute for Nature and Forest
team Biometrics & Quality Assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium

tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] Namens denis.ay...@unibas.ch
> Verzonden: dinsdag 23 februari 2010 9:27
> Aan: r-help@r-project.org
> Onderwerp: [R] Longitudinal analysis: contrasting time points
> 
> Hi everyone
> 
> I have the following situation:
> 
> In a longitudinal study, subjects fill out a questionnaire 
> every year (repeated measurements over time). Also, the
> subjects are nested within departments. There is an 
> intervention going on over time. The outcome variable is 
> continuous. Now I'd like to analyse two things:
> 
> 1. Is there a significant change over time? I think this is 
> done by a mixed-effects model with time as an independent 
> variable (also called growth-curves according to Jos W.R. Twisk 2006).
> 
> 2. I want to build contrasts between the years (i.e., time 
> points). Thus, I'd like to know which years are different 
> from each other. Normally, I would do an ANOVA with a 
> TukeyHSD-posthoc test, but I'm not sure how to do this with 
> repeated measurements over time and a nested design. Could 
> anybody help me on this?
> 
> Thanks for any help.
> 
> Regards,
> Denis Aydin
> 
> 
> References:
> 
> Applied Multilevel Analysis: A Practical Guide. Jos WR Twisk. 
> Cambridge University Press, UK 2006
> 
> --
> 
> This email and any files transmitted with it are 
> confide...{{dropped:8}}
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

Druk dit bericht a.u.b. niet onnodig af.
Please do not print this message unnecessarily.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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  90  90  90  94  94  94  94  94  94  94  94  94  94  98
  [19]  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98  98 102 102
  [37] 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102 102
  [55] 102 102 102 102 102 102 106 106 106 106 106 106 106 106 106 106 106 106
  [73] 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106
  [91] 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106 106
 [109] 106 106 106 106 106 106 106 106 106 106 106 106 110 110 110 110 110 110
 [127] 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110
 [145] 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110
 [163] 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110
 [181] 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110
 [199] 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 114 114
 [217] 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114
 [235] 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114
 [253] 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114
 [271] 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114
 [289] 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114
 [307] 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114
 [325] 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114 114
 [343] 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118
 [361] 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118
 [379] 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118
 [397] 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118
 [415] 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118
 [433] 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118
 [451] 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118 118
 [469] 118 118 118 118 118 118 118 118 118 118 118 122 122 122 122 122 122 122
 [487] 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122
 [505] 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122
 [523] 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122
 [541] 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122
 [559] 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122
 [577] 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122 122
 [595] 122 122 122 122 122 122 122 122 122 122 122 122 122 126 126 126 126 126
 [613] 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126
 [631] 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126
 [649] 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126
 [667] 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126 126
 [685] 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130
 [703] 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130
 [721] 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130 130
 [739] 130 130 130 130 130 130 130 130 130 130 130 130 130 130 134 134 134 134
 [757] 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134
 [775] 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134
 [793] 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134 134
 [811] 134 134 134 134 134 134 134 138 138 138 138 138 138 138 138 138 138 138
 [829] 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138
 [847] 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138 138
 [865] 138 138 138 138 138 138 138 138 138 138 138 138 138 142 142 142 142 142
 [883] 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142
 [901] 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142 142
 [919] 142 142 142 142 142 142 142 142 142 142 146 146 146 146 146 146 146 146
 [937] 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146 146
 [955] 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 150 154
 [973] 154 154 154 154 154 154 154 154 158 158 158 158 158 162 162 166 166 166
 [991] 170 170 170 170 170 170 170 174 174 174


ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie & Kwaliteitszorg
Gaverstraat 4
9500 Geraardsbergen
Belgium

Research Institute for Nature and Forest
team Biometrics & Quality Assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium

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.026))
ggplot(df, aes(x=trt, y=coon, fill = group, ymax = coon + se, ymin =
coon - se)) + geom_bar(position = "dodge", stat="identity") +
geom_errorbar(position = "dodge")




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie & Kwaliteitszorg
Gaverstraat 4
9500 Geraardsbergen
Belgium

Research Institute for Nature and Forest
team Biometrics & Quality Assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium

tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] Namens hpdutra
> Verzonden: vrijdag 12 maart 2010 2:16
> Aan: r-help@r-project.org
> Onderwerp: [R] simple plot in ggplot2, wrong error bars
> 
> 
> I was wondering if anyone  could help me with this, simple problem. 
> 
> I am essentially following the example on Hadley's  webpage
> (http://had.co.nz/ggplot2/geom_errorbar.html), but it still 
> doesn't make any
> sense to me. 
> 
> 
> 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.026))
>  limits <- aes(ymax = coon + se, ymin=coon - se)
>  p<-ggplot(df, aes(fill=group, y=coon, x=trt))
> p+geom_bar(position="dodge",stat="identity")
> dodge <- position_dodge(width=0.9)
> > p + geom_bar(position="dodge") + geom_errorbar(limits,
> position="dodge",
> > width=0.5)
> 
> as you noticed the code above gets the error bars in the 
> wrong columns. 
> So I used the code below (I replaced position_dodge w/ a 
> negative value and
> geom_errorbarr with dodge no quote marks)
> 
> 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.026))
> limits <- aes(ymax = coon + se, ymin=coon - se)
> p<-ggplot(df, aes(fill=group, y=coon, x=trt))
> p+geom_bar(position="dodge",stat="identity")
> dodge <- position_dodge(width=-0.9)
> > p + geom_bar(position="dodge") + geom_errorbar(limits,
> position=dodge,
> > width=0.5)
> 
> 
> Why do I need to use negative values to get the right 
> errorbar structure,
> why do I need use doge without quote marks?
> Thanks
> 
> Beto
> 
> 
> 
> -- 
> View this message in context: 
> http://n4.nabble.com/simple-plot-in-ggplot2-wrong-error-bars-t
> p1589994p1589994.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

Druk dit bericht a.u.b. niet onnodig af.
Please do not print this message unnecessarily.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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
Gaverstraat 4
9500 Geraardsbergen
Belgium

Research Institute for Nature and Forest
team Biometrics & Quality Assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium

tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] Namens Paul Johnson
> Verzonden: donderdag 18 maart 2010 5:54
> Aan: R-help
> Onderwerp: [R] Care to share an R presentation?
> 
> The R movement is picking up steam in the center of America.  
> People that ignored my R-enthusiasm 10 years ago are now 
> calling me up asking for presentations.  I need to make a 2  
> hour presentation to a collection of faculty and grad
> students who might like to use R. I don't want to make it 
> seem too complicated (as I often do), but I don't want to 
> mislead them to think it will be easy.
> 
> I expect other r-help readers have been in this same 
> situation.  I have a recollection (5, 6 years ago) that one 
> of the R leaders had a slideshow for this exact purpose.  But 
> I can't find it now. There is a R-help similar request and 
> both John Fox and  Deepayan Sarkar offered links to their 
> materials.  However, the links aren't valid anymore.
> 
> If I don't find a pre-existing example to work from, I'll 
> slap together a Beamer/Sweave presentation and post it where 
> future speech givers can get it.
> 
> --
> Paul E. Johnson
> Professor, Political Science
> 1541 Lilac Lane, Room 504
> University of Kansas
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

Druk dit bericht a.u.b. niet onnodig af.
Please do not print this message unnecessarily.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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,

Thierry

PS The R-SIG-Mixed models is a more appropriate list for this kind of
questions.




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Daryl Morris
Verzonden: dinsdag 30 juni 2009 8:17
Aan: r-help@r-project.org
Onderwerp: [R] lmer (or lme) with heteroscedasticity

Hello,

I'm trying to fit a mixed-effects model with a single binary predictor
(case/control status in my case), a random intercept (e.g. dependent on
radiologist) and also a random slope (a per-radiologist difference
between cases and controls).

I know how to do that, but what I don't know how to do is both of (1)
allowing the variance to be different for cases and controls (2) forcing
the random effects to be independent

By "both", I mean:
(1) Using lme (from nlme library) I know how to use varGroup as
described in Pinheiro & Bates chapter 5, but in that library, I don't
know how to force the random effects to be independent.
(2) Using lmer (from lme4 library) I can force the random effects to be
independent (using a description published by Bates in the R magazine in
2005) but I don't know how to allow the variance to depend on group.

To be clear, the model I wan to fit is:

Y_{ij} ~ beta_0 + beta_1*disease_{ij} + b_i 0 + b_i1*disease_{ij} +
error_{ij} where b_i0 and b_i1 are independent Normal where error_{ij} =
Normal(0, sd_case) if disease_{ij}= 1 error_{ij} = Normal(0, sd_control)
if disease_{ij}= 2 i is an indicator of radiologist... a single
radiologist does multiple cases and multiple controls.

Thanks, Daryl

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Andriy Fetsun
Verzonden: donderdag 2 juli 2009 12:48
Aan: r-help@r-project.org
Onderwerp: [R] (no subject)

Hi,

Could you please help me?

I am trying to load an csv-file in R, but it works wrong!

 My data is


0,0127

-0,0016

0,0113

0,0037

-0,0025


> Ret<-read.csv("Ret.csv")
> Ret
  X0 X0127
1  016
2  0   113
3  037
4  025

Thank you in advance!

--
Best regards,

Andy

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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





ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens deepak m r
Verzonden: dinsdag 14 juli 2009 13:17
Aan: r-help@r-project.org
Onderwerp: [R] hi friends, is there any wait function in R

hi,
   is there any wait function in R. I am running one R script to plot
many graphs it is in the for loop. its showing no error but its not
plotting well I think i can solve this problem with a wait function.
Please help me in this regards. If u need any clarification about
programme. u can find the script below.

best regards,
Deepak.M.R
Biocomputing Group
University of Bologana.


#!/usr/bin/R
s<-c("GG","GA","GV","GL","GI","GM","GF","GW","GP","GS","GT","GC","GY","G
N","GQ","GD","GE","GK","GR","GH","AA","AV","AL","AI","AM","AF","AW","AP"
,"AS","AT","AC","AY","AN","AQ","AD","AE","AK","AR","AH","VV","VL","VI","
VM","VF","VW","VP","VS","VT","VC","VY","VN","VQ","VD","VE","VK","VR","VH
","LL","LI","LM","LF","LW","LP","LS","LT","LC","LY","LN","LQ","LD","LE",
"LK","LR","LH","II","IM","IF","IW","IP","IS","IT","IC","IY","IN","IQ","I
D","IE","IK","IR","IH","MM","MF","MW","MP","MS","MT","MC","MY","MN","MQ"
,"MD","ME","MK","MR","MH","FF","FW","FP","FS","FT","FC","FY","FN","FQ","
FD","FE","FK","FR","FH","WW","WP","WS","WT","WC","WY","WN","WQ","WD","WE
","WK","WR","WH","PP","PS","PT","PC","PY","PN","PQ","PD","PE","PK","PR",
"PH","SS","ST","SC","SY","SN","SQ","SD","SE","SK","SR","SH","TT","TC","T
Y","TN","TQ","TD","TE","TK","TR","TH","CC","CY","CN","CQ","CD","CE","CK"
,"CR","CH","YY","YN","YQ","YD","YE","YK","YR","YH","NN","NQ","ND","NE","
NK","NR","NH","QQ","QD","QE","QK","QR","QH","DD","DE"!
 ,"DK","DR","DH","EE","EK","ER","EH","KK","KR","KH","RR","RH","HH")
for(t in 1:length(s))
{

a<-read.table(paste("../All_alpha_proteins/alp",s[t],"mean.sat",sep=""),
header=T)
attach (a)
names(a)
al<-1:length(paste("alp",s[t],"_mean",sep=""))

b<-read.table(paste("../All_beta_proteins/bet",s[t],"mean.sat",sep=""),h
eader=T)
attach(b)
names(b)
bl<-1:length(paste("bet",s[t],"_mean",sep=""))

p<-read.table(paste("../Alpha_and_beta_proteins_a+b/apb",s[t],"mean.sat"
,sep=""),header=T)
attach(p)   
names(p)
pl<-1:length(paste("apb",s[t],"_mean",sep=""))

o<-read.table(paste("../Alpha_and_beta_proteins_aorb/aob",s[t],"mean.sat
",sep=""),header=T)
attach(o)   
names(o)
ol<-1:length(paste("aob",s[t],"_mean",sep=""))
postscript(file=paste("Mean_",s[t],"_Plot.ps",sep=""))
plot(0,xlim=c(0,160),ylim=c(0,70),main=paste("Mean Distance Plot
for ",s[t]," Rsidue pair",sep=""),ylab="Mean Distance in
Angstrom",xlab="Residue Seperation Number")
lines(al,paste("alp",s[t],"_mean",sep=""),col="blue",lty = 2)
lines(bl,paste("bet",s[t],"_mean",sep=""),col="yellow",lty = 2)
lines(pl,paste("apb",s[t],"_mean",sep=""),col="red",lty = 2)
lines(ol,paste("aob",s[t],"_mean",sep=""),col="green",lty = 2)
legend("topleft",c("Alpha Proteins","Beta Proteins","Alpha +
Beta","Alpha or Beta"),lty =
c(2,2,2,2),col=c("blue","yellow","red","green"))
dev.off()
}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailin

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("fit","se.fit")])

#the actual plot
ggplot(cuts, aes(x = cut, y = fit, ymin = fit - se.fit, ymax=fit +
se.fit, colour = factor(A))) + geom_pointrange(position =
position_dodge(width = 0.2)) + coord_flip()

More details on the ggplot2 website: http://had.co.nz/ggplot2/

HTH,

Thierry




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Girish A.R.
Verzonden: dinsdag 14 juli 2009 13:31
Aan: r-help@r-project.org
Onderwerp: [R] Help needed in identifying type of plot


Hi folks,

Can someone please help me in identifying the type of plot shown here?
Sample R code or specific package name would be of help as well.

Thanks,
-Girish

http://www.nabble.com/file/p24477714/example_plot.jpg 


--
View this message in context:
http://www.nabble.com/Help-needed-in-identifying-type-of-plot-tp24477714
p24477714.html
Sent from the R help mailing list archive at Nabble.com.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Jose Narillos de Santos
Verzonden: donderdag 16 juli 2009 11:31
Aan: r-help@r-project.org
Onderwerp: [R] Save results

I imagine I make a function whose results are a Matrix Z

How cn I save in a txt or excel file the result of apply my function?

something similar to save Z.txt.

Thanks in advance.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[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.outlier to AFLP/man/AFLP.outlier.Rd
Writing AFLP.outlier to AFLP/man/AFLP.outlier.Rd
Error in col(m) : 
  a matrix-like object is required as argument to 'row/col'

traceback()
14: col(m)
13: split.default(m, col(m))
12: split(m, col(m))
11: zip(c, ...)
10: zip.c(names(formals), formals)
9: parse.formals(partitum)
8: parse.usage(partitum)
7: function (partitum) 
   {
   assign.parent("params", NULL, environment())
   assign.parent("examples", NULL, environment())
   parse.name(partitum)
   parse.usage(partitum)
   }(list(assignee = "AFLP.outlier", formals = list(Replicate =
"data.frame(PC = character(), Replicate = character(), Observed =
numeric())", 
   Specimen = "data.frame(PC = character(), Specimen = character(),
Observed = numeric())", 
   Marker = "data.frame(PC = character(), Marker = numeric(),
Observed = numeric())", 
   Residual = c("data.frame(PC = character(), Replicate =
character(), Marker = numeric(), ", 
   "Observed = numeric())")), srcref = list(filename =
"AFLP/R/AFLP-outlier.R", 
   lloc = c(26L, 1L, 31L, 1L, 1L, 1L
6: do.call(proc, list(...))
5: maybe.call(pre.parse, partitum)
4: roclet$parse.parsed(parse.files(...))
3: function (...) 
   roclet$parse.parsed(parse.files(...))("AFLP/R/AFLP-outlier.R", 
   "AFLP/R/AFLP-package.R", "AFLP/R/as-AFLP.R", "AFLP/R/is-AFLP.R")
2: do.call(Rd$parse, files)
1: roxygenize("AFLP", roxygen.dir = "AFLP", copy.package = FALSE, 
   unlink.target = FALSE)


#content of AFLP-outlier.R

#' Holds the outliers of an AFLP project
#' @method AFLP outlier
#' @param Replicate a dataframe with the name of the primer combination
(PC), 
#'  the name of the replicate and the observed value of the
outlier
#' @param Specimen a dataframe with the name of the primer combination
(PC), 
#'  the name of the specimen and the observed value of the
outlier
#' @param Marker a dataframe with the name of the primer combination
(PC), 
#'  the name of the marker and the observed value of the
outlier
#' @param Residual a dataframe with the name of the primer combination
(PC), 
#'  the name of the replicate, the name of the marker and
the observed value
#'  of the outlier
#' @return An object of the AFLP.outlier class
#' @author Thierry Onkelinx \email{Thierry.Onkelinx@@inbo.be}
#' @examples 
#' AFLP.outlier()

setClass("AFLP.outlier",
representation = representation(Replicate = "data.frame",
Specimen = "data.frame",
Marker = "data.frame", Residual = "data.frame"),
prototype = prototype(Replicate = data.frame(PC = character(),
Replicate = character(), Observed = numeric()),
Specimen = data.frame(PC = character(), Specimen =
character(), Observed = numeric()),
Marker = data.frame(PC = character(), Marker =
numeric(), Observed = numeric()),
Residual = data.frame(PC = character(), Replicate =
character(), Marker = numeric(), Observed = numeric()))
)

AFLP.outlier <- function(Replicate = data.frame(PC = character(),
Replicate = character(), Observed = numeric()), 
Specimen = data.frame(PC = character(), Specimen =
character(), Observed = numeric()), 
Marker = data.frame(PC = character(), Marker =
numeric(), Observed = numeric()), 
Residual = data.frame(PC = character(), Replicate =
character(), Marker = numeric(), Observed = numeric())){
new("AFLP.outlier", Replicate = Replicate, Specimen = Specimen,
Marker = Marker, Residual = Residual)
}




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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


Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an officia

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



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens saurav pathak
Verzonden: donderdag 16 juli 2009 12:18
Aan: r-help@r-project.org
Onderwerp: [R] PROBIT REGRESSION FOR GROUPED/CLUSTERED DATA

Hello all

I have been working to fix this for weeks now, It should be simple to
fix.
Please help

Let me explain what I am doing, I have a data set for 65 countries over
a period of 9 years (2000-2008). Each country has on an average say 2000
interviews, so that the total set has roughly 65*9*2000 data
points/observations (of course there are missing vales as well). Now let
me explain how are the data clustered or grouped. I use the variable
"yearctry"
which is computed as year*1+ international phone code of the
country, say for example USA with calling code 001 for the year 2000
will have a yearctry value = 201. Under this particular value of
yearctry of 201 there are roughly 2000 observations, next for the
same year for say UK the yearctry value would be 244 (having roughly
2000 observations) , and similarly so on for the rest of the 63
countries for the year 2000 and all other years from 2000 to 2008. For
say the year 2001, the values of yearctry for USA and UK would be
2001001 and 2001044 respectively (again 2000 obseravations for each
country roughly) and so on for the other 63 countries as well. So the
data set is *grouped/clustered using "yearctry"*

I am trying to look into a selection bias if any within each "yearctry"
(ie 2000 observation for one country for 9 years and so on for 65
countries) value, essentially therefore I wish to check for 65*9 values
of "yearctry"
with each "yearctry" having 2000 observations roughly. Hence I use the
glm/probit to look into the selection bias where all my dependant
variable "s" are either  0 or 1. The formula

*myProbit<- glm(s ~ age + gender + gemedu + gemhinc + es_gdppc + imf_pop
+ estbbo_m, family = binomial(link = "probit"), data =
adpopdata)*

is the Heckman selection equation based on all observations without
taking into account the fact that each "yearctry" is unique, I want the
selection equation to recognise the uniqueness of each "yearctry" value
, takes one "yearctry" at a time, estimates the probit, goes to the next
"yearctry"
repeats the probit regression and then give me the result. At the moment
I do not accomplish that using the above formula. The above formula does
regression on a bulk basis, but I wish that it recognises one yearctry
from the other and then performs the regression for all yearctry values
and finally produces me the result

Is there any other model recommended that should do the job other than
the glm???If Yes please help how?

Let me give you the exact command that Stata uses, so that things become
very clear:

*xtprobit s age gender gemeduc gemhinc es_gdppc imf_pop estbbo_m,
i(yearctry)*

This does exactly what I wish to accomplish in R, ie does the heckman
selection equation for the selection variables (seven in my case) based
upon the uniqueness of "yearctrty"

I have worked weeks on this, kindly help me, I think it is a small issue
to fix in the equation, although since I am new to R, I do not exactly
know what exactly will fix my problem, so any help will be highly
appreciated Thanks

--
Dr.Saurav Pathak
PhD, Univ.of.Florida
Mechanical Engineering
Doctoral Student
Innovation and Entrepreneurship
Imperial College Business School
s.patha...@imperial.ac.uk
0044-7795321121

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zola

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 bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Thomas Roth (geb. Kaliwe)
Verzonden: vrijdag 17 juli 2009 10:03
Aan: 'r-help@r-project.org'
Onderwerp: [R] how to evaluate character vector within pnorm()

Hi,

I'm trying to evaluate a character vector within pnorm. I have a vector
with values and names

x = c(2,3)
names(x) = c("mean", "sd")

so that i tried the following

temp = paste(names(x), x, sep = "=")

#gives
#> temp
#[1] "mean=2" "sd=3"

#Problem is that both values 2 and 3 are taken as values for the mean
argument in pnorm pnorm(0, eval(parse(text = temp)) )

#but not as
pnorm(0, mean = 2, sd = 3 )


#How can i get

pnorm(0, eval(parse(text = temp)) )

#to do

pnorm(0, mean = 2, sd = 3 )



Thank you for your time

Thomas Roth

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Mohan S
Verzonden: donderdag 23 juli 2009 6:14
Aan: r-help@r-project.org
Onderwerp: [R] param:qsec in ggplot2

Hii

  i have been trying to do a scatter plot with ggplot2, like the plot 6
here
(http://had.co.nz/ggplot2/geom_point.html) .. where the points size vary
with values

> p + geom_point(aes (size = qsec))


  but am not sure how to setup the parameter - qsec

  could anyone please give some pointers on how to define that

thanks
Mo.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens axionator
Verzonden: donderdag 23 juli 2009 11:04
Aan: David Winsemius
CC: r-help@r-project.org
Onderwerp: Re: [R] contour plot

That problem is that for every y I get a different x and thus cant
create an array as in the help page examples.
I was just wondering, whether there is a possibility to create such a
contour plot easily without having to spend too much time with setting
up a suitable matrix manually.

Armin

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens RON70
Verzonden: donderdag 23 juli 2009 14:25
Aan: r-help@r-project.org
Onderwerp: [R] Another question on gplot


I am getting following strange error :

library(sn)
library(ggplot2)

dat1 <- as.matrix(rsn(1000, 0, 1, 0))[,1]

ggplot() + geom_histogram(aes(x = dat1, y = ..density.., fill =
..count..))
+
  xlab("Distribution") + scale_y_continuous("") 


Error: No data for layer

Can anyone please tell me why it is coming?
--
View this message in context:
http://www.nabble.com/Another-question-on-gplot-tp24624709p24624709.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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.

HTH,

Thierry
 




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens RON70
Verzonden: vrijdag 24 juli 2009 11:23
Aan: r-help@r-project.org
Onderwerp: [R] ggplot question


In page http://had.co.nz/ggplot2/scale_date.html , there is a time
series plot for multiple variables at the bottom. i.e

qplot(date, value, data = em, geom = "line", group = variable) + 
+   facet_grid(variable ~ ., scale = "free_y")

How can I make different color for different series?

Thanks
--
View this message in context:
http://www.nabble.com/ggplot-question-tp24641347p24641347.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Albert EINstEIN
Verzonden: dinsdag 28 juli 2009 6:56
Aan: r-help@r-project.org
Onderwerp: [R] storing output in html or pdf table format.


Hi every one,
Thanks for every one who are all supporting to us. we want some
clarification on output in R. I have generated summary statistics output
for dataset (E.g. sales) in output window. Now i want  to store that
output in a html or pdf in a table format. if possible can any one
provide code for this one.

Thanks in advance.  

--
View this message in context:
http://www.nabble.com/storing-output-in-html-or-pdf-table-format.-tp2469
2508p24692508.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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.

Have a look at the posting guide
(http://www.r-project.org/posting-guide.html). It states:

Questions about statistics: The R mailing lists are primarily intended
for questions and discussion about the R software. However, questions
about statistical methodology are sometimes posted. If the question is
well-asked and of interest to someone on the list, it may elicit an
informative up-to-date answer. See also the Usenet groups
sci.stat.consult (applied statistics and consulting) and sci.stat.math
(mathematical stat and probability).  

HTH,

Thierry



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens alis villiyam
Verzonden: dinsdag 28 juli 2009 11:28
Aan: r-help@r-project.org
Onderwerp: [R] Fwd: randomized block design analysis in R

-- Forwarded message --
From: alis villiyam 
Date: Mon, Jul 27, 2009 at 9:47 AM
Subject: randomized block design analysis in R
To: bol...@zoology.ufl.edu


Dear All user
Hello,

I'm a  student and I have some trouble with the experimental
(columns-experiments) design of my project. I use a randomized block
design with 4 treatments including a control. For each treatment, I use
3 replicates and 3 blocks.

The treatments are:

-T1 = COD (300 mg/Lit)   COD=chemical oxygen demand

-T2 = COD (200 mg/Lit)

-T3 = COD (100 mg/Lit)

-T4 = COD (0 mg/Lit) as a control

The experiment is conducted during three months and a sample is taken
each Week in every experimental unit.

At the first, I irrigated all soil columns (12 columns) with demonize
water for 1 week.

Then during 8 weeks, I irrigated all columns with waste water with
different concentration. Then, gain, I irrigated all columns with
demonize water for 4 weeks.

Now I want to know how I can analyses the results in R. For example, I
want to detect the Effect of waste water on some physical properties of
soil, before, during use waste water and after use waste water (Is there
any significant change in properties of soil.) Time is also important,
so I want to know the interaction between time and some physical
properties of soil, like water content .first comprises between
Treatments and then comprise between weeks).

Questions to be answered:

1)  Theta (water content), before (1 week) and after the COD; is
there a
difference?
2)  Theta, during, before and after the COD; is there a difference?
3)  Is there a trend in Theta, during COD (8 weeks)?
4)  Is there a difference in Theta, during COD between the
treatments?
I hope somebody can help me to find correct statistical analyses in R.


Kind regards,

Alisia

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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.

HTH,

Thierry

PS Don't for get that you need to load a package before using it! Just
installing it is not sufficient.

library(lme4)
?lmer

library(nlme)
?lme




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Angela Radulescu
Verzonden: woensdag 29 juli 2009 1:48
Aan: r-help@r-project.org
Onderwerp: [R] Installing lme4 package in Windows Vista


Hi all,

I have a problem with package installing in Windows, on my PC machine.
The end goal is to be able to use the lme() function. Here's what I did
so far: 

> install.packages("lme4")
Warning in install.packages("lme4") :
  argument 'lib' is missing: using
'C:\Users\Angela\Documents/R/win-library/2.9'
--- Please select a CRAN mirror for use in this session --- trying URL
'http://cran.cnr.Berkeley.edu/bin/windows/contrib/2.9/lme4_0.999375-31.z
ip'
Content type 'application/zip' length 1140865 bytes (1.1 Mb) opened URL
downloaded 1.1 Mb

package 'lme4' successfully unpacked and MD5 sums checked

The downloaded packages are in

C:\Users\Angela\AppData\Local\Temp\Rtmp1t8vjT\downloaded_packages
updating HTML package descriptions
Warning message:
In file.create(f.tg) :
  cannot create file 'C:\PROGRA~1\R\R-29~1.1/doc/html/packages.html',
reason 'Permission denied'

I had to change permissions on some of the "library" folder before this.
Still, after installation, R cannot find the "lme" function of interest.


> lme
Error: object 'lme' not found

Does anyone know why this is happening, and what the solution to the
problem is? 

Many thanks,
Angela
--
View this message in context:
http://www.nabble.com/Installing-lme4-package-in-Windows-Vista-tp2470993
2p24709932.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ 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: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
Namens Patrick Schorderet
Verzonden: woensdag 29 juli 2009 10:29
Aan: r-help@r-project.org
Onderwerp: [R] Newbie in R: Reading .txt files and storing the 'numbers'
in avector


Hello everybody,

I'm a newbie in R and just went through an introduction class recently.

Here's my problem.
I have 2 text files (.txt) with plain numbers ('doubles' for those who
know c++) ordered into 2 columns as below:

coordinate1 value1
coordinate2 value2
coordinate3 value3
... ...
coordinateN valueN

I would like to write a small programme in which i would:
1. take all values of file 1 and store them in a vector 2. substract to
those all values of file 2 (one by one) and store the result in a new
vector 3. Create a sliding window of chosen size and calculate the
mathematical average and store these averages in a new vector 4. Plot
the different graphes with a bar plot

So I wrote a c++ script that does the first parts and writes the
averages in a output.txt file (which I have up and running).  
Unfortunately, I seem to fail in reading these as numbers and putting
them into a vector (in the R environment). I can read the file , but
this is what I get:

 > z=scan(file = "/Users/NCCRGENETICS/Desktop/testRnumbers.txt", what =
"double") Read 19 items  > z
  [1] "{\\rtf1\\ansi\\ansicpg1252\\cocoartf949\\cocoasubrtf430"
  [2] "{\\fonttbl\\f0\\fswiss\\fcharset0"
  [3] "Helvetica;}"
  [4] "{\\colortbl;\\red255\\green255\\blue255;}"
  [5] "\\paperw11900\\paperh16840\\margl1440\\margr1440\\vieww9000\
\viewh8400\\viewkind0"
  [6] "\\pard\\tx566\\tx1133\\tx1700\\tx2267\\tx2834\\tx3401\\tx3968\
\tx4535\\tx5102\\tx5669\\tx6236\\tx6803\\ql\\qnatural\\pardirnatural"
  [7] "\\f0\\fs24"
  [8] "\\cf0"
  [9] "13\\"// This is where my file
"should" start  
reading the numbers I see in the window when I open it with textedit
[10] "27\\"
[11] "39\\"
[12] "48\\"
[13] "34\\"
[14] "17\\"
[15] "23\\"
[16] "45\\"
[17] "23\\"
[18] "4\\"
[19] "}"
 >

Thanks so much to any of you who could provoid a little help... I'm
getting nuts.
Patrick

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


  1   2   3   4   5   6   7   >