[R] optimize integer function parameters

2013-07-22 Thread Christof Kluß
Hi I have "observations" obs <- (11455, 11536, 11582, 11825, 11900, ...) and a simulation function f(A,B,C,D,E,F), so sim <- f(A,B,C,D,E,F) e.g. sim = c(11464, 11554, 11603, 11831, 11907, ...) now I would like to fit A,B,C,D,E,F such that "obs" and f(A,B,C,D,E,F) match as well as possible. A

Re: [R] optimize integer function parameters

2013-07-23 Thread Christof Kluß
print(paste(rmse,TS0,TS1,TS2,TB0,TB1,TB2)) act <- rmse } } Am 23-07-2013 13:20, schrieb Enrico Schumann: On Tue, 23 Jul 2013, Christof Kluß writes: I have "observations" obs <- (11455, 11536, 11582, 11825, 11900, ...) and a simula

[R] force pdf()

2013-08-14 Thread Christof Kluß
Hi is there a way to generate a pdf, e.g. pdf("test.pdf"), even if the file "test.pdf" is open? (e.g. with acrobat) i.e. I would have to close "test.pdf" in the viewer without any user interaction, than override the file and maybe open it again. thx Christof ___

[R] read tab delimited file from a certain line

2013-01-16 Thread Christof Kluß
Hi I would like to read table data from a text-files with extra informations in the header (of unknown line count). Example: informations (unknown count of lines) ... and at some point the table -- year month mday value 2013 1 16 0 ... If it was an excel fi

Re: [R] read tab delimited file from a certain line

2013-01-17 Thread Christof Kluß
3 1 16 0 ")) # This is it i <- grep("^year", x) read.table(textConnection(x[i:length(x)]), header = TRUE) Hope this helps, Rui Barradas Em 16-01-2013 14:17, Christof Kluß escreveu: Hi I would like to read table data from a text-files with extra informations in the header

Re: [R] read tab delimited file from a certain line

2013-01-20 Thread Christof Kluß
rg/hbLite.R";) hbLite("R.filesets") /Henrik On Thu, Jan 17, 2013 at 1:34 AM, Christof Kluß wrote: Hello thank you for the fast and helpful answer! Now the following works fine for me x <- readLines(filename) i <- grep("^year", x) dlf <- read.table(textConne

[R] make R program faster

2013-03-28 Thread Christof Kluß
Hi there are some good tips in "The R Inferno" http://www.burns-stat.com/documents/books/the-r-inferno/ or connect C++ to R with Rcpp http://dirk.eddelbuettel.com/code/rcpp.html or byte code compiler (library(compiler)) or library(data.table) but do you have an idea to fasten standard R source c

[R] eval(parse(...)) only once in a function

2012-09-16 Thread Christof Kluß
Hi I would like to have something like str <- "df$JT == 12" fun <- function(df) { b <- eval(parse(str)) return(b) } but for performance "eval(parse(a))" should not be evaluated at each function call, but should work as fun <- function(df) { b <- df$JT == 12 return(b) } Do you have

Re: [R] eval(parse(...)) only once in a function

2012-09-18 Thread Christof Kluß
r. Christof Am 17-09-2012 22:52, schrieb Thomas Lumley: > On Mon, Sep 17, 2012 at 6:27 PM, Christof Kluß > wrote: >> but for performance "eval(parse(a))" should not be evaluated at each >> function call, but should work as >> > You can do it with bquote()

[R] nlme function examples for dose-respone

2012-09-25 Thread Christof Kluß
Hi, I want to fit nonlinear dose-response curves, as "fun(X,a,b,c)", for each of our 5 trail locations. Our data basis is something like location plot year dose response For each location there are 4 plots as repetitions (over 3 years). So the interactions "location*year" and "location*plot" sho

Re: [R] nlme function examples for dose-respone

2012-09-25 Thread Christof Kluß
locations as > fixed. With only 5, you don't have enough information to estimate the > variance component with any precision anyway. > > 3. Feel free to ignore (2) and defer to the experts at (1). > > Cheers, > Bert > > > On Tue, Sep 25, 2012 at 8:52 AM, Chris

[R] lattice xyplot, get current level

