[R] within: order of newly added variables

2009-09-02 Thread RINNER Heinrich
Dear R community, I am using function 'within' in R.2.9.1 to add variables to an existing data.frame. This works wonderful, except for one minor point: The new variables are added to the data in reverse order. For example: x <- data.frame(a = 1:3, b = 4:6) y <- within(x, { c = a^2 d =

[R] putting reference lines or grids into the background of a plot

2009-09-03 Thread RINNER Heinrich
Dear R-community, using R.2.9.1, how do you put reference lines or grids into the _background_ of a plot? For example: barplot(3:1) abline(h = seq(0.5, 2.5 ,0.5), col = "red", lty = "dashed") -> The lines are before the bars (and the line parts going through the bars might be considered as "ch

[R] lattice: adding information on number of observations

2009-12-01 Thread RINNER Heinrich
Dear R-users, I am using R version 2.9.1 and lattice 0.17-26 under windows. In a lattice boxplot, I would like to add information on how many observations each singel boxplot is based upon. For example (the basic plot): # Begin R-code library(lattice) dat <- data.frame(panvar = rep(c("A","B","A"

[R] read.spss: option "to.data.frame" and string variables

2010-01-12 Thread RINNER Heinrich
Dear R-users, I am using R version 2.10.1 and package foreign version 0.8-39 under windows. When reading .sav-Files (PASW Statistics 18.0.1) containing string variables, these are automatically converted to factors when using option "to.data.frame = TRUE" (see example below). It's clear to me w

[R] barplot: border color when stacked

2010-01-12 Thread RINNER Heinrich
Dear R-users, I am using R version 2.10.1 under windows. In a barplot, I want to mark one of the bars with a special border color. For example: barplot(c(3, 7, 11), border = c(NA, "red", NA)) But how to do this when the bars are stacked? for example: barplot(matrix(1:6, ncol=3)) # border of seco

[R] tapply and more than one function, with different arguments

2010-01-26 Thread RINNER Heinrich
Dear R-users, I am working with R version 2.10.1. Say I have is a simple function like this: > my.fun <- function(x, mult) mult*sum(x) Now, I want to apply this function along with some other (say 'max') to a simple data.frame, like: > dat <- data.frame(x = 1:4, grp = c("a","a","b","b")) Ide

Re: [R] tapply and more than one function, with different arguments

2010-01-26 Thread RINNER Heinrich
Hi Dennis, now that's a very nice function, and this seems to be just what I need! Thanks a lot! -Heinrich. Von: Dennis Murphy [djmu...@gmail.com] Gesendet: Dienstag, 26. Januar 2010 19:44 An: RINNER Heinrich Cc: r-help Betreff: Re: [R] tapply and more

Re: [R] Highlighting a few bars in a barplot

2010-09-09 Thread RINNER Heinrich
Hello Daniel, something like that might work: x <- runif(6) marker1 <- rep(c("red", "blue"), 3) marker2 <- c(rep(0,5), 10) barplot(x, col = marker1) barplot(x, density = marker2, add=T) But I'd be interested if you learn about other solutions... -Heinrich. > -Ursprüngliche Nachricht- >

[R] RODBC: forcing a special column to be read in as character

2010-10-13 Thread RINNER Heinrich
Dear R-users, I am working with R version 2.10.1 and package RODBC Version: 1.3-2 under windows. Say I have a table "testtable" (in an Access data base), which has many different columns, among them a character column "X" with "integer-like" data as "0012345". Using sqlFetch, I'd like to assur

Re: [R] plot CI and mortality rate

2010-10-20 Thread RINNER Heinrich
You could also use lattice + Hmisc: # Fake data (taken from Dennis Murphy's reply): mortrate <- round(runif(100), 3) moe = 1.96 * sqrt(mortrate * (1 - mortrate))/10 dd <- data.frame(rate = mortrate, CI.lower = mortrate - moe, CI.upper = mortrate + moe, hosp = factor(paste('H', 1:100, sep = '')))

[R] RODBC: data base with decimal point ","

2010-10-21 Thread RINNER Heinrich
Dear R-users, I am working with R version 2.10.1 and package RODBC Version: 1.3-2 under windows. Say I have a table "testtable" (in an Access data base) with 3 columns and 1 row that looks like this: X Y Z 0012345 42 42,1 The columns are of these types: X - character, Y

Re: [R] RODBC: data base with decimal point ","

2010-10-25 Thread RINNER Heinrich
l list you mentioned, maybe I find something there. Best wishes, Heinrich. > -Ursprüngliche Nachricht- > Von: Marc Schwartz [mailto:marc_schwa...@me.com] > Gesendet: Freitag, 22. Oktober 2010 14:53 > An: RINNER Heinrich > Cc: r-h...@stat.math.ethz.ch > Betreff: Re: [R] RO

[R] replace text at certain positions in a file

2010-10-28 Thread RINNER Heinrich
Hello, I am working with R version 2.10.1 under windows. In a text file, I need to replace all characters at certain column positions with blanks. For example, say the file contains two lines and looks like this: ab34cd78e fg3 hi78j I'd like to replace everything at positions 3-4 and 7-8 with b

Re: [R] replace text at certain positions in a file

2010-11-02 Thread RINNER Heinrich
") in the replacement part, so something is wrong in my expression there. I just can't figure out what... Kind regards Heinrich. > -Ursprüngliche Nachricht- > Von: Gabor Grothendieck [mailto:ggrothendi...@gmail.com] > Gesendet: Donnerstag, 28. Oktober 2010 13:40 > An

[R] lattice: left-aligned text in strips?

2008-05-14 Thread RINNER Heinrich
[adapted repost of question http://tolstoy.newcastle.edu.au/R/e4/help/08/03/6260.html] Dear R community, by default, text in the strips of a trellis plot is centered in the strip. Is there a way to have the text left-aligned? For example: library(lattice) test <- data.frame(x=rnorm(100), y=rnor

Re: [R] lattice: left-aligned text in strips?

2008-05-15 Thread RINNER Heinrich
left.aligned) ### Anywag, thanks again for having taken the time thinking about my question; Heinrich. > -Ursprüngliche Nachricht- > Von: Charilaos Skiadas [mailto:[EMAIL PROTECTED] > Gesendet: Mittwoch, 14. Mai 2008 13:30 > An: RINNER Heinrich > Cc: [EMAIL PROTECTED] > B

Re: [R] Confidence Interval for SMR

2008-02-19 Thread RINNER Heinrich
You could have a look at package "epitools" (on CRAN, or at www.epitools.net). -Heinrich. > -Ursprüngliche Nachricht- > Von: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Im Auftrag von stefan lhachimi > Gesendet: Dienstag, 19. Februar 2008 10:45 > An: [EMAIL PROTECTED] > Betreff: [R] Co

[R] trellis: left-aligned text in strips?

2008-03-11 Thread RINNER Heinrich
Dear R community, by default, text in the strips of a trellis plot is centered in the strip. Is there a way to have the text left-aligned? for example: libary(lattice) test <- data.frame(x=rnorm(100), y=rnorm(100), a=rep(c("A: centered text","B: centered text"),50)) xyplot(y ~ x | a, data = test