[R] For loop

2008-06-28 Thread Rajasekaramya
Hi, Could you please let me know to use a list in a for loop here geneset is a loop.I am trying to match the names of the list with 1st row of the output. result- list() for(i in 1:length(output) { result[[i]] - geneset(which(geneset %n% output[,1])) } Kindly help me out -- View

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)

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,

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,])) } Chunhao

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

[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(Tt). 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))

[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

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 (class

Re: [R] lme4 package

2008-06-28 Thread Ben Bolker
Takatsugu Kobayashi tkobayas at 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]: snip / 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

[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 like this tmp3

[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 of

[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

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

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 (i in

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, Postgraduate

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) # calculate offset of each

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

[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:

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,

[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) x - do.call(data.frame,

[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 the