Re: [R] Calculate Specificity and Sensitivity for a given threshold value

2008-11-13 Thread N. Lapidus
Hi Pierre-Jean, Sensitivity (Se) and specificity (Sp) are calculated for cutoffs stored in the "performance" x.values of your prediction for Se and Sp: For example, let's generate the performance for Se and Sp: sens <- performance(pred,"sens") spec <- performance(pred,"spec") Now, you can have a

Re: [R] detect repeated number in a vector

2008-10-08 Thread N. Lapidus
Can this be an answer ? which(v %in% names(table(v)[table(v)>1])) [1] 2 5 Nael On Wed, Oct 8, 2008 at 8:36 PM, liujb <[EMAIL PROTECTED]> wrote: > > Dear R users, > > I have this vector that consists numeric numbers. Is there a command that > detects the repeated numbers in a vector and returns

Re: [R] vectorized sub, gsub, grep, etc.

2008-10-07 Thread N. Lapidus
Hi John, Wouldn't you get the same with just mapply(sub, patt, repl, X) ? Nael On Tue, Oct 7, 2008 at 9:58 PM, Thaden, John J <[EMAIL PROTECTED]> wrote: > R pattern-matching and replacement functions are > vectorized: they can operate on vectors of targets. > However, they can only use one pat

Re: [R] How can I easily rbind a list of data frames into one data frame?

2008-09-27 Thread N. Lapidus
Try do.call("rbind", nameofyourlist) Nael On Sat, Sep 27, 2008 at 8:51 AM, Matthew Pettis <[EMAIL PROTECTED]>wrote: > Hi, > > I have a list output from the 'lapply' function where the value of > each element of a list is a data frame (each data frame in the list > has the same column types). How

Re: [R] Return a list

2008-09-26 Thread N. Lapidus
The answers that were previously given allow you to easily extract results from your returned list, but if I understand well, this list is created only because you cannot return several arguments whereas you need to keep the values of a, b, c, etc. Am I right? Another solution would be to directly

Re: [R] Converting 1-D array to vector