2012-10-02 Thread Christof Kluß
Hi xyplot(y ~ x | subject) plots a separate graph of y against x for each level of subject. But I would like to have an own function for each level. Something like xyplot(y ~ x | subject, panel = function(x,y) { panel.xyplot(x,y) panel.curve(x,y) { # something

Re: [R] lattice xyplot, get current level

2012-10-02 Thread Christof Kluß
subj <- levels(subject) subj[panel.number()] seems to be a good solution is there something like panel.legend (instead of panel.text)? Am 02-10-2012 12:59, schrieb Christof Kluß: > Hi > > xyplot(y ~ x | subject) plots a separate graph of y against x for each > level of subje

[R] mark sections on a time chart

2012-10-19 Thread Christof Kluß
Hi is there a comfortable way to mark periods on time chart (axis.Date)? To do it with arrows(...), seems to be irritating. I want to have something like <---winter--><--spring--><--summer--> thx Christof __ R-help@r-project.org mailing list https:/

Re: [R] mark sections on a time chart

2012-10-20 Thread Christof Kluß
Hello Rui Barradas thank you very much. That is exactly what I was looking for. Christof Am 20-10-2012 14:19, schrieb Rui Barradas: > library(zoo) > > arrowsRange <- function(from, to, at = 1, labels = NULL, > length = 1/8, horizontal = TRUE, border = FALSE, ...){ > require(plotrix) >

[R] connect points in charts

2012-10-26 Thread Christof Kluß
Hi is there a automatic way that long distances between points are not connected. I have something like plot(x,y,type="o",...) atx <- seq(as.Date("2009-04-01"),as.Date("2011-04-01"),"month") axis.Date(1, at=atx,labels=format(atx, "%b\n%Y"), padj=0.5 ) but I do not want lines between points wh

[R] nonlinear regression with an iterativ function

2010-11-10 Thread Christof Kluß
Hi, we have a function that calculates a value for each day of the year. For example an iterative function like actvalue_0 := 0 actvalue_ {t+1} := actvalue_t + f(param_1,param_2,actvalue_t) and for some days we have measurements. Now we want to choose param_1 and param_2 so that the function va

[R] linear regression with replication

2011-05-23 Thread Christof Kluß
Hi, we want to calculate a linear regression that results from three test series. (The "Average linear regression" over 3 replication.) Each test serie consists of the values ​​for 3 times (0min, 25min, 50min) and is repeated three times. We need such a regression for each combination of subject

[R] Fwd: linear regression with replication

2011-05-24 Thread Christof Kluß
Probably the question fits better in the lme4 mailing list, so I forwarded it. Original-Nachricht Betreff: linear regression with replication Datum: Mon, 23 May 2011 16:31:54 +0200 Von: Christof Kluß An: Newsgruppen: gmane.comp.lang.r.general Hi, we want to calculate a

[R] lme: extract result-function

2012-06-13 Thread Christof Kluß
Hi, mod <- lme(A ~ -1 + B+C+D+E+F+G, random = ~1 | ...) results in summary(mod)$coeff B C D E F G (Intercept) b c d e f g i Now I'm interested in the function f <- function(B,C,D,E,F,G) <- { return(i + b*B + c*C + d*D + e*E + f*F + g*G) } Is there a easier way to create such function with f

[R] visualize correlation matrix

2012-06-17 Thread Christof Kluß
Hi is there a easy way to get something like http://addictedtor.free.fr/graphiques/graphcode.php?graph=137 pairs(USJudgeRatings[,c(2:3,6,1,7)], lower.panel=panel.smooth, upper.panel=panel.cor) but without the "lower.panel" (and without numbers and ticks at the border.) thx Christof _

[R] lm without intercept, false R-squared

2012-06-27 Thread Christof Kluß
Hi is there a command that calculates the correct adjusted R-squared, when I work without intercept? (The R-squared from lm without intercept is false.) Greetings Chrsitof __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-hel

Re: [R] lm without intercept, false R-squared

2012-06-27 Thread Christof Kluß
run a regression I like to have the R² of the regression line and not something else. ;) Am 27-06-2012 10:25, schrieb Uwe Ligges: > > > On 27.06.2012 09:33, Christof Kluß wrote: >> Hi >> >> is there a command that calculates the correct adjusted R-squared, when >&g

Re: [R] lm without intercept, false R-squared

2012-06-27 Thread Christof Kluß
run a regression I like to have the R² of the regression line and not something else. ;) Am 27-06-2012 10:25, schrieb Uwe Ligges: > > > On 27.06.2012 09:33, Christof Kluß wrote: >> Hi >> >> is there a command that calculates the correct adjusted R-squared, when >&g

[R] save conditions in a list

2012-07-02 Thread Christof Kluß
Hi how would you save conditions like a = "day > 100"; b = "val < 50"; c = "year == 2012" in a list? I like to have variables like "day", "val", "year" and a list of conditions list(a,b,c). Then I want to check if a & b & c is true or if a | b | c is true or similar things. Greetings Christof

Re: [R] save conditions in a list

2012-07-05 Thread Christof Kluß
And now with data.frames > result <- lapply(conds, fun, DF) > > Reduce(`&`, result) # combine the results > Reduce(`|`, result) # > > > Hope this helps, > > Rui Barradas > > Em 02-07-2012 18:04, Christof Kluß escreveu: >> Hi >> >> how would

[R] alternative to rbind for data.table

2012-07-21 Thread Christof Kluß
Hi I want to add a row to a "data.table" in each round of a for loop. "rbind" seems to be a inefficient way to implement this. How would you do this? The "slow" solution: library(data.table) Rprof("test.out") dt <- data.table() for (i in (1:1)) { # algorithm that generates a list with dif

[R] self-starter functions for y = a + b * c^x

2012-08-14 Thread Christof Kluß
Hi there are some predefined self-start functions, like SSmicmen, SSbiexp, SSasymp, SSasympOff, SSasympOrig, SSgompertz, SSflp, SSlogis, SSweibull, Quadratic, Qubic, SSexp (nlrwr) Btw, do you know graphic examples for this functions? The SSexpDecay (exponential decay) for y = (y0 - plateau)*exp(

Re: [R] self-starter functions for y = a + b * c^x

2012-08-14 Thread Christof Kluß
Hi Ken Am 14-08-2012 11:50, schrieb ken knoblauch: > Christof Kluß email.uni-kiel.de> writes: > >> But now I search a self-starter for y = a + b * c^x > > You might be able to adapt the SS.calib function > from the psyphy package for this. > It was designed to

Re: [R] self-starter functions for y = a + b * c^x

2012-08-14 Thread Christof Kluß
Am 14-08-2012 19:40, schrieb Peter Ehlers: > On 2012-08-14 00:09, Christof Kluß wrote: >> But now I search a self-starter for y = a + b * c^x > Can't you just reparameterize with c^x = exp(x * log(c)) ? oh, I've missed this... thank you very muc

[R] simplify source code

2011-11-26 Thread Christof Kluß
Hi I would like to shorten mod1 <- nls(ColName2 ~ ColName1, data = table, ...) mod2 <- nls(ColName3 ~ ColName1, data = table, ...) mod3 <- nls(ColName4 ~ ColName1, data = table, ...) ... is there something like cols = c(ColName2,ColName3,ColName4,...) for i in ... mod[i-1] <- nls(ColName[i]

[R] append to PDF file

2011-11-26 Thread Christof Kluß
Hi is there a way to append a plot as PDF to an existing PDF file? savePlot seems not to have this possibility. Christof __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-pr

Re: [R] simplify source code

2011-11-29 Thread Christof Kluß
Hi Dennis, thank you very much. That works fine. Is there a possibility that R continue even if one of the models is not solvable? R currently terminates with an error message. greetings Christof Am 27-11-2011 01:34, schrieb Dennis Murphy: vars<- c('y1', 'y2', 'y3') # Function to create t

Re: [R] append to PDF file

2011-11-29 Thread Christof Kluß
Hi Jim, Hi Ken Am 27-11-2011 00:00, schrieb jim holtman: There is the 'pdftk' (PDF tool kit) that you will find on the web that will do the job. I have used it to both combine and split out the pages in the PDF file. yes, thx. GUI tools like www.pdfsam.org do the job too. But is there a poss

Re: [R] simplify source code

2011-12-01 Thread Christof Kluß
t;C1"]!) Can you give me a hint? greetings Christof Am 26-11-2011 23:30, schrieb Christof Kluß: Hi I would like to shorten mod1 <- nls(ColName2 ~ ColName1, data = table, ...) mod2 <- nls(ColName3 ~ ColName1, data = table, ...) mod3 <- nls(ColName4 ~ ColName1, data = table, ...

[R] apply on function with vector as result

2011-12-09 Thread Christof Kluß
Hi, a have some code like myfunc <- function(x) { ...; return c(a,b) } ys <- sapply(0:100,myfunc) so I get something like c(c(a1,b1),c(a2,b2),...) But now I need the "as" and "bs" in one vector as <- apply(ys, function(c(a,b)) a) bs <- apply(ys, function(c(a,b)) b) Can you help me with the

Re: [R] apply on function with vector as result

2011-12-09 Thread Christof Kluß
Am 09-12-2011 12:54, schrieb Sarah Goslee: >> myfunc<- function(x) {a=x; b=x-1; c(a, b) } >> ys<- sapply(1:5, myfunc) >> ys > [,1] [,2] [,3] [,4] [,5] > [1,]12345 > [2,]01234 > > And from there, it's not at all clear what you mean by "one vector" - > i

[R] clear plot linear mixed model

2012-01-02 Thread Christof Kluß
Hi, first a happy new year ;) I would like to plot the regression lines of a model like lme <- lme(conc ~ name/time - 1, random=conc~time|nr,method="ML",data=measurements) Ideally a seperate plot for each regression line (respectively name) and seperate colors for the measurements (nr). H

Re: [R] clear plot linear mixed model

2012-01-02 Thread Christof Kluß
Am 02-01-2012 10:54, schrieb ken knoblauch: Christof Kluß email.uni-kiel.de> writes: lme<- lme(conc ~ name/time - 1, random=conc~time|nr,method="ML",data=measurements) see plot.augPred in the nlme package thx, but how to set "primary"? I always get t

[R] selection part of "subset"

2012-01-05 Thread Christof Kluß
Hi I want to do something like a <- c(10,20,15,43,76,41,25,46) tab <- data.frame(a) name <- "a" for (v in unique(tab[[name]])) { r <- subset(tab, name==v) # this does not work ... } i.e. a "string" on the left side of the select expression (subset). How could I solve this? thx Christof

Re: [R] selection part of "subset"

2012-01-05 Thread Christof Kluß
Hi the output should look like r <- subset(tab, a==v) but now I have something like r <- subset(tab, "a"==v) and r <- subset(tab, [["a"]]==v) does not work :( greetings Christof Am 05-01-2012 16:51, schrieb Christof Kluß: > Hi

Re: [R] selection part of "subset"

2012-01-09 Thread Christof Kluß
Hi thank you very much for your useful answers! In this case I solved it with Sarah's suggestion tab[tab[[name]] == v,] that works fine Greetings Christof Am 05-01-2012 16:51, schrieb Christof Kluß: > Hi > > I want to do something like > > a <- c(10,20,1

[R] RODBC vs gdata

2012-01-09 Thread Christof Kluß
Hi one col in my Excel file contains many numbers. But on line 3000 and some other lines are strings like "FG 1". "RODBS" seems to omit this lines. "gdata" works, but is much slower. Is this a bug of RODBC or do I apply it wrong? Example with the same "file.xlsx" library(RODBC); excel <- odbcC

Re: [R] RODBC vs gdata

2012-01-09 Thread Christof Kluß
ShowDoc("RODBC", package="RODBC") > > Regards, > Enrico > > > Am 09.01.2012 19:02, schrieb Christof Kluß: >> Hi >> >> one col in my Excel file contains many numbers. But on line 3000 and >> some other lines are strings like "FG 1&qu

[R] break an axis.POSIXct

2012-01-20 Thread Christof Kluß
Hi I like to use "axis.POSIXct" to plot days from 2006 till 2008. But I only have datas for the summer months. Is it possible to get two axis breaks, to have not so long distances without points? thx Christof __ R-help@r-project.org mailing list https:

[R] visualize lme results

2012-01-22 Thread Christof Kluß
Hi for each measurement day we use "lme" for our four repetitions. Now it would be great if we can represent the error too. The following seems to be good. Unfortunately, there is not the full example source code. Maybe someone has done it before. (from http://anthony.darrouzet-nardi.net/science

[R] plotting dates, incorrectly scaled x-axis?

2012-02-12 Thread Christof Kluß
Hi, I want to plot with axis.Date(), but something is scaled incorrectly. The red vertical line in is put on a totally wrong position. (sample below) Do you have an idea what I'm doing wrong? Thx Christof x11(width=30, height=20) x<-seq(as.Date("2010-02-27"), as.Date("2011-03-28"),"month") y

[R] plotting dates, incorrectly scaled x-axis?

2012-02-12 Thread Christof Kluß
Hi, I want to plot with axis.Date(), but something is scaled incorrectly. The red vertical line in is put on a totally wrong position. (sample below) Do you have an idea what I'm doing wrong? Thx Christof x11(width=30, height=20) x<-seq(as.Date("2010-02-27"), as.Date("2011-03-28"),"month") y