Re: [R] Recoding

2008-06-28 Thread jgarcia
Agustín; also you can do: > v <- c(1,1,1,2,3,4,1,10,3) > dict <- cbind(c(1,2,3),c(1001,1002,1003)) > v <- ifelse(!is.na(match(v,dict)),dict[match(v,dict),2],v) > v [1] 1001 1001 1001 1002 10034 1001 10 1003 Javier - > Dear Agustin, > > Perhaps > > v1 <- c(1,1,1,2,3,4,1,10,3) > dpu

Re: [R] use of quotation marks

2008-06-28 Thread Prof Brian Ripley
The answer may be simple: you need to use quotation marks and not the falsely named 'smart quotes' of Office. How are you writing your programs? It is best to use an R-aware text editor, but it you must use Word or similar, turn off all the automatic mis-features. On Fri, 27 Jun 2008, Rodri

Re: [R] For loop

2008-06-28 Thread ctu
Hi, I guess this what your need. I assume your output is 10 by 11 matrix. However, you still need to define your geneset function(?) result<- list() output<-matrix(NA, nrow=10, ncol=11) for(i in 1:length(ncol(output))) { result[[i]] <- geneset(which(geneset %n% output[1,])) } Chunha

Re: [R] median of grouped data

2008-06-28 Thread Peter Dalgaard
jim holtman wrote: Is this what you want: # split the dataframe by the grouping (z was your sample data) z.s <- split(z, z[[1]]) # calculate the median (ans <- lapply(z.s, function(.grp) apply(.grp[,7:9], 2, median))) $HOR006_3 TC.15_comps IC.16_comps SOC.17_comps 10.549669 4.

[R] How to get the 5th percentile( with a 95% CI )of the Kaplan-meier estimator?

2008-06-28 Thread 程燕
Hi, all dear R experts, I am really stuck by how to get the 5th percentile( with a 95% CI )of the Kaplan-meier estimator of survival function P(T>t). I have a simulated sample of lifetime Ts, then I set the KM estimator < km.fit<-survfit(Surv(T),type="kaplan-meier",data=Surv(T)) https://st

[R] How to estimate the parameters in a bivariate weibull distribution?

2008-06-28 Thread 程燕
Hi,Dear all R experts, As far as I know, fitdistr() is only to estimate the parameters in univariate distributions. I have a set of data (x,y) and I assume it follows a bivariate weibull distribution. Could someone tell me a function in R that is suitable for parameter estimation in mult

Re: [R] lme4 package

