search for: rr

Displaying 20 results from an estimated 2341 matches for "rr".

Did you mean: err
2009 Jan 28
3
for/if loop
Hi, it's my first time to write a loop with R for my homework. This loop is part of the function. I wanna assign values for hll according to panel [ii,1]=pp. I didn't get any error message in this part. but then when I further calculate another stuff with hll, the function can't return. I think it must be some problem in my loop. Probably something stupid or easy. But I tried to look for previous posts in forum and read R language help. But none can help.. Thanks! fo...
2010 Apr 19
2
plotting RR, 95% CI as table and figure in same plot
...zero-inflated Poisson models. I would prefer plotting the rate ratios and 95% CI (as I've found Gelman and others convincing about plotting tables...), but our journals usually like the numbers themselves. Thus, I'm looking at a recent JAMA article in which both numbers and dotplot of RR and 95% CI are presented and wondering about best way to do this in R. Essentially, the plot has 3 columns: variable names, RR and 95% CI, and dotplot of the same. Using the bioChemists data in the pscl package and errbar function in Hmisc package, the code below is in the right direction... b...
2013 Apr 25
1
time series plot: x-axis problem
Hi, I'm trying to plot a simple time series. I'm running into an issue with x-axis The codes below will produce a plot with correct x-axis showing from Jan to Dec > rr=c(3,2,4,5,4,5,3,3,6,2,4,2) > (rr=ts(rr,start=c(2012,1),frequency=12)) > win.graph(width=6.5, height=2.5,pointsize=8) > plot(rr, xlab="2012", ylab="event freq", xaxt = "n", col="blue") > axis(1, time(r...
2010 Jun 08
2
problem with if else statement
Dear colleagues, What did I not understand ? ->my intention I want to create a new variable: In plain language: If someone is taking anithypertensive treatment (med.hyper==1) table(med.hyper) med.hyper 0 1 472 97 I want to subtract 5 mmHg (rr.dia.2m-5) from the measured diastolic blood pressure (rr.dia.2m) if not treated - the value of the measured diastolic blood pressure should remain the same ->my code (data frame is attached !) rr.dia2.corr<-if(med.hyper==1) { rr.dia.2m-5 } else { rr.dia2.corr==rr.dia.2m } R warning Warnme...
2001 Sep 06
0
crosstabulation
...y x 0 (%) 1 (%) 0 14 ( 77.8) 4 ( 22.2) 1 3 ( 42.9) 4 ( 57.1) > ################################################# Table<- function(..., margin = 1) { proportion.table<- function(data, MARGIN = 1) { if(is.null(d <- dim(data))) stop("data is not an array") if(any(data < 0) || any(trunc(data) != data)) stop("data is not an array of counts") if(length(MARGIN)) sweep(data, MARGIN = MARGIN, apply(data, MARGIN = MARGIN, sum), "/") else data/sum(data) } tt <- table(...) dd <- dim(tt) dnam <- dimnames(tt) if(length(d...
2009 Sep 29
4
Something wrong with my function Please Help
Hi R users, I try to build a function to compute odds ratio and relative risk however something wrong. I stuck for many hours but I really don't know how to solve it. Would someone please give me a hint? > OR.RR<-function(x){ + x <- as.matrix(any(dim(x)==2)) + OR<-(x[1,1]*x[2,2])/(x[1,2]*x[2,1]) + RR<-(x[1,1]/(sum(x[1,])))/(x[2,1]/(sum(x[2,]))) + return(OR);return(RR) + } > > tt<-matrix(data=1:4,nrow=2,ncol=2) > OR.RR(tt) Error in OR.RR(tt) : subscript...
2000 Oct 19
2
Multiple outputs of a function
Hello everybody, I'm writting some functions for experimental designs. The one I'm working on is similar to "fac.design" on Splus. The problem I have is with the form of the output : When the argument fraction is submitted, Splus gives something like : A B C 1 - - - 2 + + - 3 + - + 4 - + + Fraction : ~A:B:C The first part of this output is the
2013 Feb 14
1
mapply error with Math (S4 group generic)
I get an error when using self-defined (not standard) functions with mapply with S4 objects from the raster package that I develop: "Error in as.character(sys.call(sys.parent())[[1]]) : cannot coerce type 'closure' to vector of type 'character'". Does anyone understand why? The prob...
2005 Jul 12
2
Puzzled at ifelse()
I have a situation where this is fine: > if (length(x)>15) { clever <- rr.ATM(x, maxtrim=7) } else { clever <- rr.ATM(x) } > clever $ATM [1] 1848.929 $sigma [1] 1.613415 $trim [1] 0 $lo [1] 1845.714 $hi [1] 1852.143 But this variant, using ifelse(), breaks: > clever <- ifelse(length(x)>15, rr.ATM(x, maxtrim=7), r...
2003 Oct 18
1
why does data frame subset return vector
Hello, I've a weired problem with a data frame. Basically it should be just one column with specific names coming from a data file (the file contains 2 rows, one should be the for the rownames of the data frame the other contains numeric values). > df.rr <- read.table("RR_anova.txt", header=T, comment.char="", row.names=1) > df.rr[c(1,2,3),] [1] 1.11e-16 1.11e-16 1.11e-16 Why are the rownames not displayed? The data file itself look slike this: > df.rr <- read.table("RR_anova.txt", header=T, comment.char=...
2009 Nov 17
1
Codoc mismatches
I have a function: source_dir <- function(path, pattern = "\\.[rR]$", chdir = TRUE) ... documented with ... \usage{source_dir(path, pattern="\\.[rR]$", chdir=TRUE)} ... But I get Codoc mismatches from documentation object 'source_dir': source_dir Code: function(path, pattern = "\\.[rR]$", chdir = TRUE) Docs: function(path,...
2009 Nov 02
2
a prolem with constrOptim
...} S } #where theta=(p11,p12,p13,p21,p22,p23,...,pK1,pK2,pK3). #The function Rmat calculates the restriction matrix needed for constrained estimation Rmat = function(k) { R = matrix(1,4,3) R[1,2] = R[1,3] = R[2,3] = R[3,2] = 0 RR = cbind(-R,R) RRR = matrix(0,4*(k-1),3*k) for ( i in 1:(k-1) ) RRR[4*(i-1)+1:4,3*(i-1)+1:6] = RR RRR } #The function gen.data generates data gen.data = function(p,N) { k = ncol(p) Data = matrix(0,4,k)...
2012 Apr 29
1
Specifying special poisson maximum likelihood
Hi everyone I am stuck on specifying my own maximum likelihood function for a special poisson model. My poisson model is as follow: O ~ Pois(b*N + b*RR*E) With O = observed cases b = constant (known) N = number of unexposed persons (known) E = number exposed persons (known) RR = relative risk (value is assumed under a scenario, e.g. RR=2.0) I used rpois to simulate the values of O for several years with known values of b, N, E and RR. Hence, a...
2011 Jun 30
1
Analysing insecticide biossays using lmer
...e-04 -3.154902 38 25 1 86 D3S 0.7 0.10 7e-04 -3.154902 60 60 2 87 D3S 0.7 0.10 7e-04 -3.154902 70 36 3 88 D3S 0.8 0.10 8e-04 -3.096910 72 51 3 89 D3S 0.9 0.10 9e-04 -3.045757 45 43 1 90 D3S 1.0 0.10 1e-03 -3.000000 48 48 1 91 RR 0.2 1.00 2e-03 -2.698970 39 1 1 92 RR 0.2 1.00 2e-03 -2.698970 60 0 2 93 RR 0.4 1.00 4e-03 -2.397940 39 3 1 94 RR 0.4 1.00 4e-03 -2.397940 60 5 2 95 RR 0.5 1.00 5e-03 -2.301030 60 9 2 96 RR 0.6 1.00 6e-03 -2.221849 39...
2012 Oct 22
1
Matlab code to R code
Dear r-users, I would like to convert my Matlab code to R-code, however it dies not work as expected.  Hope somebody can help me to match Matlab and r codes. R code: rr <- function(r,cxn) { tol <- 1E-4; for(i in 1:n) { t1 <- (1+(i-1)*r)*log((1+(i-1)*r)) t2 <- (i-1)*(1-r)*log(1-r) rri <- ((t1+t2)/i*log(i))-cxn rr <- rri > tol } round(rr,4) } rr1 <- rr(0.5,0.0242) ; rr1 Matlab code: function F = cxncnr(r) n = 4; % terms t1 = (1+(n-1)*r)*l...
2010 Sep 10
6
adding zeroes after old zeroes in a vector ??
Hello Imagine I have a vector with ones and zeroes I write it compactly: 1111111100001111111111110000000001111111111100101 I need to get a new vector replacing the "N" ones following the zeroes to new zeroes. For example for N = 3 1111111100001111111111110000000001111111111100101 becomes 1111111100000001111111110000000000001111111100000 I can do it with a for loop but I've read
2012 Sep 05
1
Outliers in Binary Logistic Regressions
...the solution I am stuck and lost, unable to get along with my work! Someone suggested I should try the code below in order to eliminate the outliers from my data. I did as I was told, but I got a negative reply. The code did not function. I am including it here so that, if possible, someone may correct it for me. That would really be very much appreciated! My data has 1439 rows. *RR.rebuild <- glm(RR, subset=remove) glm(RR, subset=!(1:1439 %in% c(56,303,365,391,512,746,859,940,1037,1042,1138,1355)) influence(RR.rebuild) influence.measures(RR.rebuild)* Many thanks in advance for a...
2012 Aug 07
2
Passing arguments to a function within a function ...
...nc = ", conc) if(verbose==TRUE) message("base.coc = ", base.conc) if(verbose==TRUE) message("relationship = ", relationship) if(is.null(cases)==TRUE) {d <- incidence.rate*pop} # use incidence rate if cases are not available if(relationship == "linear") {RR = exp(beta*(conc-base.conc))} #RR=exp[beta(X-Xo)] if(relationship == "log-linear") {RR = ((conc+1)/(base.conc+1))^beta} if(verbose==TRUE) message("RR = ", RR) AF = (RR-1)/RR #AF=(RR-1)/RR if(verbose==TRUE) message("AF = ", AF) AM = AF * d #AM = AF * cases...
2004 Dec 23
1
PRI unable to request channel
...switch or the T1 card (TE405P). I have a channel in that state at the moment, and here is the output from "pri intense debug span 1" when attempting to make an outgoing call: testbridge*CLI> pri intense debug span 1 Enabled EXTENSIVE debugging on span 1 T203 counter expired, sending RR and scheduling T203 again Sending Receiver Ready (1) > [ 00 01 01 03 ] > Supervisory frame: > SAPI: 00 C/R: 0 EA: 0 > TEI: 000 EA: 1 > Zero: 0 S: 0 01: 1 [ RR (receive ready) ] > N(R): 001 P/F: 1 > 0 bytes of data -- Restarting T203 counter < [ 00 01 01 05 ]...
1997 Aug 15
1
R-alpha: (minor?) S-R inconsistency: NULL =~= list() -- useful is.ALL function
In S, NULL and list() are not the same. In R they are (I think). --------------------------------------------------- At least, is.list(NULL) #-> 'F' in S; 'TRUE' in R Yes: I had an instance where this broke correct S code: match(c("xlab","ylab"), names(list(...))) when '...' is empty, gives an error in R, but gives c(NA,NA) in S. ------------ You may like my function 'is.ALL(.)' for detecting things like these : (actually some more functions; a relatively nice exa...