[R] initalizing and checking validity of S4 classes

2007-07-25 Thread Bojanowski, M.J. (Michal)
Dear Martin and Seth, Thanks a million for explanations and suggestions. I find myself still in the process of learning S4 system. Can you possibly suggest some material that I could use in this process? Anything apart from Programming with data book? I also know the notes written by John

[R] initalizing and checking validity of S4 classes

2007-07-24 Thread Bojanowski, M.J. (Michal)
Dear useRs and wizaRds, I am currently developing a set of functions using S4 classes. On the way I encountered the problem exemplified with the code below. For some reason the 'validity' method does not seem to work, i.e. does not check for errors in the specification of the slots of the

[R] ODP: Updating R version

2007-06-02 Thread Bojanowski, M.J. \(Michal\)
Is R not loading the packages at all (like they were never installed), or perhaps it is complaining that they were build on the older version of R? You have to be more specific here about what happens etc. For now try running update.packages and see if it fixes the problem. I would also

Re: [R] tapply

2007-06-01 Thread Bojanowski, M.J. \(Michal\)
I'm not sure what is the 'pvalue' function (it's not found in base nor stats packages) but this should give you what you want: # some example re - rnorm(100) reg - rep(1:3, length=100) ast - rep(1:2, length=100) tapply( re, list(reg, ast), function(v) shapiro.test(v)$p.value ) # or neater by

Re: [R] random effects in lmer

2007-06-01 Thread Bojanowski, M.J. \(Michal\)
Look here for the answer: https://stat.ethz.ch/pipermail/r-help/2006-May/094765.html : :: ::: Note that my e-mail address has changed to m.j.bojanowski at uu dot nl ::: Please update you address books accordingly. Thank you! :: : Michal Bojanowski ICS /

Re: [R] Help with optim

2007-05-29 Thread Bojanowski, M.J. \(Michal\)
Hi, Unfortunately I don't think it is possible to do exactly what you want, but: If the numbers reported by 'optim' to the console are enough for you, then consider using 'capture.output'. Below I used the example from 'optim' help page, because I could not use yours directly. hth, Michal #

Re: [R] How to transform matrices to ANOVA input datasets?

2007-03-14 Thread Bojanowski, M.J. \(Michal\)
Hi Josh, Consider what follows to convert your data and estimate the models. I am not sure however, what do you want to do after the models are estimated, so my suggestions stop at this point. HTH, Michal # -b-e-g-i-n---R---c-o-d-e- # first i make some data that is similar to yours so i can

Re: [R] Highlight overlapping area between two curves

2007-03-13 Thread Bojanowski, M.J. \(Michal\)
If PDF is OK, you can use the 'alpha' argument in colors, i.e.: pdf( file.pdf) p - seq(0.2,1.4,0.01) x1 - dnorm(p, 0.70, 0.12) x2 - dnorm(p, 0.90, 0.12) plot(range(p), range(x1,x2), type=n) polygon(p, x1, col = rgb(1,0,0, .5),lwd=4, lty=2) polygon(p, x2, col = rgb(0,0,1, .5),lwd=4) dev.off()

Re: [R] 'substitute' question

2007-03-13 Thread Bojanowski, M.J. \(Michal\)
I do not understand why you play with 'substitute' instead of something like this: # CAUTION: this will work only for bivariate case # plotmaking function plotModel - function(m) { x - m$model$x y - m$model$y r2 - summary(m)$r.squared plot(x,y) abline(m)

Re: [R] 'substitute' question

2007-03-13 Thread Bojanowski, M.J. \(Michal\)
I'm sorry for my first post as I did not properly understood your problem. The reason why you were getting paste(R^2, = , 48.7) instead of the properly formatted R^2=48.7 is that in creating 'texts' in your code you were mixing character string with expressions resulting in 'texts' being a list

Re: [R] inconsistent behaviour of add1 and drop1 with a weighted linear model

2007-03-13 Thread Bojanowski, M.J. \(Michal\)
Hmmm, this is the same I got add1(model,.~.+x1+x2) Single term additions Model: y ~ 1 Df Sum of SqRSSAIC none 74.541 24.703 x1 144.377 30.164 14.942 x2 136.619 37.922 17.918 R version 2.4.1 (2006-12-18) i386-pc-mingw32 locale:

Re: [R] sink with R-code

2007-03-08 Thread Bojanowski, M.J. \(Michal\)
Hi, How about 'capture.output'? You could also put the code in a separate file and sink the sourcing it with the echo=TRUE argument, for example (input.r contains the commands). sink(output.txt) source(input.r, echo=TRUE) sink() HTH, Michal *** Note that my e-mail address has changed to

Re: [R] Searching and deleting elements of list

2007-03-08 Thread Bojanowski, M.J. \(Michal\)
Hi, A little bit shorter perhaps: # deletion mydata2 - lapply( mydata, function(x) x[ !(x %in% A) ] ) # insert A again mydata2[[1]] - A mydata2 [[1]] [1] aaa bbb ccc ddd eee [[2]] [1] vvv ooo zzz [[3]] [1] sss jjj ppp [[4]] character(0) Please note that if all elements are deleted (as

[R] ODP: Plotting a broken line?

2007-03-07 Thread Bojanowski, M.J. \(Michal\)
Hi Aldi, Yet another way to do what you want. 'd' is your data frame. You cannot easily modify the attributes of the lines however... # just to set up coordinates plot( d$Location, d$otherinfo, type=n) # plot the lines invisible(by(d, d$indicator, function(dd) lines(dd$Location,

[R] using non-ASCII strings in R packages

2007-01-24 Thread Bojanowski, M.J. \(Michal\)
Hello dear useRs and wizaRds, I am currently developing a package that will enable to use administrative map of Poland in R plots. Among other things I wanted to include region names in proper Polish language so that they can be used in creating graphics etc. I am working on Windows and when I

[R] problem with hist() for 'times' objects from 'chron' package

2006-06-23 Thread Bojanowski, M.J. \(Michal\)
Hello dear useRs and wizaRds, I encountered the following problem using the hist() method for the 'times' classes from package 'chron'. You should be able to recreate it using the code: library(chron) # pasted from chron help file (?chron) dts - dates(c(02/27/92, 02/27/92, 01/14/92, 02/28/92,

[R] rearranging data frame rows

2006-06-23 Thread Bojanowski, M.J. \(Michal\)
Hi Fede, How about using merge()? For example: n - letters[1:10] d1 - data.frame( n=n, x1=rnorm(10) ) d2 - data.frame( n=sample(n), x2=rnorm(10)) d1 d2 merge(d1,d2) Is this what you had in mind? HTH, Michal