[R] confidence interval around Aalen-Johansen if no events

2023-09-06 Thread Andreas Leha
Hi all,

I'd like to calculate confidence intervals around Aalen-Johansen
estimates at given time points.  And later I'd like to be able to
compare the Aalen-Johansen estimates at given time points between
groups.
My problem is, that there are no events recorded.

So my question is:
Does anyone know how to get confidence intervals around Aalen-Johansen
estimates in the absence of (or prior to) events?
(And ideally also how to compare the Aalen-Johansen estimates at given
time points between groups in that situation.)

Note that I can do the same thing for Kaplan-Meier estimates (using
the bpcp package).

Many thanks in advance!

Best,
Andreas

PS:  Some code that illustrates my problem:

-
library("dplyr")
library("survival")

## read data
sdat <- structure(list(time = c(2, 189, 182, 2, 184, 179, 179, 159, 18, 
177, 177, 182, 184, 178, 179, 178, 179, 179, 177, 178, 175, 184, 
179, 179, 176, 176, 175, 193, 183, 182, 179, 175, 178, 90, 189, 
177, 185, 179, 184, 171, 182, 181, 179, 179, 175, 104, 185, 180, 
180, 177, 176, 184, 181, 178, 184, 178, 182, 176, 176, 180, 180, 
176, 183, 182, 175, 184, 182, 182, 177, 182, 64, 178, 179, 179, 
176, 93, 131, 184, 181), event = structure(c(2L, 1L, 1L, 2L, 
1L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 1L, 1L), .Label = c("censored", 
"competing_event", "event_of_interest"), class = "factor"), group = 
structure(c(2L, 
2L, 2L, 1L, 2L, 1L, 2L, 2L, 1L, 1L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 
2L, 1L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 2L, 1L, 2L, 
1L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 
2L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 
1L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 1L), .Label = c("G1", 
"G2"), class = "factor")), row.names = c(NA, -79L), class = c("tbl_df", 
"tbl", "data.frame"))
sdat
## there are no events of interest:
sdat$event %>% table(exclude = NULL)

## fit works fine
fit <- survfit(Surv(time, event) ~ group, data = sdat)
## the estimate is at 0 (as expected)
fit$pstate[,3]
## but there is no confidence estimate
fit$lower[,3]
fit$upper[,3]
## cmprsk does not event return estimates for the event of interest
library("cmprsk")
fit <- cuminc(ftime = sdat$time,
  fstatus = sdat$event,
  cencode = "censored",
  group = sdat$group)
fit



## note that I can get confidence intervals from a Kaplan-Meier
## estimator:

## censor competing events:
sdat <-
  sdat %>%
  mutate(event2 = recode(event,
 competing_event = "censored")) %>%
  mutate(event2 = as.numeric(event2) - 1)
sdat$event2 %>% table(exclude = NULL)
## fit using the survival package
fit <- survfit(Surv(time, event2) ~ 1, data = sdat)
fit
## no (meaningful?) confidence intervals
fit$lower
fit$upper
## but through the bpcp package this is possible
library("bpcp")
sfit2 <- bpcpfit(Surv(time, event2) ~ 1, data = sdat)
sfit2
tidykmciLR(sfit2)
## can further compare between groups:
bpcp2samp(sdat$time, sdat$event2, sdat$group, testtime = 150,
  parmtype = "difference")

__
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.


[R] unused argument(s) (Header = 1) help!

2023-08-09 Thread Andreas Noviyanto
Dear Daniel,

I was use this script to calculate replicateBE with R software, its 
worked. when i use the same script with similar data (xlsx) i got error 
messages like below, do you have any suggest? thanks anyway
my script:
library(replicateBE)
path.in  <- "Z:/Personil Omega"
path.out <-  path.in
method.A(path.in=path.in, path.out=path.out, file="lans",
  set="01", ext="xlsx", header=1, ola=TRUE)
method.A(path.in=path.in, path.out=path.out, file="lans",
 set="02", ext="xlsx", header=1)
ABE(path.in=path.in, path.out=path.out, file="lans",
 set="01", ext="xlsx", header=1)

ABE(path.in=path.in, path.out=path.out, file="lans",
 set="02", ext="xlsx", header=1)

