[R] extract index during execution of sapply

2007-06-22 Thread Christian Bieli
Hi there During execution of sapply I want to extract the number of times the function given to supply has been executed. I came up with: mylist - list(a=3,b=6,c=9) sapply(mylist,function(x)as.numeric(gsub([^0-9],,deparse(substitute(x) This works fine, but looks quite ugly. I'm sure that

[R] Data management problem (reorder rows in dataframe by text flag)

2007-02-07 Thread Christian Bieli
(col1=t.x[1,],col2=sub(\\*$,,t.x[2,])) greets christian -- Christian Bieli, project assistant Institute of Social and Preventive Medicine University of Basel, Switzerland Steinengraben 49 CH-4051 Basel Tel.: +41 61 270 22 12 Fax: +41 61 270 22 25 [EMAIL PROTECTED] www.ispm-unibasel.ch

Re: [R] factor levels with umlauts

2006-10-10 Thread Christian Bieli
, Christian Bieli wrote: Hi all I have to generate some test data for import in an sql database. The database is meant for web-based data entry in a study taking place in a german speaking region, so factor levels of the variables include umlauts. The variables in the dataframe t.muster

[R] factor levels with umlauts

2006-10-06 Thread Christian Bieli
Hi all I have to generate some test data for import in an sql database. The database is meant for web-based data entry in a study taking place in a german speaking region, so factor levels of the variables include umlauts. The variables in the dataframe t.muster are generated e.g. like this:

[R] Passing arguments to glm()

2006-06-30 Thread Christian Bieli
Hi there I want to pass arguments (i.e. the response variable and the subset argument) in a self-made function to glm. Here is one way I can do this: f.myglm - function(y,subfact,subval) { glm(d.mydata[,y]~d.mydata[,'x1'],family=binomial,subset=d.mydata[,subfact]==subval) } str(d.mydata)

[R] random generation of a factor

2006-05-22 Thread Christian Bieli
Hi everybody Does anybody know a function that generates a factor of length N with K levels given the proportions c(p1, p2,... ,pk)? It would not be too hard to write it for myself, but if there's a preexisting one.. I searched the documentation and the help archive, but could not find

Re: [R] random generation of a factor

2006-05-22 Thread Christian Bieli
Dear Dave and Roland Thanks for your answers! I think sample() does the job I'm looking for. I also came up with rmultinom(), but could not make it working, because I don't want several multinomial distributed vectors, but one vector with K levels of predefined proportions. Propably there is a

[R] How to handle large dataframes?

2006-02-14 Thread Christian Bieli
RAM) and I work on a Windows XP platform. I am working on a Windows XP platform with R version 2.1 (all packages updated). Thanks for your answers. Christian -- Christian Bieli, project assistant Institute of Social and Preventive Medicine University of Basel, Switzerland Steinengraben 49 CH

[R] GEE Modelle in Stata und R

2006-02-08 Thread Christian Bieli
-.3976316 5.36526 -- Christian -- Christian Bieli, project assistant Institute of Social and Preventive Medicine University of Basel, Switzerland Steinengraben 49 CH-4051 Basel Tel.: +41 61 270 22 12 Fax

[R] assign object to list

2006-01-20 Thread Christian Bieli
to create all the dataframes in my workspace first. I tried it with parentheses {}, but it obviously did not work. Thanks in advance. Christian -- Christian Bieli, project assistant Institute of Social and Preventive Medicine University of Basel, Switzerland Steinengraben 49 CH-4051 Basel Tel.: +41

[R] updating formula inside function

2006-01-11 Thread Christian Bieli
Dear R-Helpers Given a function like foo - function(data,var1,var2,var3) { f - formula(paste(var1,'~',paste(var2,var3,sep='+'),sep='')) linmod - lm(f) return(linmod) } By typing foo(mydata,'a','b','c') I get the result of the linear model a~b+c. How can I rewrite the

[R] Indexing variables within lapply?

2005-11-29 Thread Christian Bieli
it with lapply(data, myfunction,...), but I dont know if theres a way to index the two vars within lapply. There is certainly a way to do it by looping, but lapply is much more elegant. Thank you for your help. Christian -- Christian Bieli, project assistant Institute of Social and Preventive Medicine

[R] problems with submitting an eps-file created in R

2005-07-22 Thread Christian Bieli
to embed fonts? 2. Is there a way to set up the resolution of the created ps/eps-file in R (until now I did the settings in ghostview)? 3. I did not find particulars about the pointsize option. What is the effect of changing the pointsize value? With best regards Christian -- Christian Bieli