2008-06-28 Thread Takatsugu Kobayashi
Hi, Could someone explain what this message mean? I was playing with lme4 pacakge but I could not run any models... Error in printMer(object) : no slot of name "dims" for this object of class "table" In addition: Warning message: In printMer(object) : trying to get slot "dims" from an object (cl

Re: [R] lme4 package

2008-06-28 Thread Ben Bolker
Takatsugu Kobayashi indiana.edu> writes: > > Hi, > > Could someone explain what this message mean? I was playing with lme4 > pacakge but I could not run any models... > > Error in printMer(object) : > no slot of name "dims" for this object of class "table" > In addition: Warning message: > In

Re: [R] plotting prcomp

2008-06-28 Thread Gavin Simpson
On Fri, 2008-06-27 at 21:43 +0200, Dan Bolser wrote: > 2008/6/27 Prof Brian Ripley <[EMAIL PROTECTED]>: > > > > I forgot to answer that: just ask R to show you stats:::biplot.prcomp > > Ah! I never knew the ::: trick! In this case you also need to know that biplot.prcomp is in stats. getAnywhere

[R] ungrouped data for multinomial regression

2008-06-28 Thread Rodrigo Briceño
Thanks for helping me out with the thing of quotation marks. I finally could save time running programs at the university and home. One additional question for all of you. I'm starting to be familiar with multinomial regression models. Actually I'm doing some exercise with the pneumo data that appe

[R] mapping one redundant index to another redundant index

2008-06-28 Thread John Lande
Dear R users, I have a simple problem I cannot solve, but I sure you can help. I have two vector, let say > tmp1 <- c("a", "a", "b", "c") > tmp2 <- c("a", "a", "b", "c", "c", "d") and I want to create a matrix of two column for which I have all the combinations of the same character, let say li

[R] String concatenation

2008-06-28 Thread Andy Fugard
Hi, Is the following function built in somewhere? concat = function(v) { res = "" for (i in 1:length(v)) res = paste(res,v[i],sep="") res } e.g. > concat(c("12","3","45")) [1] "12345" Cheers, Andy -- Andy Fugard, Postgraduate Research Student Psychology (Room F3), The University

[R] one cluster question

2008-06-28 Thread 王春萍
Dear everyone: I am now trying one exercise using clustering method£¬I want to identify clusters and members for each cluster from the clustering result. it is important that i want to require the minimal distance between members in one cluster below one fixed cutoff So I am writing to

Re: [R] mapping one redundant index to another redundant index

2008-06-28 Thread Gabor Grothendieck
merge(tmp1, tmp2) gives the basic data and you can put it in the form requested using: Tmp1 <- data.frame(x = tmp1) Tmp2 <- data.frame(x = tmp2) M <- merge(Tmp1, Tmp2) data.frame(tmp1 = M$x, tmp2 = M$x) or using Tmp1 and Tmp2 from above: library(sqldf) sqldf("select x tmp1, x tmp2 from Tmp1 nat

Re: [R] String concatenation

2008-06-28 Thread Peng Jiang
Hi, Andy I am a little confused, why don't you just use paste() directly? > paste("12","3","45",sep="") produce the same result with your concat. regards . On 2008-6-28, at 下午7:44, Andy Fugard wrote: Hi, Is the following function built in somewhere? concat = function(v) { res = "" for

Re: [R] String concatenation

2008-06-28 Thread Prof Brian Ripley
paste(v, collapse="") On Sat, 28 Jun 2008, Andy Fugard wrote: Hi, Is the following function built in somewhere? concat = function(v) { res = "" for (i in 1:length(v)) res = paste(res,v[i],sep="") res } e.g. concat(c("12","3","45")) [1] "12345" Cheers, Andy -- Andy Fugard, Postg

Re: [R] change values in data frames

2008-06-28 Thread poul
Thanks a lot, it works perfectly . Bye Paul jholtman wrote: > > Is this what you want: > >> x > cola colb > 11c > 21i > 31i > 41c > 52i > 62c > 72c > 82i > 92i >> # generate run lengths >> z <- rle(x$colb) >> # calculat

Re: [R] Connecting lines across missing data points, xyplot

2008-06-28 Thread Carl Witthoft
Just had to comment that I thought this question was unintentionally funny, seeing as many of us have gone thru a lot of pain to force Excel NOT to join lines across NA-type points in our data. Back to the subject: if you use is.na(), just be careful to remove the corresponding values in th

[R] Converting the results of granger.test into a matrix

2008-06-28 Thread tolga . i . uzuner
Dear R Users, The granger.test command in the MSBVAR package estimates all possible bivariate Granger causality tests for m variables. If one passes a data frame with 3 rows, it returns 6 granger tests in two rows, one for the F-statistic and another for the p-value. For example: > a<-rnorm(1

Re: [R] include S4 class and methods in a package

2008-06-28 Thread Charilaos Skiadas
On Jun 27, 2008, at 1:44 PM, baptiste Auguié wrote: DeaR list, Pardon the stupidity of this question but I've been trying this for a while now without success. I've followed the example given in the green book "programming with data", and I now have a working example of a S4 class with a

Re: [R] include S4 class and methods in a package

2008-06-28 Thread baptiste Auguié
Thanks Haris, I eventually got this to work thanks to some off-list help and lots of trials and error. I have to admit I still don't understand all the details of the procedure (the "generic" paradigm in particular escapes me), but at least I have achieved a working example that I can alter

[R] Parallel R

2008-06-28 Thread Juan Pablo Romero Méndez
Hello, The problem I'm working now requires to operate on big matrices. I've noticed that there are some packages that allows to run some commands in parallel. I've tried snow and NetWorkSpaces, without much success (they are far more slower that the normal functions) My problem is very simple,

Re: [R] Converting the results of granger.test into a matrix

2008-06-28 Thread tolga . i . uzuner
Hi Patrick, Thanks, that worked. noitems<-3 firstcol<-{result<-NULL;for(i in 1:noitems)result<-c(result,(1:noitems)[-i]);result} secondcol<-{result<-NULL; for(i in 1:noitems) result<-c(result,rep(i,noitems-1)); result} cols<-cbind(firstcol,secondcol) gt_mat<-array(NA,c(noitems,noitems)) gt_m

[R] ggplot2 axis scales

2008-06-28 Thread Felipe Carrillo
Hi all: Was this question ever answered? #Is it possible to have different axis limit for each facet in a ggplot2 plot? Here is an example library(ggplot2) x=seq(-10,10,.1) y=cos(x) z=sin(x)*10 dat=melt(data.frame(x,y,z), id.var="x") qplot( x, value, data=dat, facets=variable~., geom="line" ) +

Re: [R] change values in data frames

2008-06-28 Thread Kenn Konstabel
Another way to do it (a more or less straightforward translation of what you said): fun <- function(x) { xp <- c("", x)[-(length(x)+1)] # to get the "previous element of x" x[1] <- if(x[1]=="i") "l" else x[1] x <- ifelse(x == "i" & xp == "c", "l", x) x <- ifelse(x == "i" &

[R] creating a dataframe using a list of the variable names

2008-06-28 Thread Stephane Bourgeois
Hello, I'm fairly new to R, and despite spending quite some time exploring, testing, and looking for answers, I still have a couple of questions remaining... The first one is about creating a dataframe using a list of the variable names . I get this output file from a database: BOB <- c('A/A',

Re: [R] creating a dataframe using a list of the variable names

2008-06-28 Thread jim holtman
Does this do what you want: > BOB <- c('A/A', 'C/C', '15/27') > MARY <- c('A/A', NA, '13/12') > JOHN <- c('A/A', 'C/A', '154/35') > CLIFF <- c('A/C', 'C/C', '15/12') > PAM <- c('A/C', 'C/A', '13/12') > sampleList <- c("BOB", "MARY", "JOHN", "CLIFF", "PAM") > polyList <- c("rs123", "rs124", "rs555"

[R] Interactive plot

2008-06-28 Thread Ron Michael
Hi all, I have created following codes : mat = cbind(c(0.59710430,0.23057380), c(0.23057380, 0.5971089)) set.seed = 1000 vary = runif(dim(mat)[1], 2000, 3000) calc = function(mat, vary) { result = vector(length = (length(vary)+1)) result[1] = sqrt(t(vary) %*% vary)

Re: [R] String concatenation

2008-06-28 Thread Andy Fugard
On 28 Jun 2008, at 16:20, Peng Jiang wrote: Hi, Andy I am a little confused, why don't you just use paste() directly? > paste("12","3","45",sep="") produce the same result with your concat. The problem is that I have a vector, not those individual arguments. But the collapse argument does

[R] Accessing methods and extending S4 classes of existing packages

2008-06-28 Thread Johannes Huesing
Dear all, I am trying to understand how to access S4 methods after loading a package, using the online documentation of getMethod and friends. This is what I have been trying: > library(coin) > findMethods("ApproxNullDistribution") list() Warning message: In findMethods("ApproxNullDistribution")

Re: [R] Parallel R

2008-06-28 Thread Martin Morgan
"Juan Pablo Romero Méndez" <[EMAIL PROTECTED]> writes: > Hello, > > The problem I'm working now requires to operate on big matrices. > > I've noticed that there are some packages that allows to run some > commands in parallel. I've tried snow and NetWorkSpaces, without much > success (they are far