result:
 > library(replicateBE)
 > path.in  <- "Z:/Personil Omega"
 > path.out <- path.in
 > method.A(path.in=path.in, path.out=path.out, file="lans",
+  set="01", ext="xlsx", header=1, ola=TRUE)
Error in method.A(path.in = path.in, path.out = path.out, file = "lans", 
  :
   unused argument (header = 1)
 > method.A(path.in=path.in, path.out=path.out, file="lans",
+ set="02", ext="xlsx", header=1)
Error in method.A(path.in = path.in, path.out = path.out, file = "lans", 
  :
   unused argument (header = 1)
 > ABE(path.in=path.in, path.out=path.out, file="lans",
+ set="01", ext="xlsx", header=1)
Error in ABE(path.in = path.in, path.out = path.out, file = "lans",  :
   unused argument (header = 1)
 > ABE(path.in=path.in, path.out=path.out, file="lans",
+ set="02", ext="xlsx", header=1)
Error in ABE(path.in = path.in, path.out = path.out, file = "lans",  :
   unused argument (header = 1)



Warm Regards,

Andreas

[[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.


Re: [R] Use of ellipsis

2022-05-29 Thread Andreas Matre



Thank you very much Ivan and Bert! I used the eval(substitute()) 
workaround suggested by Ivan and it worked perfectly.


Andreas Matre

__
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.


[R] Use of ellipsis

2022-05-26 Thread Andreas Matre

Hello,
I am trying to figure out the proper way to use ellipsis to pass 
arguments to child functions. I'm trying to create a wrapper function 
around stats::lm and lme4::lmer such that if the formula passed to the 
wrapper function contains a random effect it will fit a lme4::lmer model 
and if not it will fit a stats::lm object. I want the function to alway 
want a formula and data argument and then use the ellipsis argument to 
pass additional arguments to either lme4::lmer or stats::lm. The problem 
is that when I pass additional arguments through the ellipsis argument I 
get the error

"Error in eval(extras, data, env) :
  ..1 used in an incorrect context, no ... to look in".

A simplified version of my attempt with a reproducible example is here:

fit_model <- function(formula, data, ...) {
  lm(formula, data, ...)
}
# Create test data
data <- data.frame(x1 = rnorm(100), x2 = rnorm(100))
data$y <- data$x1 + data$x2 + rnorm(100)

fit_model(y ~ x1 + x2, data = data) # This works
fit_model(y ~ x1 + x2, data = data, weights = rep(1, 100)) # This does 
not work


Any hints as to why this error occurs would be appreciated. I found [1], 
but I don't think that's relevant, since as far as I can tell, there 
should be no non-standard evaluation here.


[1] https://stat.ethz.ch/pipermail/r-help/2010-February/228881.html

Andreas Matre

__
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: [ESS] [OT] Enabled a hook and no longer find which

2021-07-30 Thread Andreas Leha via ESS-help
Dirk Eddelbuettel via ESS-help  writes:

> tl;dr: I enabled an action 'on save' and I no longer find where :-/
>
>
> Longer story: I settled upon GNU global and ggtags at some point for a
> (mostly multilingual) system of tags in R and C++ (and some more). So a few
> of source directories have these (ugly names) files GPATH, GTAGS, GRTAGS.
> And at one point I became too clever by half and somehow enabled updating of
> these files for at least some repos. But I no longer remember _how_ I did
> that and can, for the life of me, find any trace in my .emacs (and, older
> story, .elisp/*el) file(s). It is definitely active in ~/git/rcpp and
> ~/git/tiledb-r -- which maybe the two repos in work in the most.
>
> This list has been very kind helpful in the past when I puzzled myself with
> this one true editor.  I suspect I used an ESS hook somewhere.  How would I
> find or debug this?
>
> The net effect seems to be that as soon I save (C-x s) the files GTAGS and
> GRTAGS get updated.  Which I otherwise do via a one-line script setting the
> proper options (as GNU global at some point in the past needed a patch, I
> think that is no longer needed)
> gtags --gtagsconf=/home/edd/.globalrc --gtagslabel=pygments --verbose 
> --statistics "$@"
>
> I have been half-amused by this for a few weeks but I am approaching "white
> flag" territory here on my own workstation: how do I find out how I enabled
> this?  I looked into git commit hooks (nope), GNU global config (nope), and,
> by looking more closely at the timestamps, have to suspect that is from
> Emacs.  But nothing in the Emacs config gives it away. I have a vague memory
> that it went via one of the XDG standard directories
> (~/.config/share/SOMETHING ?) but no mas.  
>
> Dirk, only moderately amuzed by now

wild guess:  file/dir local variable?

Best,
Andreas

__
ESS-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help


Re: [ESS] eldoc in Rmd files

2018-11-11 Thread Leha, Andreas via ESS-help
Dear Vitalie,

yes, indeed.  Thanks a lot!  I had a merge conflict in my git checkout
of polymode which went unnoticed (for quite some time...).

el-doc works fine again also in my Rmd files.

Best,
Andreas



On 11/11/18 12:53, Vitalie Spinu wrote:
> 
> You have an outdated polymode
> 
>   polymode$ git show 0340f5e7e55235832e
>   commit 0340f5e7e55235832e59673f027cc79a23cbdcd6
>   Author: Vitalie Spinu 
>   Date:   Tue Mar 7 12:22:42 2017 +0100
> 
> Polymode has been rewritten and R functionality lives in a separate
> package. Just install `poly-R` from melpa and remove *all* old polymode
> configuration from your .emacs.
> 
>   Vitalie
> 
>>> On Sat, Nov 10 2018 10:54, Leha, Andreas via ESS-help wrote:
> 
>> Hi all,
> 
>> I recently upgraded both emacs and ess.  One of those broke eldoc
>> functionality in Rmd files, which worked fine previously.
> 
>> I can reproduce with `emacs -Q`.
> 
>> To reproduce this, use this test.Rmd file:
> 
>> ---
>> title: Test
>> ---
> 
>> ```{r testblock, include = FALSE}
>> rnorm
>> ```
> 
> 
> 
>> - move the point to the source block
>> - type C-c C-v to update the references
>> - type the opening '(' after 'rnorm'
> 
>> Now, I would expect the eldoc message in the echo buffer, as it appears
>> in ordinary R files.
> 
>> This is a major limitation for my workflow.  Can I fix that somehow?
> 
>> Thanks in advance!
> 
>> Regards,
> 
>> Andreas
> 
>> PS:
> 
>> Here is my setup:
> 
>> - linux (debian buster)
> 
>> - Emacs 26.1.50
> 
>> - ess-version: 18.10.2
> 
>> - polymode (0340f5e7e55235832e59673f027cc79a23cbdcd6)
> 
>> - markdown-mode, version 2.4-dev
> 
>> PPS:
> 
>> And here is my minimal init.el:
> 
> 
> 
> 
> 
> 
> 
> 
>> ;; ess
> 
>> (add-to-list 'load-path "~/local/emacs/ess/lisp")
> 
>> ;;(load "~/local/emacs/ess/lisp/ess-site.el")
> 
>> (require 'ess-site)
> 
>> ;; markdown mode
> 
>> (setq load-path
> 
>>   (append '("~/local/emacs/markdown-mode/")
> 
>>   load-path))
> 
>> (autoload 'markdown-mode "markdown-mode"
> 
>>"Major mode for editing Markdown files" t)
> 
>> ;;(add-to-list 'auto-mode-alist '("\\.text\\'" . markdown-mode))
> 
>> (add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
> 
>> (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
> 
>> ;; polymode
> 
>> (setq load-path
> 
>>   (append '("~/local/emacs/polymode/"
>> "~/local/emacs/polymode/modes")
> 
>>   load-path))
> 
>> (require 'poly-R)
> 
>> (require 'poly-markdown)
> 
>> ;;; R modes
> 
>> (add-to-list 'auto-mode-alist '("\\.Snw" . poly-noweb+r-mode))
> 
>> (add-to-list 'auto-mode-alist '("\\.Rnw" . poly-noweb+r-mode))
> 
>> (add-to-list 'auto-mode-alist '("\\.Rmd" . poly-markdown+r-mode))
> 
> 
> 
>> __
>> ESS-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/ess-help

-- 
Dr. Andreas Leha
Head of the 'Core Facility
Medical Biometry and Statistical Bioinformatics'

UNIVERSITY MEDICAL CENTER GÖTTINGEN
GEORG-AUGUST-UNIVERSITÄT
Department of Medical Statistics
Humboldtallee 32
37073 Göttingen
Mailing Address: 37099 Göttingen, Germany
Fax: +49 (0) 551 39-4995
Tel: +49 (0) 551 39-4987
http://www.ams.med.uni-goettingen.de/service-de.shtml
__
ESS-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help


[ESS] eldoc in Rmd files

2018-11-10 Thread Leha, Andreas via ESS-help
Hi all,

I recently upgraded both emacs and ess.  One of those broke eldoc
functionality in Rmd files, which worked fine previously.

I can reproduce with `emacs -Q`.


To reproduce this, use this test.Rmd file:

--8<---cut here---start->8---
---
title: Test
---

```{r testblock, include = FALSE}
rnorm
```
--8<---cut here---end--->8---


- move the point to the source block
- type C-c C-v to update the references
- type the opening '(' after 'rnorm'

Now, I would expect the eldoc message in the echo buffer, as it appears
in ordinary R files.







This is a major limitation for my workflow.  Can I fix that somehow?











Thanks in advance!







Regards,



Andreas











PS:







Here is my setup:



- linux (debian buster)



- Emacs 26.1.50



- ess-version: 18.10.2



- polymode (0340f5e7e55235832e59673f027cc79a23cbdcd6)



- markdown-mode, version 2.4-dev











PPS:







And here is my minimal init.el:







--8<---cut here---start->8---



;; ess



(add-to-list 'load-path "~/local/emacs/ess/lisp")



;;(load "~/local/emacs/ess/lisp/ess-site.el")



(require 'ess-site)







;; markdown mode



(setq load-path



  (append '("~/local/emacs/markdown-mode/")



  load-path))



(autoload 'markdown-mode "markdown-mode"



   "Major mode for editing Markdown files" t)



;;(add-to-list 'auto-mode-alist '("\\.text\\'" . markdown-mode))



(add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))



(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))







;; polymode



(setq load-path



  (append '("~/local/emacs/polymode/"
"~/local/emacs/polymode/modes")



  load-path))



(require 'poly-R)



(require 'poly-markdown)



;;; R modes



(add-to-list 'auto-mode-alist '("\\.Snw" . poly-noweb+r-mode))



(add-to-list 'auto-mode-alist '("\\.Rnw" . poly-noweb+r-mode))



(add-to-list 'auto-mode-alist '("\\.Rmd" . poly-markdown+r-mode))



--8<---cut here---end--->8---
__
ESS-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help


Re: [R] PSOCK cluster and renice

2017-12-03 Thread Andreas Leha
Hi Henrik,

Thanks for the detailed in fast reply!

My guess would be that the confusion comes from the different use of nice and 
renice.

The workraund you provided work fine!  Thanks a lot.

Best,
Andreas



Henrik Bengtsson <henrik.bengts...@gmail.com> writes:

> Looks like a bug to me due to wrong assumptions about 'nice'
> arguments, but could be because a "non-standard" 'nice' is used.  If
> we do:
>
>> trace(system, tracer = quote(print(command)))
> Tracing function "system" in package "base"
>
> we see that the system call used is:
>
>> cl <- parallel::makePSOCKcluster(2L, renice = 19)
> Tracing system(cmd, wait = FALSE) on entry
> [1] "nice +19 '/usr/lib/R/bin/Rscript'
> --default-packages=datasets,utils,grDevices,graphics,stats,methods -e
> 'parallel:::.slaveRSOCK()' MASTER=localhost PORT=11146 OUT=/dev/null
> TIMEOUT=2592000 XDR=TRUE"
> nice: ‘+19’: No such file or directory
> ^C
>
> The code that prepends that 'nice +19' is in parallel:::newPSOCKnode:
>
> if (!is.na(renice) && renice)
> cmd <- sprintf("nice +%d %s", as.integer(renice), cmd)
>
> I don't know where that originates from and on what platform it was
> tests/validated.  On Ubuntu 16.04, CentOS 6.6, and CentOS 7.4, I have
> 'nice' from "GNU coreutils" and they all complain about using '+',
> e.g.
>
> $ nice +19 date
> nice: +19: No such file or directory
>
> but '-' works:
>
> $ nice -19 date
> Sun Dec  3 20:01:31 PST 2017
>
> Neither 'nice --help' nor 'man help' mention the use of a +n option.
>
>
> WORKAROUND:  As a workaround, you can use:
>
> cl <- future::makeClusterPSOCK(2L, rscript = c("nice",
> "--adjustment=10", file.path(R.home("bin"), "Rscript")))
>
> which is backward compatible with parallel::makePSOCKcluster() but
> provides you with more detailed control.  Try adding verbose = TRUE to
> see what the exact call looks like.
>
> /Henrik
>
>
> On Sun, Dec 3, 2017 at 7:35 PM, Andreas Leha
> <andreas.l...@med.uni-goettingen.de> wrote:
>> Hi all,
>>
>> Is it possible to use the 'renice' option together with parallel
>> clusters of type 'PSOCK'?  The help page for parallel::makeCluster is
>> not specific about which options are supported on which types and I am
>> getting the following message when passing renice = 19 :
>>
>>> cl <- parallel::makeCluster(2, renice = 19)
>> nice: ‘+19’: No such file or directory
>>
>> Kind regards,
>> Andreas
>>
>> __
>> 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.
>
> __
> 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.

__
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.

[R] PSOCK cluster and renice

2017-12-03 Thread Andreas Leha
Hi all,

Is it possible to use the 'renice' option together with parallel
clusters of type 'PSOCK'?  The help page for parallel::makeCluster is
not specific about which options are supported on which types and I am
getting the following message when passing renice = 19 :

> cl <- parallel::makeCluster(2, renice = 19)
nice: ‘+19’: No such file or directory

Kind regards,
Andreas

__
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.

[R] greport

2017-10-17 Thread Andreas Betz
Hello,

I am trying to setup grereport by Frank Harell on my Fedora system. 
Unfortunately some links for latex on the homepage are disabled. Thus I cannot 
find ocgtools for Fedora. Further Acrobat reader has not been updated after 
2013. Can somebody give me some pointers how to set up the package.

Thank you

Andreas


This email message is for the sole use of the intended r...{{dropped:11}}

__
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] encoding/locale problem with ssh -X

2017-06-23 Thread Andreas Leha
Hi Paul,

Thanks for following this up!

It used to be R version 3.3.1

I updated to R version 3.4.0

Now everything seems to work!

Many thanks!

Best,
Andreas



On 23/06/17 03:02, Paul Murrell wrote:
> Hi
> 
> What version of R do you have (on the remote machine) ?
> 
> I can replicate this with ...
> 
> x11(type="Xlib")
> library(grid)
> convertHeight(stringDescent("größe"), "in")
> 
> ... on R 3.2.5, but not on, e.g., R 3.4.0 (just running R locally in
> both cases).
> 
> Paul
> 
> On 21/06/17 20:05, Andreas Leha wrote:
>> Hi all,
>>
>> I am struggling with remote R sessions and a (I suspect) locale related
>> encoding problem:  Using the X11 device (X11forwarding enabled),
>> whenever I try to plot something containing umlauts using ggplot2, I am
>> seeing sth like
>>
>> ,
>> | Error in grid.Call(L_stringMetric, as.graphicsAnnot(x$label)) :
>> |   invalid use of -61 < 0 in 'X11_MetricInfo'
>> `
>>
>> Using base graphics is fine as is plotting to another device (pdf, say).
>>
>> Here is some code to reproduce:
>>
>> ,
>> | plot(1:10, 1:10, main = "größe")
>> | ## this works
>> |
>> | library("ggplot2")
>> | qplot(1:10, 1:10)
>> | ## this works still
>> |
>> | qplot(1:10, 1:10) + xlab("größe")
>> | ## ERROR
>> `
>>
>>
>> My setup:
>> - locally:
>>Linux (Debian GNU/Linux 9)
>> - remotely
>>Linux (RHEL Server release 7.3 (Maipo)
>>
>> (Maybe) relevant bits of my .ssh/config:
>>
>> ,
>> | Host theserver
>> |  HostName XXX.XXX.XXX.XXX
>> |  ForwardX11 yes
>> |  ForwardX11Timeout 596h
>> |  IdentityFile ~/.ssh/id_rsa
>> |  IdentitiesOnly yes
>> |  ForwardAgent yes
>> |  ServerAliveInterval 300
>> `
>>
>> Thanks in advance for your help!
>>
>> Best,
>> Andreas
>>
>> __
>> 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.
>>
>

__
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.

[R] encoding/locale problem with ssh -X

2017-06-21 Thread Andreas Leha
Hi all,

I am struggling with remote R sessions and a (I suspect) locale related
encoding problem:  Using the X11 device (X11forwarding enabled),
whenever I try to plot something containing umlauts using ggplot2, I am
seeing sth like

,
| Error in grid.Call(L_stringMetric, as.graphicsAnnot(x$label)) :
|   invalid use of -61 < 0 in 'X11_MetricInfo' 
`

Using base graphics is fine as is plotting to another device (pdf, say).

Here is some code to reproduce:

,
| plot(1:10, 1:10, main = "größe")
| ## this works
| 
| library("ggplot2")
| qplot(1:10, 1:10)
| ## this works still
| 
| qplot(1:10, 1:10) + xlab("größe")
| ## ERROR
`


My setup:
- locally:
  Linux (Debian GNU/Linux 9)
- remotely
  Linux (RHEL Server release 7.3 (Maipo)

(Maybe) relevant bits of my .ssh/config:

,
| Host theserver
|  HostName XXX.XXX.XXX.XXX
|  ForwardX11 yes
|  ForwardX11Timeout 596h
|  IdentityFile ~/.ssh/id_rsa
|  IdentitiesOnly yes
|  ForwardAgent yes
|  ServerAliveInterval 300
`

Thanks in advance for your help!

Best,
Andreas

__
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.

[R] [R-pkgs] New Package: pinbasic - Fast and Stable Estimation of the Probability of Informed Trading (PIN)

2016-10-26 Thread Andreas Recktenwald

Dear R-Users,

a new package, "pinbasic", is now available on CRAN. According to the 
DESCRIPTION:



Utilities for fast and stable estimation of the probability of informed 
trading (PIN) in the model introduced by Easley et al. (2002) 
 are implemented. Since the basic model 
developed  by Easley et al. (1996) 
 is nested in the former due to 
equating the intensity of uninformed buys and sells, functionalities  
can also be applied to this simpler model structure, if needed.



A vignette will be added to the package in near future. However, the 
existing manual pages should be a good starting point.


Development version of the package is available at:

https://github.com/anre005/pinbasic

--
Diplom-Kaufmann Andreas Recktenwald
Statistik & Ökonometrie
Rechts- und Wirtschaftswissenschaftliche Fakultät
Universität des Saarlandes
Campus C3 1, Raum 2.06
66123 Saarbrücken
Deutschland

___
R-packages mailing list
r-packa...@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-packages
__
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.

[R] outlier labels incorrectly assigned with ggplot2 box plot

2016-10-20 Thread Andreas Nord
Dear list,

I want to label outliers in a ggplot box plot with the name of the subject for 
which outlying data were observed.


I have proceeded by creating a simple function to identify outliers:

is_outlier <- function(x) {

  return(x < quantile(x, 0.25) - 1.5 * IQR(x) | x > quantile(x, 0.75) + 1.5 * 
IQR(x))

}


And then the 'safe_ifelse' workaround to get 'ifelse' to function properly with 
factors.

safe.ifelse <- function(cond, yes, no) {

  class.y <- class(yes)

  if (class.y == "factor") {

levels.y = levels(yes)

  }

  X <- ifelse(cond,yes,no)

  if (class.y == "factor") {

X = as.factor(X)

levels(X) = levels.y

  } else {

class(X) <- class.y

  }

  return(X)

}


>From here, I have ran data through a dplyr pipeline to produce the plot.

**data at https://www.dropbox.com/s/2pcuuclxiqw1va1/data.csv?dl=0


library(dplyr)
data<-subset(data,data$variable1!='NA')
p1<-
  data %>%
  group_by(season,location) %>%
  mutate(outlier=safe.ifelse(is_outlier(variable1),subject,as.numeric(NA))) %>%
  ggplot(aes(x=factor(season),y=variable1))+
  geom_boxplot()+
  facet_wrap(~location,nrow=2)+
  guides(fill=FALSE)+
  geom_text(aes(label=outlier),na.rm=TRUE,hjust=1.5,size=2.5)

While outliers are correctly identified, labelling does not work as it should. 
Rather than getting subject-specific outlier labels, three levels of the 
'subject' factor are printed repeatedly and erroneously (and seemingly 
randomly). Labelling outliers by their numerical values (i.e. by changing 
'subject' to 'variable1' in the 'safe_ifelse function) does not cause problems.

I assume I am missing something obvious here - perhaps someone could kindly 
indicate where I am going wrong?

Thanks,
Andreas

[[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.


[R] ifelse for creating discriminating variable based on two conditions

2016-10-14 Thread Andreas Nord

Dear list,

Apologies for a likely naive question.


I am trying to create a discriminating dummy variable using 'ifelse' based on 
conditions in two variables.


Specifically, I want to assign levels in a new factor as '0' or '1' based on a 
user-defined cut off. I.e. something similar to:

  >data1<-data.frame(molecule=runif(30,min=0,max=1e3))

>data1$newcol<-ifelse(data1$molecule>2*sd(data1$molecule),1,0)


Which is all straightforward.


But how do I go on to assign values in variable 'molecule'based on the same cut 
off, but separately for each level of a second variable, in this case the 
factor 'fruit' with three levels. That is, how do I derive fruit-specific 
cut-offs using a data frame with the general structure of that below?

>data2<-data.frame(molecule=runif(30,min=0,max=1e3),fruit=factor(rep(c('apple','pear','orange'),10)))


Many thanks in advance!



[[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.


[R] [R-pkgs] New package 'forestinventory: Design-Based Global and Small-Area Estimations for Multiphase Forest Inventories'

2016-07-11 Thread Hill Andreas
Dear R users,

We are happy to announce that the R package 'forestinventory: Design-Based 
Global and Small-Area Estimations for Multiphase Forest Inventories'
is now on CRAN (https://cran.r-project.org/web/packages/forestinventory/).

The aim of our package is to provide global- and smallarea estimators for 
twophase and threephase forest inventories under simple and cluster sampling.
The methods can be used for double sampling for stratification (i.e. classical 
ANOVA model as prediction model),
double sampling for regression (i.e. multiple regression model as prediction 
model) and double sampling for regression within strata
(i.e. classical ANCOVA model as prediction model). The implemented estimators 
have been developed by Daniel Mandallaz at ETH Zurich
and their implementation has been optimized according to current challenges and 
needs of multiphase inventories (e.g. use of remote sensing / geodata).

Relevant features:

-  Provides point - and variance estimators for 64 inventory scenarios 
in total,

according to sample design (simple and cluster sampling, two- and threephase 
inventory designs) and availability of auxiliary information

-  Allows for the computation of Confidence Intervals for the point 
estimates

-  Completes the range of the already published estimators for 
threephase small area estimations

-  Also includes estimators for onephase inventories (only using 
terrestrial inventory data)

Upcoming activities:
We will publish a vignette illustrating the use of the various estimators as 
soon as possible.


Best,

Andreas Hill
Alexander Massey


---
ETH Z�rich
Andreas Hill
Forstl. Ingenieurwesen, Heinimann
CHN K 75.1
Universit�tstrasse 16
8092 Z�rich

Telefon: +41 44 632 32 36
andreas.h...@usys.ethz.ch

[[alternative HTML version deleted]]

___
R-packages mailing list
r-packa...@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-packages__
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] why must a named colClasses in read.table be in correct order

2015-07-08 Thread Andreas Leha
Hi Henrik,

Thanks for your reply.

I am not (yet) convinced, though.  The help page for read.table
mentions named colClasses and if I specify colClasses for not all
columns, the names are taken into account:

--8---cut here---start-8---
kkk - c(a\tb,
 3.14\tx)
str(read.table(textConnection(kkk),
   sep=\t,
   header = TRUE))

str(read.table(textConnection(kkk),
   sep=\t,
   header = TRUE,
   colClasses=c(b=character)))
--8---cut here---end---8---

What am I missing?

Best,
Andreas



On 09/07/2015 02:21, Henrik Bengtsson wrote:
 read.table() does not make use of names(colClasses) - only its values.
 Because of this, ordering is critical, as you noted. It shouldn't be
 too hard to add support for a named `colClasses` argument of
 utils::read.table(), but someone needs to convince the R core team
 that this is a good idea.
 
 As an alternative, see R.filesets::readDataFrame() for a
 read.table()-like function that matches names(colClasses) to column
 names, if they exists.
 
 /Henrik
 (author of R.filesets)
 
 On Wed, Jul 8, 2015 at 5:41 PM, Andreas Leha
 andreas.l...@med.uni-goettingen.de wrote:
 Hi all,

 Apparently, the colClasses argument to read.table needs to be in the
 order of the columns *even when it is named*.  Why is that?  And where
 would I find it in the documentation?

 Here is a MWE:

 --8---cut here---start-8---
 kkk - c(a\tb,
  3.14\tx)
 read.table(textConnection(kkk),
sep=\t,
header = TRUE)

 cclasses=c(b=character,
a=numeric)

 read.table(textConnection(kkk),
sep=\t,
header = TRUE,
colClasses = cclasses)  ## --- error

 read.table(textConnection(kkk),
sep=\t,
header = TRUE,
colClasses = cclasses[order(names(cclasses))])
 --8---cut here---end---8---


 Thanks,
 Andreas

 __
 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.

__
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] why must a named colClasses in read.table be in correct order

2015-07-08 Thread Andreas Leha
Hi Henrik,

Thank you very much for looking into this.  And thanks for the patch!

Yes, let's hope this is a typo that gets fixed.

Regards,
Andreas

Henrik Bengtsson henrik.bengts...@ucsf.edu writes:
 Thanks for insisting; I was wrong and I'm happy to see that there is
 indeed code intended for named 'colClasses', which even goes back to
 2004.   But as you report, then names only work when
 length(colClasses)  cols (which also explains why I though it was not
 supported).  I'm not sure if that _strictly less than_  test is
 intentional or a mistake, but I would propose the following patch:

 [HB-X201]{hb}: svn diff src\library\utils\R\readtable.R
 Index: src/library/utils/R/readtable.R
 ===
 --- src/library/utils/R/readtable.R (revision 68642)
 +++ src/library/utils/R/readtable.R (working copy)
 @@ -139,7 +139,7 @@
  if (rlabp) col.names - c(row.names, col.names)

  nmColClasses - names(colClasses)
 -if(length(colClasses)  cols)
 +if(length(colClasses) = cols)
  if(is.null(nmColClasses)) {
  colClasses - rep_len(colClasses, cols)
  } else {


 Your example works with this patch.  I've made it source():able so you
 can try it out (if you cannot source() https://, then download the
 file an source it locally):

 source(https://gist.githubusercontent.com/HenrikBengtsson/ed1eeb41a1b4d6c43b47/raw/ebe58f76e518dd014423bea466a5c93d2efd3c99/readtable-fix.R;)

 kkk - c(a\tb,
  3.14\tx)

 colClasses - c(a=numeric, b=character)
 data - read.table(textConnection(kkk),
sep=\t,
header = TRUE,
colClasses = colClasses)
 str(data)
 ### 'data.frame':   1 obs. of  2 variables:
 ### $ a: num 3.14
 ### $ b: chr x

 ## Does not work with utils::read.table(), but with patch
 data - read.table(textConnection(kkk),
sep=\t,
header = TRUE,
colClasses = rev(colClasses))
 str(data)
 ### 'data.frame':   1 obs. of  2 variables:
 ### $ a: num 3.14
 ### $ b: chr x

 Let's hope that the above is a (10-year old) typo, and changing a  to
 a = adds support for named 'colClasses', which is a really useful
 functionality.

 /Henrik

 On Wed, Jul 8, 2015 at 6:42 PM, Andreas Leha
 andreas.l...@med.uni-goettingen.de wrote:
 Hi Henrik,

 Thanks for your reply.

 I am not (yet) convinced, though.  The help page for read.table
 mentions named colClasses and if I specify colClasses for not all
 columns, the names are taken into account:

 --8---cut here---start-8---
 kkk - c(a\tb,
  3.14\tx)
 str(read.table(textConnection(kkk),
sep=\t,
header = TRUE))

 str(read.table(textConnection(kkk),
sep=\t,
header = TRUE,
colClasses=c(b=character)))
 --8---cut here---end---8---

 What am I missing?

 Best,
 Andreas



 On 09/07/2015 02:21, Henrik Bengtsson wrote:
 read.table() does not make use of names(colClasses) - only its values.
 Because of this, ordering is critical, as you noted. It shouldn't be
 too hard to add support for a named `colClasses` argument of
 utils::read.table(), but someone needs to convince the R core team
 that this is a good idea.

 As an alternative, see R.filesets::readDataFrame() for a
 read.table()-like function that matches names(colClasses) to column
 names, if they exists.

 /Henrik
 (author of R.filesets)

 On Wed, Jul 8, 2015 at 5:41 PM, Andreas Leha
 andreas.l...@med.uni-goettingen.de wrote:
 Hi all,

 Apparently, the colClasses argument to read.table needs to be in the
 order of the columns *even when it is named*.  Why is that?  And where
 would I find it in the documentation?

 Here is a MWE:

 --8---cut here---start-8---
 kkk - c(a\tb,
  3.14\tx)
 read.table(textConnection(kkk),
sep=\t,
header = TRUE)

 cclasses=c(b=character,
a=numeric)

 read.table(textConnection(kkk),
sep=\t,
header = TRUE,
colClasses = cclasses)  ## --- error

 read.table(textConnection(kkk),
sep=\t,
header = TRUE,
colClasses = cclasses[order(names(cclasses))])
 --8---cut here---end---8---


 Thanks,
 Andreas

 __
 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.

__
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

[R] why must a named colClasses in read.table be in correct order

2015-07-08 Thread Andreas Leha
Hi all,

Apparently, the colClasses argument to read.table needs to be in the
order of the columns *even when it is named*.  Why is that?  And where
would I find it in the documentation?

Here is a MWE:

--8---cut here---start-8---
kkk - c(a\tb,
 3.14\tx)
read.table(textConnection(kkk),
   sep=\t,
   header = TRUE)

cclasses=c(b=character,
   a=numeric)

read.table(textConnection(kkk),
   sep=\t,
   header = TRUE,
   colClasses = cclasses)  ## --- error

read.table(textConnection(kkk),
   sep=\t,
   header = TRUE,
   colClasses = cclasses[order(names(cclasses))])
--8---cut here---end---8---


Thanks,
Andreas

__
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] aov + pairwise.t.test: only selected pairs

2014-06-22 Thread Andreas Maunz
Thanks for the hint. I found out how to specify contrasts in multcomp using
function contrMat:
https://stats.stackexchange.com/questions/104028/r-multcomp-contrasts-for-tukey
This is about Tukey's test, but the principle is the same for all tests

However, it seems that repeated t-tests with pooled variance are not
supported in multcomp:
http://www.inside-r.org/packages/cran/multcomp/docs/contrMat

Am I wrong? If not, how could I do repeated t-tests for specific contrasts?

Thank you
Andreas



On Wed, Jun 11, 2014 at 10:28 AM, ONKELINX, Thierry 
thierry.onkel...@inbo.be wrote:

 Have a look at the multcomp package. The examples in glht() demonstrate
 how to specify the required contrasts.

 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 Andreas Maunz
 Verzonden: woensdag 11 juni 2014 10:02
 Aan: r-help@r-project.org
 Onderwerp: [R] aov + pairwise.t.test: only selected pairs

 Hi,

 I have a 1-way anova result and want to do a post test.

 I want to do pairwise t-tests where the global variance is taken into
 account (i.e. a real post test on the anova result, not multiple simple t
 tests on the samples).

 I understand I should use pairwise.t.test() for that. However, it does not
 allow me to select specific pairs, it always analyzes all pairs. How can I
 analyze specific pairs only?

 Thanks
 Andreas

 [[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.



[[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] multcomp: Contrasts for Tukey

2014-06-18 Thread Andreas Maunz
I want to use the glht function.

In the linfct argument, I provide my linear functions to be tested.
I provide contrasts there, such as (for example)
c(Group1 - Group2 = 0, Group1 - Group3 = 0)
to compare group no 1 against the other groups.

I want to do Tukey's test in this fashion. Is it possible? I saw I could do
(for example)
mcp(Group='Tukey')
for this, but this does all the pairwise comparisons and I want only
specific contrasts.
If not, how can I do it?

Thanks

[[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] aov + pairwise.t.test: only selected pairs

2014-06-11 Thread Andreas Maunz
Hi,

I have a 1-way anova result and want to do a post test.

I want to do pairwise t-tests where the global variance is taken into
account (i.e. a real post test on the anova result, not multiple simple t
tests on the samples).

I understand I should use pairwise.t.test() for that. However, it does not
allow me to select specific pairs, it always analyzes all pairs. How can I
analyze specific pairs only?

Thanks
Andreas

[[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] filename of current device

2014-05-19 Thread Andreas Leha


On 18/05/2014 18:08, Prof Brian Ripley wrote:
 On 14/05/2014 23:04, Andreas Leha wrote:
 Hi all,

 how do I find out about the filename, the currently open (let's say pdf)
 device is writing to?

 If I find 'dev.cur()' returning 'pdf 3' when I expect 'nulldevice 1' I
 would like to know, which file that pdf device is actually targeting.

 Any help for my poor organization is highly appreciated...
 
 You cannot know this for an arbitrary device, at least not from R.
 
 Most files in R are opened with the C call fopen() and thereafter
 referred to by a file handle: the file can be renamed, unlinked ...
 whilst the handle is open.  Some system utilities[*] may be able to tell
 you what filepaths are/were associated with file handles open in a
 process, but it cannot be done portably.
 
 However, in R-devel there is the possibility of a device recording extra
 information about itself.  See the NEWS item
 
 • Graphics devices can add attributes to their description in
   .Device and .Devices.  Several of those included with R use a
   filepath attribute.
 
 AFAIR the pdf() device does: let's see
 
 pdf('/tmp/foo.pdf')
 dev.cur()
 pdf
   2
 .Devices
 [[1]]
 [1] null device
 
 [[2]]
 [1] pdf
 attr(,filepath)
 [1] /tmp/foo.pdf
 
 
 There is at least one exception: for historical reasons locked in by
 undocumented use in package tkrplot, the win.metafile() device does
 include the file path in the device 'name'.
 
 [*] They have existed at least on Linux, Windows and OS X.
 


Very nice!  Thank you for pointing that out.  That's exactly what I was
hoping to see in R.  Good to know that this is already there.

Regards,
Andreas

__
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] filename of current device

2014-05-14 Thread Andreas Leha
Hi all,

how do I find out about the filename, the currently open (let's say pdf)
device is writing to?

If I find 'dev.cur()' returning 'pdf 3' when I expect 'nulldevice 1' I
would like to know, which file that pdf device is actually targeting.

Any help for my poor organization is highly appreciated...

Regards,
Andreas

__
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] filename of current device

2014-05-14 Thread Andreas Leha
Hi David,

Thank you for following up on that.

David Winsemius dwinsem...@comcast.net writes:

 On May 14, 2014, at 3:04 PM, Andreas Leha wrote:

 Hi all,
 
 how do I find out about the filename, the currently open (let's say pdf)
 device is writing to?
 
 If I find 'dev.cur()' returning 'pdf 3' when I expect 'nulldevice 1' I
 would like to know, which file that pdf device is actually targeting.
 
 Any help for my poor organization is highly appreciated...
 

 Have your read the help file for pdf()? The first argument is the default 
 naming mechanism:

 file = ifelse(onefile, Rplots.pdf, Rplot%03d.pdf)

 So if you call pdf() then it will write to the working directory with a named 
 constructed from those choices.


Sorry for being unclear.  I am aware of that.  My use case is, that
apparently, I have called pdf(somefile.pdf) somewhen during a long
lasting R session.

I tend to have separate R sessions open in parallel
for the project I am working on.  So, I can easily have R session open
that run for weeks.

So, when I return to an R session (when I got some additional data, I
was asking for, e.g.) after several days, I do not know what that call
was.  And for several reasons, the actual call (pdf(somefile.pdf))
might not even be visible in my R session.

In that situation, I would like to know, which is the open file for the
current device.

I hope that makes my question clearer.

Regards,
Andreas

__
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] filename of current device

2014-05-14 Thread Andreas Leha
Hi David,

David Winsemius dwinsem...@comcast.net writes:

 On May 14, 2014, at 3:44 PM, Andreas Leha wrote:

 Hi David,
 
 Thank you for following up on that.
 
 David Winsemius dwinsem...@comcast.net writes:
 
 On May 14, 2014, at 3:04 PM, Andreas Leha wrote:
 
 Hi all,
 
 how do I find out about the filename, the currently open (let's say pdf)
 device is writing to?
 
 If I find 'dev.cur()' returning 'pdf 3' when I expect 'nulldevice 1' I
 would like to know, which file that pdf device is actually targeting.
 
 Any help for my poor organization is highly appreciated...
 
 
 Have your read the help file for pdf()? The first argument is the default 
 naming mechanism:
 
 file = ifelse(onefile, Rplots.pdf, Rplot%03d.pdf)
 
 So if you call pdf() then it will write to the working directory with a 
 named constructed from those choices.
 
 
 Sorry for being unclear.  I am aware of that.  My use case is, that
 apparently, I have called pdf(somefile.pdf) somewhen during a long
 lasting R session.
 
 I tend to have separate R sessions open in parallel
 for the project I am working on.  So, I can easily have R session open
 that run for weeks.
 
 So, when I return to an R session (when I got some additional data, I
 was asking for, e.g.) after several days, I do not know what that call
 was.  And for several reasons, the actual call (pdf(somefile.pdf))
 might not even be visible in my R session.
 
 In that situation, I would like to know, which is the open file for the
 current device.

 Well, if you acheived success with the pdf() call by executing
 dev.off() then you closed that device. The previous device does leave
 behind a footprint but not the entire name of hte file or the
 contents.

 ?dev.prev

 old.dev -dev.prev()
 str(old.dev)
  Named int 5
  - attr(*, names)= chr pdf


 If you had not changed working directory you may be able to then look
 at all of the pdf files. You can get information with file,info()

 ?file.info



Thanks for the follow-up.  I take it, there is no 'easy' way in R to
achieve this.

The best solution (on unix systems) that I have come up with is this:
  system(paste(lsof -p, Sys.getpid(), | grep pdf))
(which obviously works only before dev.off())

I was hoping for some more reliable way to achieve this, but it'll work
for me.

Thanks again,
Andreas

__
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] transition from depends to imports

2014-05-09 Thread Andreas Leha
Hi all,

I am having trouble to do a particular transition from depends to
imports in one of my packages.

This packages uses 'wilcoxsign_test' from the 'coin' package.  And this
is the only function from the coin package that it uses (directly).

(Everything works fine, as long as my package depends on the coin
package.)

My guess was, that I would need to only import that function from the
coin package. (I.e. to move the coin package from Depends
to Imports in the DESCRIPTION and in the NAMESPACE do
'importFrom(coin,wilcoxsign_test)'.)

But then, calling wilcoxsign_test leads to this error:
,
| Error in formula2data(formula, data, subset, frame = parent.frame(), ...) : 
|   could not find function ModelEnvFormula
`

Now, formula2data is an unexported function in the coin package and
ModelEnvFormula is a (exported) function in modeltools.

So, I tried to import ModelEnvFormula from modeltools -- no avail.
And I tried to import formula2data from coin -- not possible
And I tried to import the whole coin package -- no avail.

So, here is the question:  How do I import 'wilcoxsign_test' from the
coin package in a way, that it is usable?

Many thanks in advance.

Regards,
Andreas

__
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] transition from depends to imports

2014-05-09 Thread Andreas Leha
Hi Duncan,

Thank you for your follow-up and fast response!

Duncan Murdoch murdoch.dun...@gmail.com writes:

 On 09/05/2014, 5:08 PM, Andreas Leha wrote:
 Hi all,

 I am having trouble to do a particular transition from depends to
 imports in one of my packages.

 This packages uses 'wilcoxsign_test' from the 'coin' package.  And this
 is the only function from the coin package that it uses (directly).

 (Everything works fine, as long as my package depends on the coin
 package.)

 My guess was, that I would need to only import that function from the
 coin package. (I.e. to move the coin package from Depends
 to Imports in the DESCRIPTION and in the NAMESPACE do
 'importFrom(coin,wilcoxsign_test)'.)

 But then, calling wilcoxsign_test leads to this error:
 ,
 | Error in formula2data(formula, data, subset, frame = parent.frame(), ...) :
 |   could not find function ModelEnvFormula
 `

 Now, formula2data is an unexported function in the coin package and
 ModelEnvFormula is a (exported) function in modeltools.

 So, I tried to import ModelEnvFormula from modeltools -- no avail.
 And I tried to import formula2data from coin -- not possible
 And I tried to import the whole coin package -- no avail.

 So, here is the question:  How do I import 'wilcoxsign_test' from the
 coin package in a way, that it is usable?


 Which version of the packages are you using?  The current version of
 coin imports ModelEnvFormula from modeltools, so it should be able to
 find that function.

 Duncan Murdoch

As it seems, the version I use(d) depends on modeltools.

,
|  packageDescription(coin)
| Package: coin
| Title: Conditional Inference Procedures in a Permutation Test Framework
| Date: 2013-04-26
| Version: 1.0-22
| Author: Torsten Hothorn, Kurt Hornik, Mark A. van de Wiel and Achim
| Zeileis
| Maintainer: Torsten Hothorn torsten.hoth...@r-project.org
| Description: Conditional inference procedures for the general
| independence problem including two-sample, K-sample
| (non-parametric ANOVA), correlation, censored, ordered and
| multivariate problems.
| Depends: R (= 2.2.0), methods, survival, mvtnorm (= 0.8-0),
| modeltools (= 0.2-9)
| Suggests: multcomp, xtable, e1071, vcd
| Enhances: Biobase
| LazyLoad: yes
| LazyData: yes
| License: GPL-2
| Packaged: 2013-04-26 12:33:15 UTC; hothorn
| NeedsCompilation: yes
| Repository: CRAN
| Date/Publication: 2013-04-26 15:27:04
| Built: R 3.0.1; x86_64-pc-linux-gnu; 2013-05-29 16:07:42 UTC; unix
| 
| -- File: /usr/lib/R/site-library/coin/Meta/package.rds 
`

I can confirm that updating coin (to version 1.1-0) did resolve my
problem.  Thank you very much!


This leads to the follow-up question:  How would I have correctly dealt
with this situation if my dependency ('coin') had not been updated?

Regards,
Andreas

__
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] transition from depends to imports

2014-05-09 Thread Andreas Leha
Duncan Murdoch murdoch.dun...@gmail.com writes:

 On 09/05/2014, 5:39 PM, Andreas Leha wrote:
 Hi Duncan,

 Thank you for your follow-up and fast response!

 Duncan Murdoch murdoch.dun...@gmail.com writes:

 On 09/05/2014, 5:08 PM, Andreas Leha wrote:
 Hi all,

 I am having trouble to do a particular transition from depends to
 imports in one of my packages.

 This packages uses 'wilcoxsign_test' from the 'coin' package.  And this
 is the only function from the coin package that it uses (directly).

 (Everything works fine, as long as my package depends on the coin
 package.)

 My guess was, that I would need to only import that function from the
 coin package. (I.e. to move the coin package from Depends
 to Imports in the DESCRIPTION and in the NAMESPACE do
 'importFrom(coin,wilcoxsign_test)'.)

 But then, calling wilcoxsign_test leads to this error:
 ,
 | Error in formula2data(formula, data, subset, frame = parent.frame(), 
 ...) :
 |   could not find function ModelEnvFormula
 `

 Now, formula2data is an unexported function in the coin package and
 ModelEnvFormula is a (exported) function in modeltools.

 So, I tried to import ModelEnvFormula from modeltools -- no avail.
 And I tried to import formula2data from coin -- not possible
 And I tried to import the whole coin package -- no avail.

 So, here is the question:  How do I import 'wilcoxsign_test' from the
 coin package in a way, that it is usable?


 Which version of the packages are you using?  The current version of
 coin imports ModelEnvFormula from modeltools, so it should be able to
 find that function.

 Duncan Murdoch

 As it seems, the version I use(d) depends on modeltools.

 ,
 |  packageDescription(coin)
 | Package: coin
 | Title: Conditional Inference Procedures in a Permutation Test Framework
 | Date: 2013-04-26
 | Version: 1.0-22
 | Author: Torsten Hothorn, Kurt Hornik, Mark A. van de Wiel and Achim
 | Zeileis
 | Maintainer: Torsten Hothorn torsten.hoth...@r-project.org
 | Description: Conditional inference procedures for the general
 | independence problem including two-sample, K-sample
 | (non-parametric ANOVA), correlation, censored, ordered and
 | multivariate problems.
 | Depends: R (= 2.2.0), methods, survival, mvtnorm (= 0.8-0),
 | modeltools (= 0.2-9)
 | Suggests: multcomp, xtable, e1071, vcd
 | Enhances: Biobase
 | LazyLoad: yes
 | LazyData: yes
 | License: GPL-2
 | Packaged: 2013-04-26 12:33:15 UTC; hothorn
 | NeedsCompilation: yes
 | Repository: CRAN
 | Date/Publication: 2013-04-26 15:27:04
 | Built: R 3.0.1; x86_64-pc-linux-gnu; 2013-05-29 16:07:42 UTC; unix
 |
 | -- File: /usr/lib/R/site-library/coin/Meta/package.rds
 `

 I can confirm that updating coin (to version 1.1-0) did resolve my
 problem.  Thank you very much!


 This leads to the follow-up question:  How would I have correctly dealt
 with this situation if my dependency ('coin') had not been updated?

 I think the only workaround would be for you to say your package
 Depends on modeltools.  It's really a coin issue, not yours, and the
 right people fixed it.


They did, indeed.  Thank you for the info and for your quick help on
this!

Regards,
Andreas

__
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] fitting a family of curves

2014-04-23 Thread andreas betz
Hello,

is it possible to fit a group of curves simultaneously to an equation with
some parameters shared among the curves others fit for each curve
individually. Several commercial software programs like Originlab have this
option often referred to as global fit. I would appreciate any advice or
referral to packages.


Thank you

Andreas

[[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] Problems with a R-packages

2014-01-24 Thread Andreas Rybicki
Bill,

Thanks for your answer.

With your advise I was able to download  ‘rjags’, ‘logspline’. Especially your 
tip install dependencies was extremely helpful AND certainly made it work.

Could I outline in this respect the following, please?

I also was able to install Xcode, because

The package lossDev appears only in the list under R package installation 
if I choose CRAN (sources), somehow not under CRAN (binaries).

Tried to install lossDev under sources and got the following messages, in 
quotation marks:


versuche URL 'http://cran.at.r-project.org/src/contrib/lossDev_3.0.0-4.tar.gz'
Content type 'application/x-gzip' length 1539914 bytes (1.5 Mb)
URL geöffnet
==
downloaded 1.5 Mb

* installing *source* package ‘lossDev’ ...
** Paket ‘lossDev’ erfolgreich entpackt und MD5 Summen überprüft
checking for prefix by checking for jags... no
configure: error: Location of JAGS headers not defined. Use configure arg 
'--with-jags-include' or environment variable 'JAGS_INCLUDE'
ERROR: configuration failed for package ‘lossDev’
* removing 
‘/Library/Frameworks/R.framework/Versions/3.0/Resources/library/lossDev’

Die heruntergeladenen Quellpakete sind in = TRANSLATED by me: The downloaded 
source packages are in

‘/private/var/folders/1d/7y5t0hy57q5bphrlsrgkq43hgp/T/RtmpoY8dls/downloaded_packages’
 


If it does not take too much of your time, maybe you could have a look at it?

AND: lossDev got no mark under installed version, but that is maybe obvious 
after the a/m R-message.

I think that I have to look for prof. help here in Germany.

Anyway, thanks for the time you spent on it,

Regards,

Andreas



Am 23.01.2014 um 18:21 schrieb William R Revelle:

 Andreas,
 You need to install those dependencies first.  
 That is,  ‘lossDev’  is not installed until you first
 . first install  ‘rjags’, ‘logspline’   but those probably require some other 
 dependencies as well.
 
 That is, when you try to install  ‘rjags’, ‘logspline’ 
 it will probably give you messages that you need some other packages.
 
 On a Mac, if you click the “install dependencies” option on the R Package  
 Installer window, this will do most of this for you.
 
 If you are installing sources, you will probably also need the Xcode 
 compiler.  It is easier to just install binaries.
 
 Bill
 
 
 
 On Jan 22, 2014, at 8:49 AM, Andreas Rybicki an.rybi...@t-online.de wrote:
 
 Hallo,
 
 Trust, that my request is one that can be posted under this mailing list
 
 Would like to install
 
 lossDev, Version in the Repository 3.0.0-4
 
 
 and I did it under CRAN(sources).
 
 get as response
 
 versuche URL 
 'http://cran.at.r-project.org/src/contrib/lossDev_3.0.0-4.tar.gz'
 Content type 'application/x-gzip' length 1539914 bytes (1.5 Mb)
 URL geöffnet
 ==
 downloaded 1.5 Mb
 
 ERROR: dependencies ‘rjags’, ‘logspline’ are not available for package 
 ‘lossDev’
 * removing 
 ‘/Library/Frameworks/R.framework/Versions/3.0/Resources/library/lossDev’
 
 Die heruntergeladenen Quellpakete sind in 
 
 ‘/private/var/folders/1d/7y5t0hy57q5bphrlsrgkq43hgp/T/RtmpipUlzT/downloaded_packages’
  
 
 Question: Was this download successful? Because in the 
 R-packages-installation-window, there appears no remark in the column 
 installed version, it is still blank.
 
 Next I tried to install rjags and logspline. Same result regarding 
 download.
 
 Even if this question is simple, any help highly appreciated.
 
 I am available via Skype too, to share my screen.
 
 Using MacBook Pro.
 
 Regards,
 
 Andreas
 
 
 
  [[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.
 
 William Revelle  
 http://personality-project.org/revelle.html
 Professorhttp://personality-project.org
 Department of Psychology   http://www.wcas.northwestern.edu/psych/
 Northwestern University  http://www.northwestern.edu/
 Use R for psychology http://personality-project.org/r
 It is 5 minutes to midnight  http://www.thebulletin.org
 
 
 
 
 


[[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] Problems with a R-packages

2014-01-22 Thread Andreas Rybicki
Hallo,

Trust, that my request is one that can be posted under this mailing list

Would like to install

lossDev, Version in the Repository 3.0.0-4


and I did it under CRAN(sources).

get as response

versuche URL 'http://cran.at.r-project.org/src/contrib/lossDev_3.0.0-4.tar.gz'
Content type 'application/x-gzip' length 1539914 bytes (1.5 Mb)
URL geöffnet
==
downloaded 1.5 Mb

ERROR: dependencies ‘rjags’, ‘logspline’ are not available for package 
‘lossDev’
* removing 
‘/Library/Frameworks/R.framework/Versions/3.0/Resources/library/lossDev’

Die heruntergeladenen Quellpakete sind in 
   
‘/private/var/folders/1d/7y5t0hy57q5bphrlsrgkq43hgp/T/RtmpipUlzT/downloaded_packages’
 

Question: Was this download successful? Because in the 
R-packages-installation-window, there appears no remark in the column 
installed version, it is still blank.

Next I tried to install rjags and logspline. Same result regarding download.

Even if this question is simple, any help highly appreciated.

I am available via Skype too, to share my screen.

Using MacBook Pro.

Regards,

Andreas



[[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] quickly extract response from formula

2013-11-01 Thread Andreas Leha
Hi David,

thanks for your quick answer!

David Winsemius dwinsem...@comcast.net writes:

 On Oct 31, 2013, at 1:27 PM, Andreas Leha wrote:

 Hi all,
 
 what is the recommended way to quickly (and without much burden on the
 memory) extract the response from a formula?

 If you want its expression value its just form[[2]]

 If you wnat it evaluated in the environment of a dataframe then this should 
 be fairly efficient:

 x - stats::runif(20)
 y - stats::runif(20)
 dfrm - data.frame(x=x,y=y)
 extractResponse - function(frm, dat) { resp - frm[[2]]; print(resp) # 
 that's optional
  fdat - eval(resp,
  envir=dat); return(fdat) }

This is what I'll be using.  Thanks again!

[...]

Regards,
Andreas

__
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] quickly extract response from formula

2013-11-01 Thread Andreas Leha
William Dunlap wdun...@tibco.com writes:

 You can bullet-proof it a bit by making sure that length(formula)==3
 before assuming that formula[[2]] is the response.   If length(formula)==2
 then there is no response term, only predictor terms.  E.g., replace
resp - frm[[2]]
 with
resp - if (length(frm)==3) frm[[2]] else NULL
 (or call stop(), or warning(), ...)

Will do.  Thanks.

- Andreas


 Bill Dunlap
 Spotfire, TIBCO Software
 wdunlap tibco.com


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
 Behalf
 Of Andreas Leha
 Sent: Friday, November 01, 2013 2:50 PM
 To: r-h...@stat.math.ethz.ch
 Subject: Re: [R] quickly extract response from formula
 
 Hi David,
 
 thanks for your quick answer!
 
 David Winsemius dwinsem...@comcast.net writes:
 
  On Oct 31, 2013, at 1:27 PM, Andreas Leha wrote:
 
  Hi all,
 
  what is the recommended way to quickly (and without much burden on the
  memory) extract the response from a formula?
 
  If you want its expression value its just form[[2]]
 
  If you wnat it evaluated in the environment of a dataframe then this 
  should be fairly
 efficient:
 
  x - stats::runif(20)
  y - stats::runif(20)
  dfrm - data.frame(x=x,y=y)
  extractResponse - function(frm, dat) { resp - frm[[2]]; print(resp) # 
  that's optional
   fdat - eval(resp,
   envir=dat); return(fdat) }
 
 This is what I'll be using.  Thanks again!
 
 [...]
 
 Regards,
 Andreas
 
 __
 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.


[R] quickly extract response from formula

2013-10-31 Thread Andreas Leha
Hi all,

what is the recommended way to quickly (and without much burden on the
memory) extract the response from a formula?

The standard way to extract the response from a formula seems to be via
model.frame() or model.extract(), but that is very memory intensive.

Here is a quick example, that (BEWARE) consumes a lot of memory:

--8---cut here---start-8---
require(ALL)
data(ALL)
y - pData(ALL)$sex
x - t(exprs(ALL))
mf - cbind(as.data.frame(x), y=y)

extractResponse - function(formula, data)
{
  m - match.call(expand.dots = FALSE)
  m[[1L]] - quote(stats::model.frame)
  m - eval.parent(m)
  y - model.extract(m, response)

  y
}
extractResponse(y~., data=mf)

extractResponseFast - function(formula, data)
{
  y - eval(as.symbol(as.character(formula)[2]),
environment(formula))

  y
}
extractResponseFast(y~., data=mf)
--8---cut here---end---8---



Or, to put my question differently, is the following approach
robust?

--8---cut here---start-8---
require(ALL)
data(ALL)
y - pData(ALL)$sex
x - t(exprs(ALL))
mf - cbind(as.data.frame(x), y=y)

extractResponseFast - function(formula, data)
{
  y - eval(as.symbol(as.character(formula)[2]),
environment(formula))

  y
}
extractResponseFast(y~., data=mf)
--8---cut here---end---8---


Many thanks in advance!

Regards,
Andreas

__
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 speed effect by using RcppArmadillo compared to R in matrix operations

2013-10-26 Thread Andreas Recktenwald

Hi,

another option if you're using Linux AND an Intel processor would be  
linking R against Intel MKL (Math Kernel Library). Under Linux you can  
get a (free) non-commercial licence for it.


Here I'm using an Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz laptop  
processor with R 3.0.2 build with intel compilers and linked against  
Intel MKL 11 and get the following times:



set.seed(123)
n - 2000
A-matrix(rnorm(n^2,0,1), n,n)
system.time(D-A%*%A%*%A+A)

   User  System verstrichen
  1.480   0.004   1.482

PS: I'm using the sequential version of Intel MKL.


Zitat von Timo Schmid timo_sch...@hotmail.com:


Hello,

I am looking for a way to do fast matrix operations (multiplication,  
Inversion) for
large matrices (n=8000) in R. I know R is not that fast in linear  
algebra than

other software.
So I wanted to write some code in C++ and incorporate this code in  
R. I have used the
package RcppArmadillo, because a lot of people write that it is  
really fast in

doing matrix algebra. So I have run a short example. See the code below.
I was wondering that I got almost the same CPU time for the matrix  
algebra in my

example. I expect that using C++ Code in R is faster than using the standard
matrix operations in R.

Is there a way to do matrix algebra in R faster as the standard  
command (e.g. %*%) using
the Rcpp or RcppArmadillo packages? I would be happy about any idea  
or advice.

Thanks in advance


  library(Rcpp)

library(RcppArmadillo)
library(inline)
library(RcppEigen)
library(devtools)

# Generation of the matrix
n=2000
A-matrix(rnorm(n^2,0,1), n,n)

# Code in R
system.time(

+ D-A%*%A%*%A+A)
   user  system elapsed
  12.290.01   12.33


# Code using RcppArmadillo
src -

+ '
+ arma::mat X = Rcpp::asarma::mat(X_);
+ arma::mat ans = X * X * X + X;
+ return(wrap(ans));
+ '

mprod6_inline_RcppArma - cxxfunction(signature(X_=numeric),

+   body = src, plugin=RcppArmadillo)


system.time(

+ C-mprod6_inline_RcppArma(X=A))
   user  system elapsed
  12.300.08   12.40


[[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.


[R] Heatmap with mouseover

2013-10-05 Thread Andreas Maunz
Dear all,

what is the recommended way to create heatmaps (or plots in general) with
mouseover-effect in R, so that I can embed it into a web app? Options I
have found so far are a) rCharts or b) sendplot. What are your experiences
and recommendations?

Thanks
Andreas

[[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] R function for censored linear regression

2013-09-24 Thread Andreas Wittmann

Dear R-useRs,

I'm looking for an R-function for censored linear regression. I have the 
following data


x1 - rnorm(100)
x2 - rnorm(100)
y - x1 + 2*x2 + rnorm(100,0,0.5)
stat - rep(1,100)
stat[50:100] - 0
data - data.frame(y,x1,x2,stat)

y is the dependent variable, x1 and x2 are the independent variables in 
a linear model. the variable y could be right-censored, this information 
is in the variable stat, where 1 denotes observed and 0 denotes 
censored. If stat is 0, then the value in y is the observed 
right-censored value and could be greater. Using the Tobit-model would 
not be the right thing here because the Tobit model assumes the same 
limit for all observations, in my data each value of y[50:100] could 
have a different limit.


If i use linear regression

lm1 - lm(y ~ x1 + x2, data=data)
summary(lm1)

the censoring is not incorporated, so my idea is to use survreg from the 
survival package


library(survival)
s1 - survreg(Surv(y, stat) ~ x1 + x2, data, dist='gaussian')
summary(s1)

my question is, is this the right approach for my aim? Is it right, that 
here each censored observations could have its own limit?


Thanks and best regards
Andreas

__
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] rgl snapshot on headless server

2013-09-17 Thread Andreas Maunz
I have now resorted to installing a full X server on the server and run a
screen there (i.e. log in a user automatically), whenever the server
restarts. Then I can set DISPLAY=:0 before starting R. Not the most elegant
solution but it works. Apart from Xvfb not working, I could also not find a
VNC server that would do it (tried XF4VNC and TigerVNC).

Thanks for your help anyway!
Andreas


On Sun, Sep 15, 2013 at 1:18 PM, Duncan Murdoch murdoch.dun...@gmail.comwrote:

 On 13-09-15 6:02 AM, Andreas Maunz wrote:

 The other write* options seem to limited to me. I am looking for a way
 to obtain a PS, or at least a PNG, since I develop a web application on
 a server that needs to grab the screenshot and create a written report
 with it. Starting my Xvfb like this:

 Xvfb :5 -screen 0 640x480x24 -ac +extension GLX +render -noreset -fbdir
 /tmp/foobar

 I can easily run glxgears and obtain nice snapshots of the gears via
 'xwud -in /tmp/foobar/Xvfb_screen0'. However, it just won't work for
 rgl! Given my test.R script with (taken from the doc of bg()):


 That does make it sound like an rgl problem.


 library('rgl')
 rgl.open()
 foo-readline('Enter to cont')
 bg3d(white)
 foo-readline('Enter to cont')
 rgl.bg http://rgl.bg(sphere=TRUE, color=c(black,green), lit=FALSE,

 back=lines )
 foo-readline('Enter to cont')
 rgl.bg http://rgl.bg(sphere=TRUE,

 texture=system.file(textures/**sunsleep.png, package=rgl),
 back=filled )
 foo-readline('Enter to cont')

 I can skip through the steps and check at each with xwud, but it just
 manages to draw the white background. The two last steps fail
 completely, I only receive a black screen. Sane for plot3d(), for example.

 Please help, if you can, it would be quite important to have this
 functionality


 I can't reproduce any of this, since I'm working on Windows, a system
 without Xvfb, and Mac OSX, where your Xvfb command fails with this error

 _XSERVTransmkdir: ERROR: euid != 0,directory /tmp/.X11-unix will not be
 created.

 (followed by a sequence of other errors).  So I'd like to fix this, but it
 just doesn't look feasible.  Perhaps you know some X11 expert who can tell
 you what rgl is doing wrong?

 Duncan Murdoch


 Thanks
 Andreas



 On Wed, Sep 11, 2013 at 6:19 PM, Duncan Murdoch
 murdoch.dun...@gmail.com 
 mailto:murdoch.duncan@gmail.**commurdoch.dun...@gmail.com
 wrote:

 On 11/09/2013 11:44 AM, Andreas Maunz wrote:

 I am running Xvfb now with

 -fbdir /some/path and
 -extension RANDR

 but rgl.snapshot is still not working.

 Any other idea? Since I can display the webGL successfully in
 firefox (so comes out correct), I assume there should be some
 way of converting it on the server side to some (vector) graphic
 file format?


 The .html file that writeWebGL produces could be considered to be
 that, but it's really mostly Javascript code, and I don't know
 anything other than a browser that can display it.  If you look at
 ?writeWebGL, you'll see links to various other ?write* files; they
 are all vector formats, but are all more limited than writeWebGL in
 what they can record.

 Duncan Murdoch


 Thanks
 Andreas




 On Tue, Sep 10, 2013 at 6:38 PM, Duncan Murdoch
 murdoch.dun...@gmail.com 
 mailto:murdoch.duncan@gmail.**commurdoch.dun...@gmail.com
 
 mailto:murdoch.duncan@gmail._**_com

 mailto:murdoch.duncan@gmail.**com murdoch.dun...@gmail.com
 wrote:

  On 10/09/2013 10:58 AM, Andreas Maunz wrote:

  Hi all,

  I have a shiny app, in which I want to use rgl's snapshot
  function. I am
  running Xvfb on my server so that rgl works. I start my
 shiny
  app as
  follows:

  echo Checking for Xvfb...
  pgrep -U username Xvfb  /dev/null 21

  if [ $? -gt 0 ]; then
 echo Starting Xvfb...
 Xvfb :7 -screen 0 1280x1024x24 
 sleep 2
  fi

  echo ...starting shiny
  export DISPLAY=:7; R --no-save --no-restore -e
  library('shiny');
  runApp('/path/to/app', port=8101)

  In the app, I do plot3d(), generate webGL and send the
 results
  to the
  browser. But the rgl.snapshot or rgl.postscript
 functionality
  do not work,
  i.e. they produce black or empty images. I assume this
 is due
  to Xvfb. Any
  chance I can create snapshots?


  rgl.snapshot requires the X server to maintain a frame
 buffer that
  it can read.   It looks as though something is going wrong
 with
  yours.  I don't use a system with Xvfb, so I can't really
 help

Re: [R] rgl snapshot on headless server

2013-09-15 Thread Andreas Maunz
The other write* options seem to limited to me. I am looking for a way to
obtain a PS, or at least a PNG, since I develop a web application on a
server that needs to grab the screenshot and create a written report with
it. Starting my Xvfb like this:

Xvfb :5 -screen 0 640x480x24 -ac +extension GLX +render -noreset -fbdir
/tmp/foobar

I can easily run glxgears and obtain nice snapshots of the gears via 'xwud
-in /tmp/foobar/Xvfb_screen0'. However, it just won't work for rgl! Given
my test.R script with (taken from the doc of bg()):

library('rgl')
rgl.open()
foo-readline('Enter to cont')
bg3d(white)
foo-readline('Enter to cont')
rgl.bg(sphere=TRUE, color=c(black,green), lit=FALSE, back=lines )
foo-readline('Enter to cont')
rgl.bg(sphere=TRUE, texture=system.file(textures/sunsleep.png,
package=rgl), back=filled )
foo-readline('Enter to cont')

I can skip through the steps and check at each with xwud, but it just
manages to draw the white background. The two last steps fail completely, I
only receive a black screen. Sane for plot3d(), for example.

Please help, if you can, it would be quite important to have this
functionality

Thanks
Andreas



On Wed, Sep 11, 2013 at 6:19 PM, Duncan Murdoch murdoch.dun...@gmail.comwrote:

 On 11/09/2013 11:44 AM, Andreas Maunz wrote:

 I am running Xvfb now with

 -fbdir /some/path and
 -extension RANDR

 but rgl.snapshot is still not working.

 Any other idea? Since I can display the webGL successfully in firefox (so
 comes out correct), I assume there should be some way of converting it on
 the server side to some (vector) graphic file format?


 The .html file that writeWebGL produces could be considered to be that,
 but it's really mostly Javascript code, and I don't know anything other
 than a browser that can display it.  If you look at ?writeWebGL, you'll see
 links to various other ?write* files; they are all vector formats, but are
 all more limited than writeWebGL in what they can record.

 Duncan Murdoch


 Thanks
 Andreas




 On Tue, Sep 10, 2013 at 6:38 PM, Duncan Murdoch 
 murdoch.dun...@gmail.commailto:
 murdoch.duncan@gmail.**com murdoch.dun...@gmail.com wrote:

 On 10/09/2013 10:58 AM, Andreas Maunz wrote:

 Hi all,

 I have a shiny app, in which I want to use rgl's snapshot
 function. I am
 running Xvfb on my server so that rgl works. I start my shiny
 app as
 follows:

 echo Checking for Xvfb...
 pgrep -U username Xvfb  /dev/null 21

 if [ $? -gt 0 ]; then
echo Starting Xvfb...
Xvfb :7 -screen 0 1280x1024x24 
sleep 2
 fi

 echo ...starting shiny
 export DISPLAY=:7; R --no-save --no-restore -e
 library('shiny');
 runApp('/path/to/app', port=8101)

 In the app, I do plot3d(), generate webGL and send the results
 to the
 browser. But the rgl.snapshot or rgl.postscript functionality
 do not work,
 i.e. they produce black or empty images. I assume this is due
 to Xvfb. Any
 chance I can create snapshots?


 rgl.snapshot requires the X server to maintain a frame buffer that
 it can read.   It looks as though something is going wrong with
 yours.  I don't use a system with Xvfb, so I can't really help,
 but you could try Googling to see if that turns anything up.

 rgl.postscript shouldn't need the X server, but it is limited in
 what it can display.

 Duncan Murdoch





[[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] rgl snapshot on headless server

2013-09-11 Thread Andreas Maunz
I am running Xvfb now with

-fbdir /some/path and
-extension RANDR

but rgl.snapshot is still not working.

Any other idea? Since I can display the webGL successfully in firefox (so
comes out correct), I assume there should be some way of converting it on
the server side to some (vector) graphic file format?

Thanks
Andreas



On Tue, Sep 10, 2013 at 6:38 PM, Duncan Murdoch murdoch.dun...@gmail.comwrote:

 On 10/09/2013 10:58 AM, Andreas Maunz wrote:

 Hi all,

 I have a shiny app, in which I want to use rgl's snapshot function. I am
 running Xvfb on my server so that rgl works. I start my shiny app as
 follows:

 echo Checking for Xvfb...
 pgrep -U username Xvfb  /dev/null 21

 if [ $? -gt 0 ]; then
echo Starting Xvfb...
Xvfb :7 -screen 0 1280x1024x24 
sleep 2
 fi

 echo ...starting shiny
 export DISPLAY=:7; R --no-save --no-restore -e library('shiny');
 runApp('/path/to/app', port=8101)

 In the app, I do plot3d(), generate webGL and send the results to the
 browser. But the rgl.snapshot or rgl.postscript functionality do not work,
 i.e. they produce black or empty images. I assume this is due to Xvfb. Any
 chance I can create snapshots?


 rgl.snapshot requires the X server to maintain a frame buffer that it can
 read.   It looks as though something is going wrong with yours.  I don't
 use a system with Xvfb, so I can't really help, but you could try Googling
 to see if that turns anything up.

 rgl.postscript shouldn't need the X server, but it is limited in what it
 can display.

 Duncan Murdoch



[[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] Problems installing FAME package on Windows 7.

2013-08-23 Thread Andreas Dibiasi
The CRAn binary is the first thing I tried. When using

install.packages(fame)
require(fame)

I get the following output:

under R x64:

 install.packages(fame)
Installing package into ‘C:/APPS/R/R-3.0.1/library’
(as ‘lib’ is unspecified)
trying URL 
'http://cran.rstudio.com/bin/windows/contrib/3.0/fame_2.18.zip'Content
type 'application/zip' length 107168 bytes (104 Kb)opened
URLdownloaded 104 Kb
package ‘fame’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Users\user\AppData\Local\Temp\Rtmpo1A2G1\downloaded_packages
require(fame)Lade nötiges Paket: fameLade nötiges Paket: tisError :
.onLoad in loadNamespace() für 'fame' fehlgeschlagen, Details:
  Aufruf: inDL(x, as.logical(local), as.logical(now), ...)
  Fehler: unable to load shared object 'C:/Program Files (x86)/FAME/chli.dll':
  LoadLibrary failure:  %1 is not a valid Win32 application.



and under R i386:

 require(fame)Lade nötiges Paket: fameLade nötiges Paket: tisError : .onLoad 
 in loadNamespace() für 'fame' fehlgeschlagen, Details:
  Aufruf: library.dynam(fame, package = fame)
  Fehler: argument lib.loc is missing, with no default


It is basically the same as using the package from source.

I checked the .onLoad function specified in the source package and there is
indeed no specification for lib.loc and no default specified. If I run the
function separatly and specify lib.loc as .libsPaths() the function seems
to work.
My .libPaths() are the following:

[1] C:/APPS/R/R-3.0.1/library C:/R/R-3.0.1/library

could this be an issue? which other environmental variable could be responsible?

Best,
Andreas Dibiasi



On 21 August 2013 18:05, Uwe Ligges lig...@statistik.tu-dortmund.de wrote:

 Probably something with your environment and/or your toolset.

 Does the CRAN binary work for you?

 i.e. just use

  install.packages(fame)

 and try it out..

 Best,
 Uwe Ligges




 On 20.08.2013 11:07, Andreas Dibiasi wrote:

 I have problems to install the FAME package. I have installed the fame
 client 9.3.32.2 and the environmental variable is set. However, for
 some reason, the warnings error: argument lib.loc  is missing,
 with no default pops up under the i386 installation and LoadLibrary
 failure:  %1 is not a valid Win32 application under x64. Has anyone
 experienced similar problems and know the a way how to solve it?


 R version 3.0.1 (2013-05-16) -- Good Sport
 Copyright (C) 2013 The R Foundation for Statistical Computing
 Platform: x86_64-w64-mingw32/x64 (64-bit)

 R is free software and comes with ABSOLUTELY NO WARRANTY.
 You are welcome to redistribute it under certain conditions.
 Type 'license()' or 'licence()' for distribution details.

 R is a collaborative project with many contributors.
 Type 'contributors()' for more information and
 'citation()' on how to cite R or R packages in publications.

 Type 'demo()' for some demos, 'help()' for on-line help, or
 'help.start()' for an HTML browser interface to help.
 Type 'q()' to quit R.


  install.packages(fame, repos = http://cran.r-project.org/;,
 type=source)Installing package into ‘C:/APPS/R/R-3.0.1/library’

 (as ‘lib’ is unspecified)trying URL
 'http://cran.r-project.org/**src/contrib/fame_2.18.tar.gz'**Contenthttp://cran.r-project.org/src/contrib/fame_2.18.tar.gz'Contenttype
 'application/x-gzip' length 51940 bytes (50 Kb)opened URLdownloaded 50

 Kb
 * installing *source* package 'fame' ...
 ** Paket 'fame' erfolgreich entpackt und MD5 Summen überprüft
 ** libs

 *** arch - i386
 cygwin warning:
MS-DOS style path detected: C:/R/R-30~1.1/etc/i386/**Makeconf
Preferred POSIX equivalent is: /cygdrive/c/R/R-30~1.1/etc/**
 i386/Makeconf
CYGWIN environment variable option nodosfilewarning turns off this
 warning.
Consult the user's guide for more details about POSIX paths:
  
 http://cygwin.com/cygwin-ug-**net/using.html#using-pathnameshttp://cygwin.com/cygwin-ug-net/using.html#using-pathnames
 gcc -m32 -IC:/R/R-30~1.1/include -DNDEBUG -Dfame -DDUMMY_CALLS
 -Id:/RCompile/CRANpkg/**extralibs64/local/include -O3 -Wall
 -std=gnu99 -mtune=core2 -c chli.c -o chli.o
 gcc -m32 -IC:/R/R-30~1.1/include -DNDEBUG -Dfame -DDUMMY_CALLS
 -Id:/RCompile/CRANpkg/**extralibs64/local/include -O3 -Wall
 -std=gnu99 -mtune=core2 -c fame.c -o fame.o
 gcc -m32 -shared -s -static-libgcc -o fame.dll tmp.def chli.o fame.o
 -Ld:/RCompile/CRANpkg/**extralibs64/local/lib/i386
 -Ld:/RCompile/CRANpkg/**extralibs64/local/lib -LC:/R/R-30~1.1/bin/i386
 -lR
 C:\Rtools\gcc-4.6.3\bin\nm.**exe: chli.c: File format not recognized
 gcc -m32 -shared -s -static-libgcc -o chli.dll chli.def chli.c
 -Ld:/RCompile/CRANpkg/**extralibs64/local/lib/i386
 -Ld:/RCompile/CRANpkg/**extralibs64/local/lib
 -LC:/R/R-30~1.1/bin/i386 -lR
 installing to C:/APPS/R/R-3.0.1/library/**fame/libs/i386

 *** arch - x64
 cygwin warning:
MS-DOS style path detected: C:/R/R-30~1.1/etc/x64/Makeconf
Preferred POSIX equivalent is: /cygdrive/c/R/R-30~1.1/etc/**
 x64/Makeconf

[R] Problems installing FAME package on Windows 7.

2013-08-20 Thread Andreas Dibiasi
I have problems to install the FAME package. I have installed the fame
client 9.3.32.2 and the environmental variable is set. However, for
some reason, the warnings error: argument lib.loc  is missing,
with no default pops up under the i386 installation and LoadLibrary
failure:  %1 is not a valid Win32 application under x64. Has anyone
experienced similar problems and know the a way how to solve it?


R version 3.0.1 (2013-05-16) -- Good Sport
Copyright (C) 2013 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.


 install.packages(fame, repos = http://cran.r-project.org/;, 
 type=source)Installing package into ‘C:/APPS/R/R-3.0.1/library’
(as ‘lib’ is unspecified)trying URL
'http://cran.r-project.org/src/contrib/fame_2.18.tar.gz'Content type
'application/x-gzip' length 51940 bytes (50 Kb)opened URLdownloaded 50
Kb
* installing *source* package 'fame' ...
** Paket 'fame' erfolgreich entpackt und MD5 Summen überprüft
** libs

*** arch - i386
cygwin warning:
  MS-DOS style path detected: C:/R/R-30~1.1/etc/i386/Makeconf
  Preferred POSIX equivalent is: /cygdrive/c/R/R-30~1.1/etc/i386/Makeconf
  CYGWIN environment variable option nodosfilewarning turns off this warning.
  Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
gcc -m32 -IC:/R/R-30~1.1/include -DNDEBUG -Dfame -DDUMMY_CALLS
-Id:/RCompile/CRANpkg/extralibs64/local/include -O3 -Wall
-std=gnu99 -mtune=core2 -c chli.c -o chli.o
gcc -m32 -IC:/R/R-30~1.1/include -DNDEBUG -Dfame -DDUMMY_CALLS
-Id:/RCompile/CRANpkg/extralibs64/local/include -O3 -Wall
-std=gnu99 -mtune=core2 -c fame.c -o fame.o
gcc -m32 -shared -s -static-libgcc -o fame.dll tmp.def chli.o fame.o
-Ld:/RCompile/CRANpkg/extralibs64/local/lib/i386
-Ld:/RCompile/CRANpkg/extralibs64/local/lib -LC:/R/R-30~1.1/bin/i386
-lR
C:\Rtools\gcc-4.6.3\bin\nm.exe: chli.c: File format not recognized
gcc -m32 -shared -s -static-libgcc -o chli.dll chli.def chli.c
-Ld:/RCompile/CRANpkg/extralibs64/local/lib/i386
-Ld:/RCompile/CRANpkg/extralibs64/local/lib
-LC:/R/R-30~1.1/bin/i386 -lR
installing to C:/APPS/R/R-3.0.1/library/fame/libs/i386

*** arch - x64
cygwin warning:
  MS-DOS style path detected: C:/R/R-30~1.1/etc/x64/Makeconf
  Preferred POSIX equivalent is: /cygdrive/c/R/R-30~1.1/etc/x64/Makeconf
  CYGWIN environment variable option nodosfilewarning turns off this warning.
  Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
gcc -m64 -IC:/R/R-30~1.1/include -DNDEBUG -Dfame -DDUMMY_CALLS
-Id:/RCompile/CRANpkg/extralibs64/local/include -O2 -Wall
-std=gnu99 -mtune=core2 -c chli.c -o chli.o
gcc -m64 -IC:/R/R-30~1.1/include -DNDEBUG -Dfame -DDUMMY_CALLS
-Id:/RCompile/CRANpkg/extralibs64/local/include -O2 -Wall
-std=gnu99 -mtune=core2 -c fame.c -o fame.o
gcc -m64 -shared -s -static-libgcc -o fame.dll tmp.def chli.o fame.o
-Ld:/RCompile/CRANpkg/extralibs64/local/lib/x64
-Ld:/RCompile/CRANpkg/extralibs64/local/lib -LC:/R/R-30~1.1/bin/x64
-lR
C:\Rtools\gcc-4.6.3\bin\nm.exe: chli.c: File format not recognized
gcc -m64 -shared -s -static-libgcc -o chli.dll chli.def chli.c
-Ld:/RCompile/CRANpkg/extralibs64/local/lib/x64
-Ld:/RCompile/CRANpkg/extralibs64/local/lib
-LC:/R/R-30~1.1/bin/x64 -lR
installing to C:/APPS/R/R-3.0.1/library/fame/libs/x64
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
*** arch - i386
Error : .onLoad failed in loadNamespace() for 'fame', details:
  call: library.dynam(fame, package = fame)
  error: Argument lib.loc fehlt (ohne Standardwert)
Fehler: Laden fehlgeschlagen
Ausführung angehalten
*** arch - x64
Error : .onLoad failed in loadNamespace() for 'fame', details:
  call: inDL(x, as.logical(local), as.logical(now), ...)
  error: kann shared object 'C:/Program Files (x86)/FAME/chli.dll' nicht laden:
  LoadLibrary failure:  %1 is not a valid Win32 application.

Fehler: Laden fehlgeschlagen
Ausführung angehalten
ERROR: loading failed for 'i386', 'x64'
* removing 'C:/APPS/R/R-3.0.1/library/fame'
* restoring previous 'C:/APPS/R/R-3.0.1/library/fame'
Warning in install.packages :
  running command 'C:/R/R-30~1.1/bin/x64/R CMD INSTALL -l
C:\APPS\R\R-3.0.1\library
C:\Users\user\AppData\Local\Temp\RtmpsbCarY/downloaded_packages/fame_2.18.tar.gz'
had status 1
Warning in install.packages :
  installation of package ‘fame’ had non-zero 

[R] suppress startup messages from default packages

2013-07-15 Thread Andreas Leha
Hi all,

several packages print messages during loading.  How do I avoid to see
them when the packages are in the defaultPackages?

Here is an example.

With this in ~/.Rprofile
,[ ~/.Rprofile ]
| old - getOption(defaultPackages)
| options(defaultPackages = c(old, filehash))
| rm(old)
`

I get as last line when starting R:
,
| filehash: Simple key-value database (2.2-1 2012-03-12)
`

Another package with (even more) prints during startup is tikzDevice.

How can I avoid to get these messages?

Regards,
Andreas

__
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] suppress startup messages from default packages

2013-07-15 Thread Andreas Leha
Hi Helios,

Helios de Rosario helios.derosa...@ibv.upv.es writes:

 Hi all,
 
 several packages print messages during loading.  How do I avoid to
 see
 them when the packages are in the defaultPackages?
 
 Here is an example.
 
 With this in ~/.Rprofile
 ,[ ~/.Rprofile ]
 | old - getOption(defaultPackages)
 | options(defaultPackages = c(old, filehash))
 | rm(old)
 `
 
 I get as last line when starting R:
 ,
 | filehash: Simple key-value database (2.2-1 2012-03-12)
 `
 
 Another package with (even more) prints during startup is
 tikzDevice.
 
How can I avoid to get these messages?


 There are several options in ?library to control the messages that are
 displayed when loading packages. However, this does not seem be able to
 supress all the messages. Some messages are defined by the package
 authors, because they feel necessary that the user reads them.



Thanks for your answer.  When I actually call library() or require()
myself I can avoid all messages.  There are hacks to do that even for
the very persistent messages [fn:1].

My question is how to suppress these messages, when it is not me who
calls library() or require(), but when the package is loaded during R's
startup through the defaultPackages option.

Regards,
Andreas

Footnotes:

[fn:1] http://stackoverflow.com/a/8143671/1844418

__
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] suppress startup messages from default packages

2013-07-15 Thread Andreas Leha
Hi David,

David Winsemius dwinsem...@comcast.net writes:

 On Jul 15, 2013, at 4:11 AM, Andreas Leha wrote:

 Hi all,
 
 several packages print messages during loading.  How do I avoid to see
 them when the packages are in the defaultPackages?

 I'm pretty sure this has been asked before (although the wrinkle of
 adding a package to default packages may not have been part of that
 discussion.)  Have you done any searching of the Archives?
 
 Here is an example.
 
 With this in ~/.Rprofile
 ,[ ~/.Rprofile ]
 | old - getOption(defaultPackages)
 | options(defaultPackages = c(old, filehash))
 | rm(old)
 `
 
 I get as last line when starting R:
 ,
 | filehash: Simple key-value database (2.2-1 2012-03-12)
 `
 
 Another package with (even more) prints during startup is tikzDevice.
 
 How can I avoid to get these messages?

 On my machine typing suppresstab brings up an option of:

  suppressPackageStartupMessages

 You should append a leading ? and read further.

I have only just now gotten your answer.  Thanks for responding.

As I already said in response to another message [fn:1] the 'wrinkle of
adding a package to default packages' is what my question really is
about.  Sorry if I was unclear.

Thanks to a very helpful answer proposing a solution using hooks [fn:2],
I was actually able to solve my 'problem' with the filehash package.

Regards,
Andreas


Footnotes:

[fn:1] http://permalink.gmane.org/gmane.comp.lang.r.general/296275

[fn:2] http://permalink.gmane.org/gmane.comp.lang.r.general/296281

__
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] suppress startup messages from default packages

2013-07-15 Thread Andreas Leha
Hi Martin,

Martin Morgan mtmor...@fhcrc.org writes:

 On 07/15/2013 06:25 AM, Duncan Murdoch wrote:
 On 15/07/2013 8:49 AM, Andreas Leha wrote:
 Hi Helios,

 Helios de Rosario helios.derosa...@ibv.upv.es writes:

  Hi all,
 
  several packages print messages during loading.  How do I avoid to
  see
  them when the packages are in the defaultPackages?
 
  Here is an example.
 
  With this in ~/.Rprofile
  ,[ ~/.Rprofile ]
  | old - getOption(defaultPackages)
  | options(defaultPackages = c(old, filehash))
  | rm(old)
  `
 
  I get as last line when starting R:
  ,
  | filehash: Simple key-value database (2.2-1 2012-03-12)
  `
 
  Another package with (even more) prints during startup is
  tikzDevice.
 
 How can I avoid to get these messages?
 
 
  There are several options in ?library to control the messages that are
  displayed when loading packages. However, this does not seem be able to
  supress all the messages. Some messages are defined by the package
  authors, because they feel necessary that the user reads them.
 


 Thanks for your answer.  When I actually call library() or require()
 myself I can avoid all messages.  There are hacks to do that even for
 the very persistent messages [fn:1].

 My question is how to suppress these messages, when it is not me who
 calls library() or require(), but when the package is loaded during R's
 startup through the defaultPackages option.

 You could try the --slave command line option on startup.  If that isn't
 sufficient, try getting the maintainer to change the package behaviour, or 
 do it
 yourself.

 In a hack-y way ?setHook and ?sink seem to work

 setHook(packageEvent(filehash, onLoad), function(...) 
 sink(file(tempfile(), w), type=message))
 setHook(packageEvent(filehash, attach), function(...)
 sink(file=NULL, 
 type=message), append)
 library(filehash)


 Martin


Thanks a lot for this really helpful answer!  Even if that is hack-y, I
am using this now and it solves my 'problem' with the filehash package.

Regards,
Andreas

__
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] problems with setClass or/and setMethod

2013-06-10 Thread andreas betz
Hello,

I am working my way through A (not so) Short introduction to S4

I created a class

setClass(Class = Trajectories,
 representation = representation(times = numeric,traj = matrix))

and tried to build a method using

setMethod(
  f = plot,
  signature = Trajectories,
  definition = function(X, y, ...){
matplot(x@times, t(x@traj), xaxt = n, type = l, ylab = ,
xlab = , pch = 1)
axis(1, at = x@times)
  }
)

R responds with an error message:

Creating a generic function for ‘plot’ from package ‘graphics’ in the
global environment
Error in conformMethod(signature, mnames, fnames, f, fdef, definition) :
  in method for ‘plot’ with signature ‘x=Trajectories’: formal arguments
(x = Trajectories, y = Trajectories, ... = Trajectories) omitted in
the method definition cannot be in the signature

Did anything change in the transition to R-3.0?

is there any other, more recent introduction to S4 classes recommended?

Thank you

for your help.

Andreas

[[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] R web application development

2013-03-19 Thread Andreas Recktenwald
Am 19.03.2013 01:11, schrieb John linux-user:
 Thanks for reply, but which archives?

 Thanks again.
   John


 
   From: Stephen Sefick ssef...@gmail.com

 Cc: r-help@r-project.org r-help@r-project.org
 Sent: Monday, March 18, 2013 8:02 PM
 Subject: Re: [R] R web application development

 I can't offer any advice, but I feel like you could probably get a good start 
 on this by looking through the archives.

 On Mon 18 Mar 2013 06:55:33 PM CDT, John linux-user wrote:
 Dear all,

 I am wondering if what would be the simple way to develop a simple web 
 application that runs R. That is, the web application allows any user upload 
 a dataframe as a variable to my web server, a linux-based apache, and then 
 run a R package (my package) on the variable that should ideally be handled 
 as a variable in memory instead of saving to the disk in my server , for 
 security concern. After running, the result would be returned to the web. 
 Any suggestion will be appreciated.

 Best,

 John
 [[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.
   [[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.
Hi,
have you tried the 'shiny' and 'shiny-server'  packages by Rstudio?
http://www.rstudio.com/shiny/

-- 
Dipl.-Kfm. Andreas Recktenwald

  

Universität des Saarlandes -- Fakultät für Rechts- und
Wirtschaftswissenschaften

Lehrstuhl für Statistik und Ökonometrie

Campus C3 1, Zimmer 206

66123 Saarbrücken

Tel.: ++49681 -- 302 3571


[[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] Function ar() in package stats: AIC procedure and time series length

2013-03-11 Thread Andreas Klein
 - min(xaic)
    names(xaic) - 0L:order.max
    resid - cal.resid()
    if(order) {
        ar - -ar[2L:(order + 1L), , , drop = FALSE]
        dimnames(ar) - list(seq_len(order), snames, snames)
    } else ar - array(0, dim=c(0L, nser, nser), dimnames=list(NULL, snames, 
snames))
    colnames(resid) - colnames(x)
    order
}


#Data for the example
x - c(-0.00658,  0.00802,  0.00642,  0.00412, -0.00618,  0.00462, -0.00168, 
-0.00148, -0.00108, -0.00608, -0.00058, -0.00318, -0.00528, -0.00218, -0.00688, 
 0.00022,  0.00472, -0.00028,  0.00362,  0.00122,  0.00852, -0.00118)
y - c(-0.0046,  0.0018,  0.0088,  0.0051, -0.0020,  0.0018,  0.0083, -0.0012,  
0.0096, -0.0014, -0.0035, -0.0107, -0.0052, -0.0027, -0.0095,  0.0008,  0.0070, 
-0.0018,  0.0031, -0.0019,  0.0097, -0.0022)

#Calculations
ar(cbind(x, y))$order #m=0

var.yw.aic.original(cbind(x, y)) #m=0

var.yw.aic.modified(cbind(x, y)) #m=13



Is my understanding of the function calc.aic() inside ar() wrong? I hope 
someone can help me to understand why ar() uses n.used instead of nser * 
n.used?


Best
Andreas


__
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] Ordered Probit/Logit with random coefficients

2013-01-21 Thread Andreas Karpf
Hello,

I searched everywhere but I didn't find what I want, that is why I as the
question here. Threads discussing this issue on this mailing list are
already quite old. Does anybody know of a function in R which allows to
estimate ordered probit/logit model with random coefficients.

The only mixed effect model I found was clmm of the ordinal package but it
only provides random intercepts. I am grateful for every hint!

Best regards,

AK
 andreas.ka...@malix.univ-paris.fr

[[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] Parameter estimates for each observation (ordered choice)

2013-01-09 Thread Andreas Karpf
I have several demographic variables with which I want to explain the
ordered choice of individuals within a survey in an ordered choice (probit
or logit, this is not important) framework. Standard ordered choice
estimations of course just give me aggregate/average parameter estimates.
For my task it would however be useful to estimate or extract hypothetical
individual-level parameter estimates (betas) for a certain independent
variable and each individual in the survey.

I have experimented with hierarchical Bayes algorithms provided by the
bayesm and ChoiceModelR. Correct me if I am wrong but I think these
techniques also demand that individuals to appear several times within a
survey (thus it should be a panel) and are confronted with different choice
situations, so that one can estimate the influence of certain attributes on
the individuals choices. Anyway ChoiceModelR and bayesm just provide
multinomial choice models while I am seeking for an ordinal probit.

My data however doesn't have any panel structure. I was also experimenting
with Bayesian inference in example by the MCMCoprobit function in the
MCMCpack package, but this function just simulates betas. I can't however,
as far as I know, attribute them to certain individuals in the survey, which
would be good. I would be very glad if somebody could give me a hint,
sometimes already a catchword is helpful to google the correct solution!
Thanks and best regards,

AK

P.S.: the last thing I tried was Compound Hierarchical Ordered Probit
(CHOPIT) because with that I am able to calculate individual cut-off points
which maybe allow be to calculate individual betas. but i didn't try it
exetnsively yet.

[[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] sqldf Date problem

2012-11-04 Thread Andreas Recktenwald


Zitat von jim holtman jholt...@gmail.com:


Most likely your Date is either a character or a factor (you need to
provide an 'str' of the dataframe).  You are therefore most likely
doing a character compare and that is the reason for your problem.
You need to convert to a character string of the format -MM-DD to
do the correct character comparison.

##

x - data.frame(Date = paste0('1/', 1:31, '/2011'))
str(x)

'data.frame':   31 obs. of  1 variable:
 $ Date: Factor w/ 31 levels 1/1/2011,1/10/2011,..: 1 12 23 26 27
28 29 30 31 2 ...

x

Date
1   1/1/2011
2   1/2/2011
3   1/3/2011
4   1/4/2011
5   1/5/2011
6   1/6/2011
7   1/7/2011
8   1/8/2011
9   1/9/2011
10 1/10/2011
11 1/11/2011
12 1/12/2011
13 1/13/2011
14 1/14/2011
15 1/15/2011
16 1/16/2011
17 1/17/2011
18 1/18/2011
19 1/19/2011
20 1/20/2011
21 1/21/2011
22 1/22/2011
23 1/23/2011
24 1/24/2011
25 1/25/2011
26 1/26/2011
27 1/27/2011
28 1/28/2011
29 1/29/2011
30 1/30/2011
31 1/31/2011


require(sqldf)
# not correct because of character compares
sqldf('select * from x where Date  1/13/2011 and Date  1/25/2011')

Date
1   1/2/2011
2  1/14/2011
3  1/15/2011
4  1/16/2011
5  1/17/2011
6  1/18/2011
7  1/19/2011
8  1/20/2011
9  1/21/2011
10 1/22/2011
11 1/23/2011
12 1/24/2011

# convert the date to /MM/DD for character compares
x$newDate - as.character(as.Date(as.character(x$Date), format =  
%m/%d/%Y))

# now do the select
sqldf('select * from x where newDate between 2011-01-13 and 2011-01-25')

DatenewDate
1  1/13/2011 2011-01-13
2  1/14/2011 2011-01-14
3  1/15/2011 2011-01-15
4  1/16/2011 2011-01-16
5  1/17/2011 2011-01-17
6  1/18/2011 2011-01-18
7  1/19/2011 2011-01-19
8  1/20/2011 2011-01-20
9  1/21/2011 2011-01-21
10 1/22/2011 2011-01-22
11 1/23/2011 2011-01-23
12 1/24/2011 2011-01-24
13 1/25/2011 2011-01-25


On Sat, Nov 3, 2012 at 4:22 PM, Andreas Recktenwald
a.recktenw...@mx.uni-saarland.de wrote:

Dear R-help readers,

i've created a database for quotes data (for 4 years; 2007 -- 2010) with the
sqldf package. This database contains a column Date in the format
mm/dd/.

The table in the database is called main.data and the database itself
Honda. I tried to get the Data just for certain period, say from
01/01/2007 until 01/10/2007 with the following code:

sqldf(select * from main.data where Date='01/10/2007' and
Date='01/01/2007'),
   dbname=Honda)


I get the data for this period for every year(2007,2008,2009,2010) not only
for 2007. It seems that the year is overlooked and just looked for the
fitting days and months.

Because I haven't really much experience with sql I decide to send my
problem to the list.

Many thanks in advance.

__
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.




--
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.



Thanks for your quick response Jim,

you are right the entries in my Date column are characters (my fault  
not to mention this in my first post).



Now i know the reasons for my problem and can solve it.

__
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] sqldf Date problem

2012-11-03 Thread Andreas Recktenwald


Dear R-help readers,

i've created a database for quotes data (for 4 years; 2007 -- 2010)  
with the sqldf package. This database contains a column Date in the  
format mm/dd/.


The table in the database is called main.data and the database  
itself Honda. I tried to get the Data just for certain period, say  
from 01/01/2007 until 01/10/2007 with the following code:


sqldf(select * from main.data where Date='01/10/2007' and  
Date='01/01/2007'),

   dbname=Honda)


I get the data for this period for every year(2007,2008,2009,2010) not  
only for 2007. It seems that the year is overlooked and just looked  
for the fitting days and months.


Because I haven't really much experience with sql I decide to send my  
problem to the list.


Many thanks in advance.

__
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] sqldf Date problem

2012-11-03 Thread Andreas Recktenwald

Dear R-help readers,

i've created a database for quotes data (for 4 years; 2007 -- 2010)  
with the sqldf package. This database contains a column Date in the  
format mm/dd/.


The table in the database is called main.data and the database  
itself Honda. I tried to get the Data just for certain period, say  
from 01/01/2007 until 01/10/2007 with the following code:


sqldf(select * from main.data where Date='01/10/2007' and  
Date='01/01/2007'),

   dbname=Honda)


I get the data for this period for every year(2007,2008,2009,2010) not  
only for 2007. It seems that the year is overlooked and just looked  
for the fitting days and months.


Because I haven't really much experience with sql I decide to send my  
problem to the list.


Many thanks in advance.

__
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] segfault in gplots::heatmap.2

2012-08-30 Thread Andreas Leha
Hi all,

I experience a segfault when calling gplots::heatmap.2(), but only when
certain other packages are loaded.

I am not sure for the correct place to send this bug report.  Should I send
it to the package maintainers directly?  If R-help is the wrong place,
please feel free to direct me to the correct one.

I am on debian (testing) linux 64 with the binary R distribution
from the repositories (version 2.15.1).

Below follows a simple reproducible example causing the segfault on my
machine.
The offending dataset is quite big, so instead of posting it here I put
it here: https://gist.github.com/3523761.  Please put it into offending.txt to
make the code below working.

This is the example.  Note, that without loading 'XLConnect' this works
nicely.
#+begin_src R
  library(gplots)
  library(XLConnect) # any of XLConnect, venneuler, xlsx case a segfault
  
  offending - dget(offending.txt)
  heatmap.2(x=offending)
#+end_src

Interestingly, I get a segfault when loading any of c(XLConnect,
venneuler, xlsx), which all depend on rJava.  But loading rJava on
its own did not produce a segfault.

Regards,
Andreas

__
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] Generate distribution from asymmetrical confidence interval and mean

2012-03-28 Thread Andreas Emanuelsson
Hi everyone, does anyone know a god way or package to generate a distribution 
satisfying a given Mean + asymmetrical Upper and Lower 95% confidence interval?

Approximately lognormal distributions but not necessary.

In my case I have a set of 42 means with UCL and LCL limits, and the data is 
more and less right skewed in each case, and I need the distributions to 
simulate joint uncertainty of a model using these inputs (Monte Carlo).

Best regards

Andreas




[[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] julian() and numerical noise

2012-03-24 Thread Andreas Eckner
Thanks for the help. A workaround seems indeed easy to write, for 
example, by rounding the the value of 'm' inside 
chron:::julian.default(), or only passing integers to the function.


I never intended to use a case involving a quadrillionth of a day, but 
encountered the problem when converting a dates in .MM format to a 
CHRON object. Here is an example for future reference (the output might 
be highly system-dependent):


   library(chron)
   date - 2012.02
   y - floor(date)
   m - (date %% 1) * 100
   julian(2, 1, 2012) - julian(m, 1, y)
[1] 1

~Andreas

P.S.: I have included Kurt Hornik on the email.

On 3/23/2012 10:52 PM, R. Michael Weylandt wrote:

julian() is in the package base. chron only provides julian.default to
avoid the error Uwe observed. If you look at the code for
julian.default, it's not too hard to see why date will be slightly
more sensitive to numeric fuzzwhether that's intentional (or
even a good/bad thing) is somewhat hard to say, but I'd guess the
maintainer didn't really consider a use case involving one
quadrillionth of a day.

Is it problematic for you? If so, a workaround is not hard to provide

Michael

On Fri, Mar 23, 2012 at 4:17 PM, Andreas Ecknerandr...@eckner.com  wrote:

Sorry, forgot to mention: R version 2.14.2

The function julian() is part of the chron package of the base
distribution.

On 3/23/2012 2:47 PM, Uwe Ligges wrote:

On 23.03.2012 15:45, Andreas Eckner wrote:

Hi,

does anybody know if the following behavior of julian() is intentional?


julian(2, 1, 2012) - julian(2 - 1e-15, 1, 2012)

[1] 1

julian(2, 1, 2012) - julian(2, 1 - 1e-15, 2012)

[1] 0

julian(2, 1, 2012) - julian(2, 1, 2012 - 1e-15)

[1] 0

In other words, julian() is subject to numerical noise in the 'day'
argument, but not in the 'month' and 'year' argument? Another example:


julian(2 - 1e-15, 1, 2012) - julian(1 - 1e-15, 1, 2012)

[1] 30



Which vbersion of R are you talking about?

I get:


julian(2, 1, 2012) - julian(2 - 1e-15, 1, 2012)

Error in UseMethod(julian) :
  no applicable method for 'julian' applied to an object of class
c('double', 'numeric')


Uwe Ligges



Thanks,
Andreas

__
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.




__
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] julian() and numerical noise

2012-03-24 Thread Andreas Eckner

Very helpful, thanks!

Andreas

On 3/24/2012 10:57 AM, R. Michael Weylandt wrote:

It might be easier to just work with a character representation rather
than fighting the floating point demons:

fnc- function(date){
 as.Date(paste(date, 01, sep = .), format = %Y.%m.%d)
}

Hope that helps,

Michael

On Sat, Mar 24, 2012 at 10:47 AM, Andreas Ecknerandr...@eckner.com  wrote:

Thanks for the help. A workaround seems indeed easy to write, for example,
by rounding the the value of 'm' inside chron:::julian.default(), or only
passing integers to the function.

I never intended to use a case involving a quadrillionth of a day, but
encountered the problem when converting a dates in .MM format to a CHRON
object. Here is an example for future reference (the output might be highly
system-dependent):


   library(chron)
   date- 2012.02
   y- floor(date)
   m- (date %% 1) * 100
   julian(2, 1, 2012) - julian(m, 1, y)

[1] 1

~Andreas

P.S.: I have included Kurt Hornik on the email.

On 3/23/2012 10:52 PM, R. Michael Weylandt wrote:

julian() is in the package base. chron only provides julian.default to
avoid the error Uwe observed. If you look at the code for
julian.default, it's not too hard to see why date will be slightly
more sensitive to numeric fuzzwhether that's intentional (or
even a good/bad thing) is somewhat hard to say, but I'd guess the
maintainer didn't really consider a use case involving one
quadrillionth of a day.

Is it problematic for you? If so, a workaround is not hard to provide

Michael

On Fri, Mar 23, 2012 at 4:17 PM, Andreas Ecknerandr...@eckner.com
  wrote:

Sorry, forgot to mention: R version 2.14.2

The function julian() is part of the chron package of the base
distribution.

On 3/23/2012 2:47 PM, Uwe Ligges wrote:

On 23.03.2012 15:45, Andreas Eckner wrote:

Hi,

does anybody know if the following behavior of julian() is intentional?


julian(2, 1, 2012) - julian(2 - 1e-15, 1, 2012)

[1] 1

julian(2, 1, 2012) - julian(2, 1 - 1e-15, 2012)

[1] 0

julian(2, 1, 2012) - julian(2, 1, 2012 - 1e-15)

[1] 0

In other words, julian() is subject to numerical noise in the 'day'
argument, but not in the 'month' and 'year' argument? Another example:


julian(2 - 1e-15, 1, 2012) - julian(1 - 1e-15, 1, 2012)

[1] 30



Which vbersion of R are you talking about?

I get:


julian(2, 1, 2012) - julian(2 - 1e-15, 1, 2012)

Error in UseMethod(julian) :
  no applicable method for 'julian' applied to an object of class
c('double', 'numeric')


Uwe Ligges



Thanks,
Andreas

__
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.






__
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] julian() and numerical noise

2012-03-23 Thread Andreas Eckner

Hi,

does anybody know if the following behavior of julian() is intentional?

   julian(2, 1, 2012) - julian(2 - 1e-15, 1, 2012)
[1] 1
   julian(2, 1, 2012) - julian(2, 1 - 1e-15, 2012)
[1] 0
   julian(2, 1, 2012) - julian(2, 1, 2012 - 1e-15)
[1] 0

In other words, julian() is subject to numerical noise in the 'day' 
argument, but not in the 'month' and 'year' argument? Another example:


   julian(2 - 1e-15, 1, 2012) - julian(1 - 1e-15, 1, 2012)
[1] 30

Thanks,
Andreas

__
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] julian() and numerical noise

2012-03-23 Thread Andreas Eckner

Sorry, forgot to mention: R version 2.14.2

The function julian() is part of the chron package of the base 
distribution.


On 3/23/2012 2:47 PM, Uwe Ligges wrote:

On 23.03.2012 15:45, Andreas Eckner wrote:

Hi,

does anybody know if the following behavior of julian() is intentional?

 julian(2, 1, 2012) - julian(2 - 1e-15, 1, 2012)
[1] 1
 julian(2, 1, 2012) - julian(2, 1 - 1e-15, 2012)
[1] 0
 julian(2, 1, 2012) - julian(2, 1, 2012 - 1e-15)
[1] 0

In other words, julian() is subject to numerical noise in the 'day'
argument, but not in the 'month' and 'year' argument? Another example:

 julian(2 - 1e-15, 1, 2012) - julian(1 - 1e-15, 1, 2012)
[1] 30



Which vbersion of R are you talking about?

I get:

 julian(2, 1, 2012) - julian(2 - 1e-15, 1, 2012)
Error in UseMethod(julian) :
  no applicable method for 'julian' applied to an object of class 
c('double', 'numeric')



Uwe Ligges



Thanks,
Andreas

__
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.


[R] Multiple data frames in single csv output

2012-03-22 Thread Andreas Emanuelsson
Hi everybody, I have a model that outputs 1) primary analysis results, 2) 
secondary analysis results and 3) model choice parameters. I would like to 
output them all together as one spread sheet to minimize my copy paste time 
since I need to run the model with at least 20-30 sets of parameters. They are 
all in different data.frames with different dimensions.

However, I have tried  to construct one final output data frame the different 
classes cant vary within each row (it seems) and I can't merge, r-c-bind or 
fill the old data frames into a bigger new. Just using a matrix seems to work 
but stills it feels like an crude way and I lose the headers and some of the 
formatting option (replace dot with comma).

Does anyone know a if there is a better package for layouting csv structure? 
(I don't want one spread sheet per table)

Are there any other neat way to join data.frames but ignoring all the indexing? 
(maybe turning them into text and printing them as a csv file)?

Best regards

Andreas Emanuelsson


[[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] 3-parametric Weibull regression

2012-01-31 Thread Pfrengle Andreas (GS-SI/ENX7)
Hello Terry,

thank you for your help. I've tried your suggestion now and worked out the 
following code. What I forgot to mention in my last mail is that I have 
interval-censored data (I'm testing with discrete increasing fluid-volumes). I 
would be thankful if you reviewed my solution:

myfun - function(offset, vol_min, vol, status, x) {
  vol_min2 - vol_min - offset
  vol2 - vol - offset
  fit - survreg(Surv(vol_min, vol, status, interval) ~ x, dist=weibull, 
subset=(vol_min2  0))
  fit$loglik[2]
}

I've edited myfun to return fit$loglik[2], the model's loglik, otherwise I'd 
get an error invalid function value in 'optimize'
To get the optimized model over categorical factor Gruppe and continuous 
factor d, I did:

fit0 - survreg(Surv(Vol_min, Vol, status, interval) ~ Gruppe + d + Gruppe * 
d, data=data, x=T, y=T)
ofit - optimize(myfun, c(0, .99*min(data$Vol_min[data$status!=0])), 
vol_min=exp(fit0$y[,1]), vol=exp(fit0$y[,2]), status=fit0$y[,3], x=fit0$x, 
maximum=T)
fit1 - survreg(Surv(Vol_min - ofit$maximum, Vol - ofit$maximum, status, 
interval) ~ Gruppe + d + Gruppe * d, data=data, x=T, y=T)
summary(fit1)

I needed to exp() the fit0$y results since they were logarithmized, so I get 
the original values again into myfun
The fit1 then builds the model with the optimized offset-value.
My next question is: How do I use the output of fit1 to build the formula for 
the distribution (i.e. the a and b parameters described in the 
dweibull-help, depending on my factors)? Is the following correct (example-plot 
for group 0, d=300)?
Also, is my assumption correct that the weibull exponent ($scale) isn't 
modelled in dependence of the factors, but constant for the whole dataset?

a - 1 / fit1$scale
b - function(Gruppe, d) exp(fit1$coeff[1] + fit1$coeff[2] * Gruppe + 
fit1$coeff[3] * d + fit1$coeff[4] * Gruppe * d)
x - seq(0,5,.02)
plot(x, dweibull(x - ofit$maximum, a, b(0, 300)))



Mit freundlichen Grüßen / Best regards

Dr. Andreas Pfrengle

Robert Bosch GmbH
 (GS-SI/ENX7-Fe)
Postfach 30 02 20
70442 Stuttgart
GERMANY
www.bosch.com

Tel. +49 711 811-3622390
andreas.pfren...@de.bosch.com

Sitz: Stuttgart, Registergericht: Amtsgericht Stuttgart, HRB 14000;
Aufsichtsratsvorsitzender: Hermann Scholl; Geschäftsführung: Franz Fehrenbach, 
Siegfried Dais;
Stefan Asenkerschbaumer, Bernd Bohr, Rudolf Colm, Volkmar Denner, Christoph 
Kübel, Uwe Raschke,
Wolf-Henning Scheider, Werner Struth, Peter Tyroller


-Ursprüngliche Nachricht-
Von: Terry Therneau [mailto:thern...@mayo.edu]
Gesendet: Freitag, 27. Januar 2012 15:18
An: Pfrengle Andreas (GS-SI/ENX7)
Cc: r-help@r-project.org
Betreff: Re: 3-parametric Weibull regression

--- begin included message ---

Hello,

I'm quite new to R and want to make a Weibull-regression with the
survival package. I know how to build my Surv-object and how to make a
standard-weibull regression with survreg.
However, I want to fit a translated or 3-parametric weibull dist to
account for a failure-free time.
I think I would need a new object in survreg.distributions, but I don't
know how to create that correctly. I've tried to inherit it from the
extreme value distribution like so
..

---  end inclusion --

 I don't think that this is possibile through the survreg.distributions
approach.  One problem is an early censoring: say an observation was
censored at time 10, and your delay time estimate were 15: the
underlying routine would need to drop that obs from the calculations,
and there is no mechanism to do that.
  An althernative approach would be to include survreg in an optimize
call.  Here is an example

 myfun - function(lower, time, status, x) {
time2 - time-lower
fit - survreg(Surv(time2, status) ~x, dist=wiebull,
  subset= (time2  0))
fit$loglik
}
 fit0 - survreg(Surv(time, status) ~ x1 + x2 + , data=yd,
x=T, y=T)
 ofit - optimize(myfun, c(0, .99*min(yd$time[yd$status==1])),
time=fit0$y[,1], status=fit0$y[,1], x=fit0$x, maximum=T)

This will give you the optimal value for the threshold.  The .99 is to
stop the routine from an intermediate solution where there is a death at
exactly time 0.  The data set is yd=your data.

Terry Therneau

__
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] 3-parametric Weibull regression

2012-01-26 Thread Pfrengle Andreas (GS-SI/ENX7)
Hello,

I'm quite new to R and want to make a Weibull-regression with the survival 
package. I know how to build my Surv-object and how to make a 
standard-weibull regression with survreg.
However, I want to fit a translated or 3-parametric weibull dist to account for 
a failure-free time.
I think I would need a new object in survreg.distributions, but I don't know 
how to create that correctly. I've tried to inherit it from the extreme value 
dist, analogous to the implemented weibull-dist like so:
survreg.distributions$weibull3p$name - weibull
survreg.distributions$weibull3p$dist - extreme
survreg.distributions$weibull3p$trans - function(y, x0) log(y) + x0
survreg.distributions$weibull3p$dtrans - function(y) 1/y
survreg.distributions$weibull3p$itrans - function(x, x0) exp(x-x0)
I then get a failure by survregDtest(survreg.distributions$weibull3p) that x0 
is missing (since the transformation function is expected to take only one 
argument).

Any ideas? Or is there maybe a package somewhere that supports 3-parametric 
weibull regression which I missed?

Regards,
Andreas


[[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] R on Android

2012-01-02 Thread Andreas Borg

Ken Hutchison schrieb:

 If stranded on a desert island and getting R fully functional on Droid would 
save you, I'd advise looking for food; else be prepared to name your phone 
Wilson.
Ken Hutchison
  


I propose to add that to fortunes :-D

Andreas Borg

--
Andreas Borg
Abteilung Medizinische Informatik

Universitätsmedizin der Johannes Gutenberg-Universität Mainz
Institut für Med. Biometrie, Epidemiologie und Informatik (IMBEI)
Obere Zahlbacher Straße 69, 55131 Mainz

Tel:  +49 (0) 6131 17-5062

E-Mail: andreas.b...@uni-mainz.de

__
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 in dbWriteTable

2011-12-02 Thread Andreas Borg

Hello,

you can fetch the column names of a table with dbListFields and then 
reorder or rename the data frame according to those.


If you want more specific help, provide an example (RSQLite would be a 
good choice as database engine to make it easily reproducible for others).


Best regards,

Andreas

arunkumar schrieb:
hi 

 I need some help in dbWriteTable. 
I'm not able to insert the rows in the table if the column order are not

same in the database and in the dataframe which i'm inserting. Also facing
issue if the table is already created externally and inserting it thru
dbWrite.

is there some way that we can sepecify the rownames in the dbwrite..or any
method which will solve my problem



--
View this message in context: 
http://r.789695.n4.nabble.com/help-in-dbWriteTable-tp4145110p4145110.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.

  



--
Andreas Borg
Abteilung Medizinische Informatik

Universitätsmedizin der Johannes Gutenberg-Universität Mainz
Institut für Med. Biometrie, Epidemiologie und Informatik (IMBEI)
Obere Zahlbacher Straße 69, 55131 Mainz

Tel:  +49 (0) 6131 17-5062

E-Mail: andreas.b...@uni-mainz.de

__
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] What's the baseline model when using coxph with factor variables?

2011-12-02 Thread Andreas Schlicker

William and David, thanks for your help.
The contrasts option was indeed what I was looking for but didn't find.

andi

On 01.12.2011 20:56, David Winsemius wrote:


On Dec 1, 2011, at 1:00 PM, William Dunlap wrote:


Terry will correct me if I'm wrong, but I don't think the
answer to this question is specific to the coxph function.


It depends on our interpretation of the questioner's intent. My answer
was predicated on the assumption that the phrase baseline model
meant baseline survival function, ... S_0(t) in survival analysis
notation.



For all the [well-written] formula-based modelling functions
(essentially, those that call model.frame and model.matrix to
interpret
the formula) the option contrasts controls how factor
variables are parameterized in the model matrix.  contr.treatment
makes the baseline the first factor level, contr.SAS makes
the baseline the last, contr.sum makes the baseline the mean,
etc.  E.g.,


df- data.frame(time=sin(1:20)+2,

   cens=rep(c(0,0,1), len=20),
   var1=factor(rep(0:1, each=10)),
   var2=factor(rep(0:1, 10)))

options(contrasts=c(contr.treatment, contr.treatment))
coxph(Surv(time, cens) ~ var1 + var2, data=df)

Call:
coxph(formula = Surv(time, cens) ~ var1 + var2, data = df)


coef exp(coef) se(coef)  zp
var11 0.1640  1.180.822 0.1995 0.84
var21 0.0806  1.080.830 0.0971 0.92

Likelihood ratio test=0.05  on 2 df, p=0.974  n= 20, number of
events= 6

options(contrasts=c(contr.SAS, contr.SAS))
coxph(Surv(time, cens) ~ var1 + var2, data=df)

Call:
coxph(formula = Surv(time, cens) ~ var1 + var2, data = df)


 coef exp(coef) se(coef)   zp
var10 -0.1640 0.8490.822 -0.1995 0.84
var20 -0.0806 0.9230.830 -0.0971 0.92

Likelihood ratio test=0.05  on 2 df, p=0.974  n= 20, number of
events= 6

options(contrasts=c(contr.sum, contr.sum))
coxph(Surv(time, cens) ~ var1 + var2, data=df)

Call:
coxph(formula = Surv(time, cens) ~ var1 + var2, data = df)


 coef exp(coef) se(coef)   zp
var11 -0.0820 0.9210.411 -0.1995 0.84
var21 -0.0403 0.9600.415 -0.0971 0.92

Likelihood ratio test=0.05  on 2 df, p=0.974  n= 20, number of
events= 6

(lm() has a contrasts argument that can override
getOption(contrasts)
and set different contrasts for each variable but coxph() does not
have
that argument.)

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org
] On Behalf Of David Winsemius
Sent: Thursday, December 01, 2011 9:36 AM
To: a.schlic...@nki.nl
Cc: r-help@r-project.org
Subject: Re: [R] What's the baseline model when using coxph with
factor variables?


On Dec 1, 2011, at 12:00 PM, Andreas Schlicker wrote:


Hi all,

I'm trying to fit a Cox regression model with two factor variables
but have some problems with the interpretation of the results.
Considering the following model, where var1 and var2 can assume
value 0 and 1:

coxph(Surv(time, cens) ~ factor(var1) * factor(var2),  data=temp)

What is the baseline model? Is that considering the whole population
or the case when both var1 and var2 = 0?


This has been discussed several times in the past on rhelp. My
suggestion would be to search your favorite rhelp archive using
baseline hazard Therneau, since Terry Therneau is the author of
survival. (The answer is closer to the first than to the second.)



Kind regards,
andi

__
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.


David Winsemius, MD
West Hartford, CT

__
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.


David Winsemius, MD
West Hartford, CT



__
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] What's the baseline model when using coxph with factor variables?

2011-12-01 Thread Andreas Schlicker

Hi all,

I'm trying to fit a Cox regression model with two factor variables but 
have some problems with the interpretation of the results. Considering 
the following model, where var1 and var2 can assume value 0 and 1:


coxph(Surv(time, cens) ~ factor(var1) * factor(var2),  data=temp)

What is the baseline model? Is that considering the whole population or 
the case when both var1 and var2 = 0?


Kind regards,
andi

__
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] Question on density values obtained from kde2d() from package MASS

2011-11-24 Thread Andreas Klein
Hello,

I am a little bit confused regarding the density values obtained from the 
function kde2d() from the package MASS because the are not in the intervall 
[0,1] as I would expect them to be. Here is an example:

x - 
c(0.0036,0.0088,0.0042,0.0022,-0.0013,0.0007,0.0028,-0.0028,0.0019,0.0026,-0.0029,-0.0081,-0.0024,0.0090,0.0088,0.0038,0.0022,0.0068,0.0089,-0.0015,-0.0062,0.0066)
y - 
c(0.00614,0.00194,0.00264,0.00064,0.00344,0.00314,-0.6,-0.00066,0.00174,0.00274,-0.00076,0.00024,-0.00236,0.00234,0.00504,0.00114,0.00054,-0.00116,-0.00016,-0.00566,0.00044,0.00404)

tmp - kde2d(x=x, y=y, n=100)
range(tmp$z)
#3.621288 11989.060924

Do I have to transform them further? Or what scale are they?
Or did I get something wrong regarding the output because in the help file it 
reads:
zAn n[1] by n[2] matrix of the estimated density: rows
correspond to the value of x, columns to the value of y.


Regards,
Andy.


__
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] Block length for Bivariate Stationary Bootstrap for Inference for Correlation

2011-11-18 Thread Andreas Klein
Hello,

I am searching for a method, algorithm or some solution to the following 
problem:
I need an estimator for the block length of two series to bootstrap the 
correlation coefficient with the stationary bootstrap procedure. The problem 
here: the two series have different block lengths!


Here is an example:
x and y are positively correlated and I would like to construct 
percentile bootstrap confidence intervals for the correlation 
coefficient between x and y.

##The question marks highlight the problem#

x - 
c(2.62,2.56,0.36,-3.43,2.44,2.77,-0.11,4.32,0.32,0.41,5.39,-2.30,7.27,2.42,4.69,-4.44,6.66,2.15,-0.60,-1.77)
y - 
c(10.40,13.56,2.11,-3.96,8.45,0.49,-2.48,14.09,3.45,7.15,-2.08,3.09,13.06,3.37,8.41,-6.63,6.01,7.94,-0.54,5.10)
xy - cbind(x,y)

library(np)
lx - b.star(x,round=TRUE)[1,1]
ly - b.star(y,round=TRUE)[1,1]


lxy - ???

library(tseries)
result - tsbootstrap(x=1:nrow(xy),nb=1000,statistic=function(idx,data) 
cor(data[idx,1],data[idx,2]),m=1,b=lxy,type=stationary,data=xy)
##


lx is not equal to ly, so what is lxy or what can it be or how can I estimate 
it? Is there something similar like b.star() but for bivariate problems?

I can estimate the block length for x (lx) or for y (ly) with b.star() but not 
the joint block length (lxy) to consider on the one hand the autocorrelation of 
x and y and on the other hand preserve the correlation structure between the 
two series.

Does anyone know a solution regarding the stationary bootstrap (no VAR-sieve 
bootstrap approach)? An exisitng algorithm like b.star() which considers the 
cross-correlation between the two variables?


I hope you can help me. Thanks a lot...

Regards,
Andy.


__
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] Function not found, maybe respective package has to be put in environment?

2011-11-13 Thread Andreas Klein
Hello everybody,

I have a problem and would like to start with an example:

library(snow)
library(tseries)
fn - function(x) adf.test(x)

clusterApply(cl=cl, x=x , fun=fn)


R cannot find the function adf.test() because it is inside the function fn(). 
This problem does not occur when, for example, fn - function(x) mean(x) holds. 
Therefore, I think the package tseries has to be put somehow in the environment 
where also the package stats is because the function mean() works but the 
function adf.test() not.

But how to solve the problem?

Remark:
The above code is an example to illustrate my problem. My original function is 
more complex and somewhere inside my function I refer to some other function 
from the package tsDyn.


I hope you can help me.

Kind regards,
Andy.


__
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] Repeated Measures Regression

2011-10-07 Thread Andreas Pedroni
Dear list, 

I'm trying to calculate a regression on a dataset with repeated measures. I 
tried to look for an example on the web and in Pinheiro and Bates 
Mixed-Effects Models in ..  book.
However, I' m not sure wether the regression model I'm using is the right 
one. I'm very thankful for any suggestions!
Ok, here's what I'm trying to do:
First, the experimental design:
We ran a study, where 36 subjects played a game, where they could 150 times 
make risky decisions. Throughout the game we recorded physiological data. 
Thus, each subject made in every trial a more or less risky decision. Now, I'm 
interested, whether parameters of the physiological data (Phys1, Phys2) can 
predict the amount of risk taken by a subject. 

So far my regression model looks as follows:

lme(Risk ~ Phys1 + Phys2, random = ~ 1  |  Subject)

Could this be suitable? Is it a problem, if the Variable Risk is autocorrelated 
within Subjects?

Thank you very much for any help and sorry if this is a too trivial question 
for the list.

Kind regards 

Andreas Pedroni

__
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] Robust covariance matrix with NeweyWest()

2011-09-28 Thread Andreas Klein
Dear R-users,

I would like to compute a robust covariance matrix of two series of 
realizations of random variables:

###Begin Example###

data - cbind(rnorm(100), rnorm(100))
model - lm(data ~ 1)
vcov(model)

library(sandwich)
NeweyWest(model) #produces an error


###End Example###

NeweyWest() produces an error but sandwich(), vcovHAC(), kernHAC, weave(),... 
do not produce any errors. It seems that the model object does not fit in that 
special case.


Nevertheless, the problem is that I need the robust version of the covariance 
matrix according to Newey and West (1987, 1994).

Any ideas or suggestions to solve the problem?

Kind regards,
Andy


__
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] Gui editor / viewer for large data

2011-07-14 Thread Andreas Borg

Dear all,

I am searching for a possibility to view large data sets (e.g. stored in 
ffdf objects) in a GUI window in a memory-efficient way. So far I looked 
at gtkDfEdit (package RGtk2Extras) and gdf (package gWidgets). Both 
operate (as far as I can see) on data frames stored in memory. gtkDfEdit 
accepts an ff data frame as input, but there is a long delay before it 
shows up, so I presume the data is converted to an in-memory data.frame 
beforehand.


Ideal would be a solution similar to JTable in Java, where one can 
implement a 'table model' class with a method (getValueAt or sth. like 
that) that returns the value of the underlying data for a given table 
cell (by x and y coordinates). When the table is drawn, getValueAt() is 
called for each cell in the viewable area. Cells outside the viewable 
range are not queried, so there is no need to keep the whole data in 
memory - it can be fetched from disk or computed on demand.


Before I seriously consider coding a suitable function or class myself, 
I would like to ask you, the R community, if anyone knows of an existing 
solution. To summarize, I need
   - a scrollable spreadsheet-like GUI element to view and potentially 
edit data
   - which only loads as much of the data as it displays at one point 
in time,
   - thereby able to handle datasets that are too large to fit into 
main memory


Thanks for any suggestions,

Andreas

--
Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: b...@imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. 
Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren 
Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die 
unbefugte Weitergabe
dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.

__
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 remove last 3 letters

2011-07-13 Thread Andreas Borg

gsub( mg, , x)

where x is your data.

Denis Kazakiewicz schrieb:

Hello to everybody
I have vector of drug dosage in string format
1.5 mg , 50 mg , 100 mg , 0.5 mg ...

The task is to remove last free symbols: ' mg'

Any suggestions are highly 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.




--
Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: b...@imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. 
Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren 
Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die 
unbefugte Weitergabe
dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.

__
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] Testing the proportional odds assumption of an ordinal generalized estimating equations (GEE) regression model

2011-06-28 Thread Andreas Karlsson

Dear list members,
 
I am estimating an ordinal generalized estimating equations (GEE) regression 
model on repeated measurements data.
 
Is there any way (preferably in R) to test the proportional odds assumption of 
this model?
 
Thanks in advance.
 
Andreas
 
 
  
[[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] problems with plots in loop

2011-06-14 Thread Andreas Betz
Dear helpers,

 

In an attempt to use a loop to generate graphs in a for loop in run into
a problem. The plan is to fill each page with eight graphs (mfrow =
c(4,2)) in to two columns. Only the buttom graphs ( meaning every fourth
graph) have  tick labels on the x  axis to preserve space. I used an if
 Else statement to achieve that.  

The problem is that the first eight graphs are skipped when I run the
loop, the other graphs are fine.  However, all graphs can be generated
individually. This indicates that the data sets are fine.

 

 

Pulling the results from a nonlinear regression to more than 90 data
sets from a list (resultslist[[i]])

Generating the first derivative and multiply it by 100 to adjust for the
scale. 

 

Here is the code. 

 

pdf('F:/diffnormal_16001a.pdf')
par(mfcol = c(4,2))
for(i in 1: 92){
fit  -  NULL
der -  NULL
Zeit  - NULL
Zeit - seq(0,300)
try(guess - predict(resultslist_1600[[i]]) )
if(class(guess) == try-error) {next}
fit - smooth.spline(Zeit, guess)
der - 100*(predict(fit, Zeit, deriv = 1))$y
  if((i/4)%%1 ==0){par(mar =c(4,4,0, 0) + 0.1)}
  else{par(mar =c(0,4,0, 0) + 0.1)}
  leg = paste(Data_, i,sep = )
  plot(resultslist_1600[[i]], type = all, pch = ., ylab = Signal,
log = , axes = F)
  lines(Zeit, der)
  if((i/4)%%1 ==0){axis(1, at = seq(0, 360, length = 6), label = c(),
font = 2)}
  axis(2, at =
pretty(na.omit(eval(parse(text=paste(bleeder1600[,,i,],sep =),
label = c())
  mtext(side = 3, leg, line = -2)}

 

I understand, that I am supposed to submit working code. However, I deal
with a fairly comprehensive data set and I have to generate a large list
using another R package. Thus I explain what it does:

 

Generate time points(Zeit - seq(0,300)

Pulling the results from a nonlinear regression to more than 90 data
sets from a list (resultslist_1600[[i]])

Test if prediction can be done

try(guess - predict(resultslist_1600[[i]]) )
if(class(guess) == try-error) {next}
(it turned out it can be done for all data set, as I am able to generate
the graphs for each data set from the command line individually.

Generating the first derivative and multiply it by 100 to adjust for the
scale. 

fit - smooth.spline(Zeit, guess)

der - 100*(predict(fit, Zeit, deriv = 1))$y

 

The problem appears to be hidden in the mfrow statement.



I spent quite a bit of time on this problem, thus any help or new ideas
would be very much appreciated.

 

Thank you

 

Andreas Betz

Scientist

andreasb...@earthlink.net

 


[[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] problems with plots in loop (corrected Email)

2011-06-14 Thread Andreas Betz
Dear helpers,

 

In an attempt to use a loop to generate graphs in a for loop in run into
a problem. The plan is to fill each page with eight graphs (mfrow =
c(4,2)) in to two columns. Only the buttom graphs ( meaning every fourth
graph) have  tick labels on the x  axis to preserve space. I used an if
 Else statement to achieve that.  

The problem is that the first eight graphs are skipped when I run the
loop, the other graphs are fine.  However, all graphs can be generated
individually. This indicates that the data sets are fine.

 

 

Pulling the results from a nonlinear regression to more than 90 data
sets from a list (resultslist[[i]])

Generating the first derivative and multiply it by 100 to adjust for the
scale. 

 

Here is the code. 

 

pdf('F:/diffnormal_16001a.pdf')
par(mfcol = c(4,2))
for(i in 1: 92){
fit  -  NULL
der -  NULL
Zeit  - NULL
Zeit - seq(0,300)
try(guess - predict(resultslist_1600[[i]]) )
if(class(guess) == try-error) {next}
fit - smooth.spline(Zeit, guess)
der - 100*(predict(fit, Zeit, deriv = 1))$y
  if((i/4)%%1 ==0){par(mar =c(4,4,0, 0) + 0.1)}
  else{par(mar =c(0,4,0, 0) + 0.1)}
  leg = paste(Data_, i,sep = )
  plot(resultslist_1600[[i]], type = all, pch = ., ylab = Signal,
log = , axes = F)
  lines(Zeit, der)
  if((i/4)%%1 ==0){axis(1, at = seq(0, 360, length = 6), label = c(),
font = 2)}
  axis(2, at =
pretty(na.omit(eval(parse(text=paste(bleeder1600[,,i,],sep =),
label = c())
  mtext(side = 3, leg, line = -2)}

 

I understand, that I am supposed to submit working code. However, I deal
with a fairly comprehensive data set and I have to generate a large list
using another R package. Thus I explain what it does:

 

Generate time points(Zeit - seq(0,300)

Pulling the results from a nonlinear regression to more than 90 data
sets from a list (resultslist_1600[[i]])

Test if prediction can be done

try(guess - predict(resultslist_1600[[i]]) )
if(class(guess) == try-error) {next}
(it turned out it can be done for all data set, as I am able to generate
the graphs for each data set from the command line individually.

Generating the first derivative and multiply it by 100 to adjust for the
scale. 

fit - smooth.spline(Zeit, guess)

der - 100*(predict(fit, Zeit, deriv = 1))$y

 

The problem appears to be hidden in the mfrow statement.

I spent quite a bit of time on this problem, thus any help or new ideas
would be very much appreciated.

 

Thank you

 

Andreas Betz

Scientist

andreasbetz@ Dear helpers,

 

In an attempt to use a loop to generate graphs in a for loop in run into
a problem. The plan is to fill each page with eight graphs (mfrow =
c(4,2)) in to two columns. Only the buttom graphs ( meaning every fourth
graph) have  tick labels on the x  axis to preserve space. I used an if
 Else statement to achieve that.  

The problem is that the first eight graphs are skipped when I run the
loop, the other graphs are fine.  However, all graphs can be generated
individually. This indicates that the data sets are fine.

 

 

Pulling the results from a nonlinear regression to more than 90 data
sets from a list (resultslist[[i]])

Generating the first derivative and multiply it by 100 to adjust for the
scale. 

 

Here is the code. 

 

pdf('F:/diffnormal_16001a.pdf')
par(mfcol = c(4,2))
for(i in 1: 92){
fit  -  NULL
der -  NULL
Zeit  - NULL
Zeit - seq(0,300)
try(guess - predict(resultslist_1600[[i]]) )
if(class(guess) == try-error) {next}
fit - smooth.spline(Zeit, guess)
der - 100*(predict(fit, Zeit, deriv = 1))$y
  if((i/4)%%1 ==0){par(mar =c(4,4,0, 0) + 0.1)}
  else{par(mar =c(0,4,0, 0) + 0.1)}
  leg = paste(Data_, i,sep = )
  plot(resultslist_1600[[i]], type = all, pch = ., ylab = Signal,
log = , axes = F)
  lines(Zeit, der)
  if((i/4)%%1 ==0){axis(1, at = seq(0, 360, length = 6), label = c(),
font = 2)}
  axis(2, at =
pretty(na.omit(eval(parse(text=paste(bleeder1600[,,i,],sep =),
label = c())
  mtext(side = 3, leg, line = -2)}

 

I understand, that I am supposed to submit working code. However, I deal
with a fairly comprehensive data set and I have to generate a large list
using another R package. Thus I explain what it does:

 

Generate time points(Zeit - seq(0,300)

Pulling the results from a nonlinear regression to more than 90 data
sets from a list (resultslist_1600[[i]])

Test if prediction can be done

try(guess - predict(resultslist_1600[[i]]) )
if(class(guess) == try-error) {next}
(it turned out it can be done for all data set, as I am able to generate
the graphs for each data set from the command line individually.

Generating the first derivative and multiply it by 100 to adjust for the
scale. 

fit - smooth.spline(Zeit, guess)

der - 100*(predict(fit, Zeit, deriv = 1))$y

 

The problem appears to be hidden in the mfrow statement.

I spent quite a bit of time on this problem, thus any help or new ideas
would be very much appreciated.

 

Thank you

 

Andreas Betz

Re: [R] Compiling C-code in Windows

2011-05-31 Thread Andreas Borg

Hi Petar,

did you install the toolset (Rtools) for compiling code for R in 
windows? See


http://cran.r-project.org/doc/manuals/R-admin.html#The-Windows-toolset

and

http://www.murdoch-sutherland.com/Rtools/

Please, can anyone help me with this? Can I use: 'R CMD SHLIB 
--output=trial.dll C:\trial.c' under Linux, and expecting working DLL?


Of course not, because Windows and Linux libraries differ by more than 
the filename extension.


Once everything is set up, compiling in windows is pretty easy thanks to 
the toolset.


Good luck,

Andreas

--
Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: b...@imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. 
Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren 
Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die 
unbefugte Weitergabe
dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.

__
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] Options for print()

2011-05-05 Thread Andreas Borg
Also take a look at sprintf, which offers everything the C-equivalent 
has. sprintf returns a string which can be sent to the console via cat.


Andreas

baptiste auguie schrieb:

Hi,

Try this,

cat(format(The TITLE, width=80, justify=centre))

HTH,

baptiste

On 5 May 2011 19:28, Dan Abner dan.abne...@gmail.com wrote:
  

Hello everyone,

I have a few questions about the print() fn:

1) I have the following code that does not center the character string:

print(The TITLE,quote=FALSE,justify=center)

2) How can I get R to not print the leading [1], etc.  when using print()?

(Sorry, I don't know what the leading [1] is called. I tried looking it up
in An Introduction, but could not find it).

Any help is greatly appreciated!

Dan

   [[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.

  



--
Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: b...@imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. 
Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren 
Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die 
unbefugte Weitergabe
dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.

__
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] Sweave stops when opening X11 device fails

2011-04-20 Thread Andreas Borg

Hi all,

I've run into the following problem with Sweave: I frequently run Sweave 
from a xterm console within an X session owned by a different user, i.e. 
my colleague is logged in on this computer and I do su with my 
username and start R and Sweave afterwards. Now, when Sweave comes to a 
figure chunk, it sees that there is an X server running and tries to 
show whatever I plot in that chunk on the screen, additionally to 
writing a pdf file. The problem is that I am not logged into the X 
session myself, and the script fails with a message saying someting like 
could not open device X11 (I have German messages, so I do not know 
what the exact phrase would be in English). When I log in with putty, 
where there is no X11 at all, everything works fine. Is there a way to 
prevent Sweave from failing in the former case? Would this even account 
as a bug? I think it would be nice if the script just kept on running 
without plotting on the screen if opening X11 fails, just like it does 
when no X11 is available at all.


Best regards,

Andreas

--
Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: b...@imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. 
Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren 
Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die 
unbefugte Weitergabe
dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.

__
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] user input

2011-04-20 Thread Andreas Borg

Hi Ivan,

there are also data.entry() and edit(), which are more tailored to data 
frames and might look awkward for entering a single value. You could 
also take a look at CRAN, maybe there is a GUI package that does what 
you want.


Andreas

Ivan Calandra schrieb:

Dear users,

I have looked on different sources and found different functions to 
prompt the user to provide input. However, I couldn't find one that 
does exactly what I'm looking for.


select.list() and menu() are nice because a graphic window appears to 
prompt the user. However, the user can only choose from a predefined 
list of choices. readline() and scan() are more free in the input but 
prompt the user in the console.


Examples:
a - select.list(choices=c(0.0,0.1,0.2), title=select number)
a## I cannot choose 0.15
[1] 0.1

b - readline(prompt=select number )
select number 0.2## in the console, not really visible
b
[1] 0.2


I would like both free input and a pop-up window. Is there a 
function for this?


Thanks in advance,
Ivan




--
Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: b...@imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. 
Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren 
Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die 
unbefugte Weitergabe
dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.

__
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] Where did my packages go ?

2011-04-19 Thread Andreas Borg

Hi Eric,

I have the same issue in Windows. When I upgrade, I just copy all the 
packages I need from the 2.12 to the 2.13 library folder and run 
update.packages afterwards. However, be careful not to replace any of 
the existing packages with older versions, as this might break the 
installation.


Andreas

eric schrieb:

Running linux 10.04 ubuntu.

Looks like Ubuntu automatically updated to version 2.13. I was running
version 2.12 until today. But now I'm getting error messages when I use the
require or library command and one of the packages I've downloaded in the
past.  For example:

  

require(quantmod)


Loading required package: quantmod
Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return
= TRUE,  :
  there is no package called 'quantmod

I noticed under my Home folder in the R folder that I have a
i486-pc-gnu-library subfolder. Inside that sub folder are 3 subfolders
labeled 2.10, 2.12, 2.13. If I look in 2.12, I see a lot of subfolders with
the names of the packages I use (quantmod for instance). If I look in the
2.13 subfolder, there's nothing there at all; it's empty.

So what is the right course of action ? 



--
View this message in context: 
http://r.789695.n4.nabble.com/Where-did-my-packages-go-tp3459079p3459079.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.

  



--
Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: b...@imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. 
Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren 
Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die 
unbefugte Weitergabe
dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.

__
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] mapply to lapply

2011-04-18 Thread Andreas Borg

My solution would be to use an index variable that goes from 1 to the number of 
rows that are to be processed, along with a helper function which calls 
Fwithcellvalue with the suitable arguments:

F2[i+1,j+1]-sum(lapply(1:nrow(cells), function(rowInd) 
Fwithcellvalue(i=i,j=j,a=cells[rowInd,2],b=cells[rowInd,4],c=cells[rowInd,1],d=cells[rowInd,3],e=cells[rowInd,5]))



Best regards,

Andreas

Alaios schrieb:

Dear all,

I would like to ask your help concerning 
converting a mapply function to lapply. The reason is that I would like to use 
mclapply which requires lapply syntax.


The command I would like to convert is:
F2[i+1,j+1]-sum(mapply(Fwithcellvalue,i=i,j=j,a=cells[,2],b=cells[,4],c=cells[,1],d=cells[,3],e=cells[,5]))

Could you please help me understand how I should change it?


Best Regards
Alex

__
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.

  



--
Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: b...@imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. 
Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren 
Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die 
unbefugte Weitergabe
dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.

__
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] mapply to lapply

2011-04-18 Thread Andreas Borg

Hi Alex,

sorry, I wasn't aware that sum does not work with listst. replace 
lapply with sapply or place the call in unlist.


Your second example does not work as you have to provide the additional 
arguments to the inner function in lapply:


lapply(1:nrow(cells), function(rowInd, i, j), [your function goes here], 
i=i, j=j)


Viele Grüße,

Andreas

Alaios schrieb:

Dear Andreas,
I would like to thank you for your reply.
I have tried two alternatives but none of the two worked out:

F2[i+1,j+1]-sum(lapply(1:nrow(cells), function(rowInd) 
Fwithcellvalue(i=i,j=j,a=cells[rowInd,2],b=cells[rowInd,4],c=cells[rowInd,1],d=cells[rowInd,3],e=cells[rowInd,5])))

this one is executed : takes like 2 mins to return(which is normal) but returns 
the following

^@Error in sum(lapply(1:nrow(cells), function(rowInd) Fwithcellvalue(i = i,  : 
  invalid 'type' (list) of argument



afterwards I tried to change the function definition so to pass i,j inside:

This one does not execute at all 


F2[i+1,j+1]-sum(lapply(1:nrow(cells), function(rowInd,i,j) 
Fwithcellvalue(i=i,j=j,a=cells[rowInd,2],b=cells[rowInd,4],c=cells[rowInd,1],d=cells[rowInd,3],e=cells[rowInd,5])))
Error in paste(f, i, j, (a,b,c,d), sep = ) : 
  argument i is missing, with no default



What do you think I should try out now?

Vielen Dank
Alex

--- On Mon, 4/18/11, Andreas Borg andreas.b...@unimedizin-mainz.de wrote:

  

From: Andreas Borg andreas.b...@unimedizin-mainz.de
Subject: Re: [R] mapply to lapply
To: Alaios ala...@yahoo.com
Cc: R-help@r-project.org
Date: Monday, April 18, 2011, 11:10 AM
My solution would be to use an index
variable that goes from 1 to the number of rows that are to
be processed, along with a helper function which calls
Fwithcellvalue with the suitable arguments:

F2[i+1,j+1]-sum(lapply(1:nrow(cells), function(rowInd)
Fwithcellvalue(i=i,j=j,a=cells[rowInd,2],b=cells[rowInd,4],c=cells[rowInd,1],d=cells[rowInd,3],e=cells[rowInd,5]))


Best regards,

Andreas

Alaios schrieb:


Dear all,

I would like to ask your help concerning converting a
  

mapply function to lapply. The reason is that I would like
to use mclapply which requires lapply syntax.


The command I would like to convert is:

  

F2[i+1,j+1]-sum(mapply(Fwithcellvalue,i=i,j=j,a=cells[,2],b=cells[,4],c=cells[,1],d=cells[,3],e=cells[,5]))


Could you please help me understand how I should
  

change it?


Best Regards
Alex

__
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.

   
  

-- Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und
Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: b...@imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und/oder rechtlich
geschützte Informationen. Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich
erhalten haben, informieren Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte
Kopieren sowie die unbefugte Weitergabe
dieser Mail und der darin enthaltenen Informationen ist
nicht gestattet.





  



--
Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: b...@imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. 
Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren 
Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die 
unbefugte Weitergabe
dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.

__
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 make this faster?

2011-04-11 Thread Andreas Borg

Hi Hasan,

I'd be happy to help you, but I am not able to run your code. You use 
commandArgs to retrieve arguments of the R program, but which ones do 
you actually provide?


Best regards,

Andreas

Hasan Diwan schrieb:

I was on vacation the last week and wrote some code to run a 500-day
correlation between the Nasdaq tracking stock (QQQ) and 191 currency pairs
for 500 days. The initial run took 9 hours(!) and I'd like to make it
faster. So, I'm including my code below, in hopes that somebody will be able
to figure out how to make it faster, either through parallelisation, or by
making changes. I've marked the places where Rprof showed me it was slowing
down:
currencyCorrelation - function(lagtime = 1) {
  require(quantmod)

  dataTrack - getSymbols(commandArgs(trailingOnly=T)[1], from='2009-11-21',
to='2011-04-03')
  stockData - get(dataTrack)
  currencies - row.names(oanda.currencies[grep(pattern='oz.', fixed=T, x
=as.vector(oanda.currencies$oanda.df.1.length.oanda.df...21.)) == F])
  correlations - vector()
  values - list()
  # optimise these loops using the apply family
  for (i in currencies) {
for (j in currencies) {
  if (i == j) next()
  fx - getFX(paste(i, j, sep='/'), from='2009-11-20', to='2011-04-02')
  # Prepare data by getting rates for market days only
  fx - get(fx)
  fx - fx[which(index(fx) %in% index(QQQ$QQQ.Close))]
  correlation - cor(fx, QQQ$QQQ.Close)
  correlations - c(correlations, correlation)
  string - paste(paste(i,j,sep='/'), correlation, sep=',')
  values - c(values,paste(string,'\n', sep=''))
}
  }
  # TODO eliminate NA's
  values - values[which(correlations[is.na(correlations) == F])]
  correlations - correlations[is.na(correlations) == F]
  values - values[order(correlations, decreasing=T)]
  write.table(values, file=commandArgs(trailingOnly=T)[2], sep='',
qmethod=NULL, quote = F, row.names=F, col.names=F)
  rm('currencies', 'correlations', 'values', 'fx', 'string')
  return()
}
lagtime - as.integer(commandArgs(trailingOnly=T)[3])
if (is.na(lagtime)) lagtime - 1
print(paste(Sys.time(), '--- starting', lagtime, 'day lag currencies
correlation with', commandArgs(trailingOnly=T)[1], 'from 2009-11-20 to
2011-04-03'))
currencyCorrelation(lagtime)
print(paste(Sys.time(), '--- ended, results in',
commandArgs(trailingOnly=T)[2]))


  



--
Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: b...@imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. 
Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren 
Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die 
unbefugte Weitergabe
dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.

__
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] random sampling with levels and with replacement

2011-04-08 Thread Andreas Borg

Hi,

I am not perfectly sure what you want to do, but here is what I would do 
to maintain good/bad ratio in the sample (as Daniel posted, split the 
data and sample from the groups):


df - data.frame(V1 = 1:400, V2 = c(rep(good,360), rep(bad,40)))
isGood - which(df$V2==good)
isBad - which(df$V2==bad)
sampleGood - df[sample(isGood, replace=TRUE),]
sampleBad - df[sample(isBad, replace=TRUE),]
summary(rbind(sampleGood, sampleBad))

Please include a more specific example with test data (for final in 
this case) next time.


Best regards,

Andreas


taby gathoni schrieb:

Dear all,
i have a dataset of about 400 records , with a variable that has  two levels 40 
bad and 360 good among other variables,how do i come up  with10 random samples 
that have the composition of as the main sample  but maintaining the 40 bad 360 
good with replacement, i recently discovered that my random samples generated 
dont maintain the ratio. My code is as  :

mysample - final[sample(1:nrow(final), 400,replace=TRUE),] 


does not give me the ratio of 40 bad and 360 good can anyone give me some 
pointers please?



Thanks,
Taby




[[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.
  



--
Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: b...@imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. 
Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren 
Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die 
unbefugte Weitergabe
dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.

__
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] Assign Names of columns in data.frame dinamically

2011-04-01 Thread Andreas Borg

Hi Marcos,

I'd be glad to help, but your example is not usable for anyone but 
yourself - I don't have the files that your code reads and I don't have 
any idea what the resulting data frames look like. Please provide 
examples of the data and the result.


Andreas

Marcos Amaris Gonzalez schrieb:

Hello List.

I have many files of ECG, each one with 7 column and I need only the
second column and the name of each ECG. I am doing this but althought
I have various days trying this i haven't gotten, so I ask help with
this, if somebody cans help me I'll be so thankfully.


rm(list=ls())

# loadEcgFiles - function(Dir=.) {
Dir - .;

txtfiles - list.files(paste(Dir),'.txt$');
ecg = data.frame(ncol=1);
len = length(txtfiles);

for (i in 1:5 ) {
# i - 1;
filename = paste(projectDir, / ,
txtfiles[i],sep='');
sample = read.table(filename, nrow=75000);  
   sampleName = filename; sampleName=gsub(./,
,sampleName); sampleName=gsub(.txt, , sampleName);
   temp - sample$V2;
   names(temp) - sampleName;
  ecg = cbind(ecg, temp);
#}

Thanks and sorry for my english.

---
Marcos Amaris González - Linux Counter #462840
--
No al SPAM!
No es más rico el que más tiene, sino el que menos necesita.
--

__
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.

  



--
Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: b...@imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. 
Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren 
Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die 
unbefugte Weitergabe
dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.

__
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 for loop to lapply

2011-03-30 Thread Andreas Borg

Hi Alaios,

there are some problems with your code:

1. In the expression Shadowlist[,,i]-i, i corresponds to dimmaps, not 
dimx. The for loop should be either


for (i in c(1:dimmaps)){
   Shadowlist[,,i]-i
}

or

for (i in c(1:dimx)){
   Shadowlist[i,,]-i
}


2. in lapply, the function must be second argument, your expression

lapply(seq(1:dimx),Shadowlist[,,seq(1:dimx)],returni)


fails because lapply wants to call Shadowlist[...] as a function. You 
probably meant (including the correction above):


lapply(seq(1:dimmaps),returni,Shadowlist[,,seq(1:dimmaps)])

or

lapply(seq(1:dimx),returni,Shadowlist[seq(1:dimx),,])

3. lapply always returns a list, there is no way to make it return an array. 
apply is better to deal with arrays, but as far as I know it cannot return 
arrays with dimension greater than 2.

Finally a general remark for future posts: Please make sure your examples are 
self-contained and executable (i.e. they don't throw an error and they do not 
depend on undefined variables, such as dimx etc. in this case)

Best regards,

Andreas



--
Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: b...@imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. 
Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren 
Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die 
unbefugte Weitergabe
dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.

__
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] (no subject)

2011-03-14 Thread Andreas Emanuelsson
Hi everyone, I have problems with a double for loop and the program response: 
Error in 1:mass[j] : NA/NaN argument

I'm trying to create a very simple script to generate a vector full of objects 
with the value [fuel] and in the amount [mass] for a hist plot.

H=1
for (j in 1:63)
 {for (i in 1:mass[j])
  { 
H[length(H)+1]=fuel[j]}
 }

What does the error mean?(where do I find explanations for such issues?

 Why does not a simple for loop work?

Error in 1:mass[j] : NA/NaN argument

Thank you very much for your time if you can help me!

/Andreas


[[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] (no subject)

2011-03-11 Thread Andreas Emanuelsson
Hi, I have tried to load a file originally from Excel, via csv, text and 
clipboard today.

When I succeed I cannot change the format from factor, and when I try to 
convert it to numerical it only gives the position of the factor-group, not 
the real value in the column?

Any quick suggestions?

Andreas


[[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] panel data

2011-02-21 Thread Andreas Sveding Otterström

Hello
 
I have a question about how to regress panel data in R. What are the 
appropriate commands and preparations that need to be made when regressing 
panel data?
 
/Andreas Otterstrom   
[[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] RSQLite to input dataframe

2011-01-04 Thread Andreas Borg


Hi Amy,

Suppose I have a dataframe as given below.

DF = data.frame(X = c(US, UK, Canada, Australia, Newzealand), Y = 
c(52, 36, 74, 10, 98))

drv - dbDriver(SQLite)
tfile - tempfile()
con - dbConnect(drv, dbname = tfile)
data(DF)
dbWriteTable(con, ..., ...) # Didn't know what to write here.
  


data() loads data sets which ship with R or an extension package. Your 
data frame DF is already in the working environment, hence it is neither 
possible nor necessary to load it, the expression


data(DF)

is an error. The command to write DF to a database would be something like

dbWriteTable(con, DF, DF)

where the second argument is the name of the database table to write to, the 
third argument the data frame you want to write (please have a look at the 
documentation).


I understand I have raised a query in a stupid manner. I need to understand is 
there any way I can use SQLite to read
 dataframe or for that matter any csv file say e.g. 'DF.csv'.


To copy a CSV file to SQLite, read it via read.table() or read.csv() first, 
then copy the result with dbWriteTable. There might be a way to read files 
directly from SQLite, but I don't know about that.

Best regards,

Andreas






  



--
Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: b...@imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. 
Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren 
Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die 
unbefugte Weitergabe
dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.

__
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] survival package - calculating probability to survive a given time

2010-12-10 Thread Andreas Wittmann

Dear R users,

i try to calculate the probabilty to survive a given time by using the 
estimated survival curve by kaplan meier.


What is the right way to do that? as far as is see i cannot use the 
predict-methods from the survival package?


library(survival)
set.seed(1)
time - cumsum(rexp(1000)/10)
status - rbinom(1000, 1, 0.5)

## kaplan meier estimates
fit - survfit(Surv(time, status) ~ 1)
s - summary(fit)

## 1. possibility to get the probability for surviving 20 units of time
ind - findInterval(20, s$time)
cbind(s$surv[ind], s$time[ind])

## 2. possibility to get the probability for surviving 20 units of time
ind - s$time = 20
sum(ind) / length(ind)

Thanks and best regards

Andreas

__
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] How to find out if a data frame has automatic row names?

2010-12-07 Thread Andreas Borg

Hi all,

I just stumbled across the difference between explicit and 'automatic' 
row names for data frames. Is there a quick way to find out if a data 
frame has automatic row names or not? Of course I know this for data 
frames that I create myself, but what if a function needs to extract 
this information for an argument?


The following example shows that this property is not easily visible:

 # data frame with automatic row names
 df - data.frame(a=1:2, b=3:4)
 # data frame with explicit row names
 df2 - data.frame(a=1:2, b=3:4, row.names=1:2)
 # printing does not reveal any difference
 df
 a b
1 1 3
2 2 4
 df2
 a b
1 1 3
2 2 4
 # both are considered equal
 all.equal(df, df2)
[1] TRUE
 identical(df, df2)
[1] TRUE
 # calling rownames gives the same result
 rownames(df)
[1] 1 2
 rownames(df2)
[1] 1 2
 # when converting to a matrix, it makes a difference
 as.matrix(df)
a b
[1,] 1 3
[2,] 2 4
 as.matrix(df2)
 a b
1 1 3
2 2 4

Thanks for any suggestion,

Andreas

--
Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: b...@imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. 
Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren 
Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die 
unbefugte Weitergabe
dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.

__
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 find out if a data frame has automatic row names?

2010-12-07 Thread Andreas Borg

That does it. Thanks!


Check ?.row_names_info

Peter Ehlers


Andreas







--
Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: b...@imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. 
Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren 
Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die 
unbefugte Weitergabe
dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.

__
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] Quadratic programming with semi-definite matrix

2010-12-04 Thread Andreas Jensen
Hello.

I'm trying to solve a quadratic programming problem of the form min
||Hx - y||^2 s.t. x = 0 and x = t using solve.QP in the quadprog
package but I'm having problems with Dmat not being positive definite,
which is kinda okay since I expect it to be numerically semi-definite
in most cases. As far as I'm aware the problem arises because the
Goldfarb and Idnani method first solves the unconstrained problem
requiring a positive definite matrix. Are there any (fast) packages
that allows me to do QP with (large) semidefinite matrices?

Example:
t - 100
y - signalConvNoisy[1,]
D - crossprod(H,H)
d - crossprod(H,y)
A - cbind(rep(-1, nrow(H)), diag(ncol(H)))
b0 - c(t, rep(0, ncol(H)))
sol - solve.QP(Dmat=D, dvec = d, Amat = A, bvec = b0)$solution
Error in solve.QP(Dmat = D, dvec = d, Amat = A, bvec = b0) :
  matrix D in quadratic function is not positive definite!

Thanks in advance,
Andreas Jensen

__
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] Performance tuning tips when working with wide datasets

2010-11-29 Thread Andreas Borg

Richard Vlasimsky schrieb:

Does anyone have any performance tuning tips when working with datasets that 
are extremely wide (e.g. 20,000 columns)?

In particular, I am trying to perform a merge like below:

merged_data - merge(data1, data2, by.x=ate,by.y=date,all=TRUE,sort=TRUE);

This statement takes about 8 hours to execute on a pretty fast machine.  The dataset data1 contains daily data going back to 1950 (20,000 rows) and has 25 columns.  The dataset data2 contains annual data (only 60 observations), however there are lots of columns (20,000 of them).  

I have to do a lot of these kinds of merges so need to figure out a way to speed it up.  


I have tried  a number of different things to speed things up to no avail.  
I've noticed that rbinds execute much faster using matrices than dataframes.  
However the performance improvement when using matrices (vs. data frames) on 
merges were negligible (8 hours down to 7).  I tried casting my merge field 
(date) into various different data types (character, factor, date).  This 
didn't seem to have any effect. I tried the hash package, however, merge 
couldn't coerce the class into a data.frame.  I've tried various ways to 
parellelize computation in the past, and found that to be problematic for a 
variety of reasons (runaway forked processes, doesn't run in a GUI environment, 
doesn't run on Macs, etc.).

I'm starting to run out of ideas, anyone?  Merging a 60 row dataset shouldn't 
take that long.

Thanks,
Richard

  


Hi Richard,

I had similar problems (even with much less data) and found out that 
most of the running time was caused by memory swapping instead of CPU 
usage. If you do not need all of the merged data at once, block-wise 
processing can help, which means that you only generate that much merged 
data at once as fits into main memory. I ended up using package RSQLite 
(an embedded database) in the following way:


-create a database connection (explained in the package docs)
-copy data to database tables via dbWriteTable()
-create indices on the columns which are used for merging, sth. like: 
dbGetQuery(con, 'create index index_year on table2(year)') - this 
speeds upjoining significantly
-construct an SQL query to do the join / merge operation and send it to 
SQLite via dbSendQuery()

-retreive the result in blocks of reasonable size with fetch()

Unless there is an operation in the query which requires SQLite to 
process the whole result (e.g. sorting), the result rows will be created 
on the fly for every call of fetch() instead of a huge table being 
allocated in addition to the original data.


I am not sure if this works with other database engines (there are a 
couple of database interfaces on CRAN); when I tried to use RPostgreSQL, 
it created the whole result set at once, leading to the same memory 
problem. Maybe that behavior can be changed by some config variable.


Best regards,

Andreas

--
Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: b...@imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. 
Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren 
Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die 
unbefugte Weitergabe
dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.

__
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] read.table / type.convert: Unexpected column class

2010-11-23 Thread Andreas Borg

Hi all,

I stumbled across the following, in my opinion surprising, behaviour of 
read.table:


 data - read.table(stdin(), sep=,)
0: 1, 2, 3 # Some comment
1:
 sapply(data, class)
  V1V2V3
integer integer numeric

I was surprised to find that V3 has class numeric despite its apparent 
integer value. I took a look at type.convert (which is called by 
read.data to determine column classes) for explanation (I quote from the 
man page):


   Vectors containing optional whitespace followed by decimal 
constants representable as R integers [...] are converted to integer. 
Other vectors containing optional whitespace followed by other decimal 
or hexadecimal constants [...] are converted to numeric.


Obviously the trailing whitespace between '3' and the comment sign '#' 
is treated as other decimal or hexadecimal constant while the leading 
whitespace before 2 is stripped. Actually, leaving just the trailing 
space after '3' without the comment gives the same result. Is there any 
reason for this behaviour?


Best regards,

Andreas

--
Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: b...@imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. 
Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren 
Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die 
unbefugte Weitergabe
dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.

__
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] Closing unreferenced result sets in dbi / RSQLite

2010-11-04 Thread Andreas Borg

Hello R-help members,

I have one problem with the database interface dbi (more specifically, I 
work with RSQLite). Consider the following example, which writes a test 
table to a temporary SQLite database and sends a query to read from it:


library(RSQLite)
df - as.data.frame(matrix(runif(4), nrow=2, ncol=2))
drv - dbDriver(SQLite)
con - dbConnect(drv)
dbWriteTable(con, df, df)
dbSendQuery(con, select * from df)


In the last line I forgot to assign the DBIResult object returned by 
dbSendQuery() to a variable, which happens from time to time when I work 
interactively. The following attempt to correct the mistake:


res - dbSendQuery(con, select * from df)

fails because the orphaned result set from the preceeding call is still 
active. Consequently, I have to close the connection to keep on working, 
which is especially annoying when working with a temporary data base 
where everything is discarded on disconnection. Is there any way to 
create a new reference to the pending result set or to close result sets 
which are not bound to a variable?


Thanks for any suggestion,

Andreas


--
Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: b...@imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. 
Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren 
Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die 
unbefugte Weitergabe
dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.

__
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   >