2008-08-27 Thread N. Lapidus
You were very close to an answer : as.vector(unlist(df[1,])) Nael On Wed, Aug 27, 2008 at 7:53 AM, Ronnen Levinson <[EMAIL PROTECTED]> wrote: > > Hi. > How do I convert a one-dimensional array of characters to a character > vector? In the example below I am trying to get the result c("a",

Re: [R] Convert list of lists <--> data frame

2008-07-23 Thread N. Lapidus
Not very elegant but seems to work: pats.df <- as.data.frame(t(sapply (1:length(pats), function (i) do.call(cbind,pats[[i]] colnames(pats.df) <- names(pats[[1]]) # then pats2 <- lapply (1:nrow(pats.df), function (i) as.list(t(pats.df)[,i])) Nael On Wed, Jul 23, 2008 at 3:23 PM, Michael Frie

Re: [R] Coefficients of Logistic Regression from bootstrap - how to get them?

2008-07-22 Thread N. Lapidus
Hi Michal, This paper by John Fox may help you to precise what you are looking for and to perform your analyses http://cran.r-project.org/doc/contrib/Fox-Companion/appendix-bootstrapping.pdf Nael On Tue, Jul 22, 2008 at 3:51 PM, Michal Figurski < [EMAIL PROTECTED]> wrote: > Dear all, > > I don't

Re: [R] multiplication question

2008-07-02 Thread N. Lapidus
Hi Murali, Just an idea, probably not the best : x<-1:4 y<-1:6 z<-matrix(1:(length(x)*length(y)),nrow=length(x)) I <- matrix(1,nrow=length(x),ncol=length(y)) I[row(I)==col(I)] <- 0 sum (outer (x, y, '*') * I) sum (outer (x, y, '*') * z * I) Hope this helps, Nael On Wed, Jul 2, 2008 at 6:3

Re: [R] naming components of a list

2008-05-25 Thread N. Lapidus
And if you have "thousands of names" like this: names(L) <- paste ("names", 1:length(L), sep="") Nael On Sun, May 25, 2008 at 10:38 PM, Erin Hodgess <[EMAIL PROTECTED]> wrote: > try this: > > > names(L) <- c("name1","name2","name3") > > L > $name1 > [1] "Fred" > > $name2 > [1] "Mary" > > $name3

Re: [R] extracting columns from a list

2008-05-23 Thread N. Lapidus
explicit. Nael On Fri, May 23, 2008 at 3:54 PM, N. Lapidus <[EMAIL PROTECTED]> wrote: > Hi Mohamed > > Try: > lapply (NameOfYourList, function (dat, NumCol) dat[,NumCol], c(12,13)) > > But there must be a shorter way to write this. > > Nael > > > On Fri,

Re: [R] extracting columns from a list

2008-05-23 Thread N. Lapidus
Hi Mohamed Try: lapply (NameOfYourList, function (dat, NumCol) dat[,NumCol], c(12,13)) But there must be a shorter way to write this. Nael On Fri, May 23, 2008 at 3:37 PM, mohamed nur anisah < [EMAIL PROTECTED]> wrote: > Dear all, > > i have 2 lists of data with each of the list contain 14 c

Re: [R] Constructing dummy variables for months for a time series object

2008-04-25 Thread N. Lapidus
Oops.. the last line should have been : for (NumMonth in 1:12) assign(NameDummy[NumMonth], GenDummyVar (NumMonth)) On Fri, Apr 25, 2008 at 10:18 AM, N. Lapidus <[EMAIL PROTECTED]> wrote: > > GenDummyVar <- function (NumMonth) rep(c(rep(0, NumMonth-1), 1, rep(0, > 12-NumMonth)),

Re: [R] Constructing dummy variables for months for a time series object

2008-04-25 Thread N. Lapidus
> GenDummyVar <- function (NumMonth) rep(c(rep(0, NumMonth-1), 1, rep(0, 12-NumMonth)), 17) > NameDummy <- c("DJan", "DFeb", "DMar", "DApr", "DMay", "DJun", "DJul", "DAug", "DSep", "DOct", "DNov", "DDec") > for (NumMonth in 1:12) assign(NameDummy, GenDummyVar (NumMonth)) > DJan [1] 0 0 0 0 0 0 0

Re: [R] locate the rows in a dataframe with some criteria

2008-03-07 Thread N. Lapidus
Hi Zhihua, M <- data.frame (x=c(10, 13, 8, 11), y=c('A', 'B', 'A', 'A')) which (M$x >= 10 & M$y == 'A') # [1] 1 4 Hope it helps, Nael 2008/3/7 N. Lapidus <[EMAIL PROTECTED]>: > Hi Zhihua, > > M <- data.frame (x=c(10

Re: [R] How can I join two lists?

2008-01-25 Thread N. Lapidus
Try c(q1,q2) Nael On Jan 25, 2008 4:45 PM, <[EMAIL PROTECTED]> wrote: > How can I join two lists? I have q1 and q2 and I want to merge them. I > have tried to use the comand merge, but not work. Any solutions? Thanks! > > > q1 > $Input1 > 7.84615384615385 > 0.5 > > $Input2 > 8.92307

Re: [R] array addition

2007-12-19 Thread N. Lapidus
Hi Robin, Before someone gives a better solution, you can try this : x1<-array(1:10,c(2,5)) x2<-array(1:9,c(3,3)) ArrayAdd<-function(array1,array2){ x<-array(0,c(max(nrow(array1),nrow(array2)),max(ncol(array1),ncol(array2 x[1:nrow(array1),1:ncol(array1)]<-x[1:nrow(array1),1:ncol(array1

Re: [R] Function for AUC?

2007-12-17 Thread N. Lapidus
Hi Armin, Do you know the rocr package ? This is very easy to draw ROC curves and to calculate AUC with it. http://rocr.bioinf.mpi-sb.mpg.de/ Hope this will help. Nael On Dec 17, 2007 2:58 AM, Stephen Weigand <[EMAIL PROTECTED]> wrote: > RSiteSearch("AUC") > > would lead you to > > http://finzi.