[R] For loop

2008-06-27 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 t

Re: [R] request: To access a particular list

2008-06-27 Thread jim holtman
what does 'str(vr)' show as the structure of the list you are creating? On Fri, Jun 27, 2008 at 3:19 AM, Muhammad Azam <[EMAIL PROTECTED]> wrote: > Dear R community > I have a problem to access particular list. I have a code given below where > there is recursive process. It is not possible to ru

Re: [R] change values in data frames

2008-06-27 Thread jim holtman
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 starting sequence > offsets <- head(cumsum(c(1, z$lengths)), -1) > # now deter

Re: [R] median of grouped data

2008-06-27 Thread jim holtman
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.224790 7.012470 $H

Re: [R] cumulative sum of within levels of a dataframe

2008-06-27 Thread Levi Waldron
Perfect, thanks all. Unlist and ave will both be very handy functions to know. -levi -- Levi Waldron, PhD Treated Wood Research Group Faculty of Forestry, University of Toronto 33 Willcocks Street, Toronto ON, M5S 3B3 CANADA Tel 647-866-5384 Fax 416-978-3834 [[alternative HTML versio

[R] Fwd: converting numbers to characters

2008-06-27 Thread milton ruser
Hi Lana, I think it could help you (following the answer by Paulo Justiniano on last week) x<-1e+05 x as.character(x) options(scipen=1) x<-1e+05 x as.character(x) ?options Kind regards, miltinho brazil On 6/27/08, Lana Schaffer <[EMAIL PROTECTED]> wrote: > > Hi, > I need to convert numbers

Re: [R] converting numbers to characters

2008-06-27 Thread milton ruser
Hi Lana, I think it could help you (following the answer by Paulo Justiniano on last week) x<-1e+05 x as.character(x) options(scipen=1) x<-1e+05 x as.character(x) ?options Kind regards, miltinho brazil On 6/27/08, Lana Schaffer <[EMAIL PROTECTED]> wrote: > > Hi, > I need to convert numbers t

[R] converting numbers to characters

2008-06-27 Thread Lana Schaffer
Hi, I need to convert numbers to characters in order to index an array when I encountered the number 10 which turned into "1e+05". Does anyone know how to get around this problem? Lana Schaffer Biostatistics/Informatics The Scripps Research Institute DNA Array Core Facility La Jolla, CA 92037

[R] converting numbers to characters

2008-06-27 Thread Lana Schaffer
Hi, I need to convert numbers to characters in order to index an array when I encountered the number 10 which turned into "1e+05". Does anyone know how to get around this problem? Lana Schaffer Biostatistics/Informatics The Scripps Research Institute DNA Array Core Facility La Jolla, CA 92037

[R] median of grouped data

2008-06-27 Thread Bricklemyer, Ross S
I am having difficulty calculating the median of grouped data. I have 8 to 10 repeated measures per sample and I have successfully used the following code to calculate the average for each sample. libs.norm.preds.median[,7:9]<-apply(libs.norm.preds.median[,7:9],MARGIN=2, FUN=ave,libs.norm.pred

[R] use of quotation marks

2008-06-27 Thread Rodrigo Briceño
Dear R Users. I just discovered today a problem in the use of quotation marks when I'm doing some programs in R. I'm using windows vista environment. The programs that I wrote in the University, made in Windows XP machines run perfectly, but when I run those in my laptop with VISTA, there are many

Re: [R] cumulative sum of within levels of a dataframe

2008-06-27 Thread Gabor Grothendieck
Try this: df$wildo <- ave(df$x, df$fac, FUN = cumsum) On Fri, Jun 27, 2008 at 4:52 PM, Levi Waldron <[EMAIL PROTECTED]> wrote: > This one should be easy but it's giving me a hard time mostly because tapply > puts the results in a list. I want to calculate the cumulative sum of a > variable in a

Re: [R] cumulative sum of within levels of a dataframe

2008-06-27 Thread Gavin Simpson
On Fri, 2008-06-27 at 16:52 -0400, Levi Waldron wrote: > This one should be easy but it's giving me a hard time mostly because tapply > puts the results in a list. I want to calculate the cumulative sum of a > variable in a dataframe, but with the accumulation only within each level of > a factor.

Re: [R] cumulative sum of within levels of a dataframe

2008-06-27 Thread Erik Iverson
Just use ?unlist df$willdo <- unlist(tapply(df$x, df$fac, cumsum)) df$ideal <- df$willdo - df$x Levi Waldron wrote: This one should be easy but it's giving me a hard time mostly because tapply puts the results in a list. I want to calculate the cumulative sum of a variable in a dataframe, but

[R] cumulative sum of within levels of a dataframe

2008-06-27 Thread Levi Waldron
This one should be easy but it's giving me a hard time mostly because tapply puts the results in a list. I want to calculate the cumulative sum of a variable in a dataframe, but with the accumulation only within each level of a factor. For a very simple example, take: > df <- data.frame(x=c(rep(

Re: [R] Need ideas on how to show spikes in my data and how to code it in R

2008-06-27 Thread Daniel Folkinshteyn
if you want the "frequency" scale rather than density scale, then leave hist as is (by default it uses the frequency scale), and rescale the density by multiplying it by the appropriate NOBS. on 06/27/2008 01:16 PM Thomas Frööjd said the following: Hi Thank you very much for taking time to an

Re: [R] plotting prcomp

2008-06-27 Thread Dan Bolser
2008/6/27 Prof Brian Ripley <[EMAIL PROTECTED]>: > On Fri, 27 Jun 2008, Prof Brian Ripley wrote: > >> On Fri, 27 Jun 2008, Dan Bolser wrote: >> >>> Please consider the following PCA example; >>> >>> my.df <- >>> data.frame(A=(x <- rnorm(100,mean=100, sd=10)), >>>B=(y <- x + rnorm(100,m

Re: [R] Alternative of Cairo

2008-06-27 Thread Michael Lawrence
On Fri, Jun 27, 2008 at 12:05 AM, [EMAIL PROTECTED] < [EMAIL PROTECTED]> wrote: > Hi All, > > I am a new member to R programming. > > Am generating some visuals by using Cairo library. But Cairo is not > compatible with all compilers May I ask which compiler you are using? There are other vector

[R] adtest for weibull distribution

2008-06-27 Thread René Pineda
HiI need help about anderson-darlin test for a weibull distribution in R.Thanks. René _ [[elided Hotmail spam]] e ready. [[alternative HTML version deleted]] __ R-help@r-projec

Re: [R] Recoding

2008-06-27 Thread Marc Schwartz
on 06/27/2008 01:41 PM Agustin Lobo wrote: Hi! Given a vector (or a factor within a df),i.e. v1 <- c(1,1,1,2,3,4,1,10,3) and a dictionary cbind(c(1,2,3),c(1001,1002,1003)) is there a function (on the same line than recode() in car) to get v2 as c(1001,1001,1001,1002,1003,4,1001,10,1003) ? I'm

Re: [R] Recoding

2008-06-27 Thread Daniel Folkinshteyn
if there's nothing specific for it, you could probably do it with merge? on 06/27/2008 02:41 PM Agustin Lobo said the following: Hi! Given a vector (or a factor within a df),i.e. v1 <- c(1,1,1,2,3,4,1,10,3) and a dictionary cbind(c(1,2,3),c(1001,1002,1003)) is there a function (on the same lin

Re: [R] Recoding

2008-06-27 Thread Jorge Ivan Velez
Dear Agustin, Perhaps v1 <- c(1,1,1,2,3,4,1,10,3) dput(as.numeric(ifelse(v1%in%c(1,2,3),paste(100,v1,sep=""),v1))) HTH, Jorge On Fri, Jun 27, 2008 at 2:41 PM, Agustin Lobo <[EMAIL PROTECTED]> wrote: > Hi! > > Given a vector (or a factor within a df),i.e. v1 <- c(1,1,1,2,3,4,1,10,3) > and a d

Re: [R] Problems exporting graphs

2008-06-27 Thread stephen sefick
I'll surely look into it. Stephen On Fri, Jun 27, 2008 at 1:43 PM, hippie dream <[EMAIL PROTECTED]> wrote: > > This is solved for me. Upgrading R to 2.7.1 sorted out the issue somehow. > Maybe there is a problem with Ubuntu 8.04 and R 2.6.2. Or maybe some other > package was installed that fixed

[R] Recoding

2008-06-27 Thread Agustin Lobo
Hi! Given a vector (or a factor within a df),i.e. v1 <- c(1,1,1,2,3,4,1,10,3) and a dictionary cbind(c(1,2,3),c(1001,1002,1003)) is there a function (on the same line than recode() in car) to get v2 as c(1001,1001,1001,1002,1003,4,1001,10,1003) ? I'm using myself a function based on match() sin

Re: [R] question on affylmGUI / oneChannelGUI

2008-06-27 Thread Martin Morgan
"Bogdan Tanasa" <[EMAIL PROTECTED]> writes: > Hi everyone. Actually, you don't want to say hi to _everyone_; you sent your mail to three different news groups, but should have sent it to the single news group that will be most helpful to you. You should have sent your email to the Bioconductor ma

Re: [R] getting multiple argument names

2008-06-27 Thread Gabor Grothendieck
Try: RSiteSearch("names of objects passed as ...") On Fri, Jun 27, 2008 at 11:48 AM, whizvast <[EMAIL PROTECTED]> wrote: > > hi, all- > > i wrote a function that accept multiple arguments, but don't know how to > assign names automatically. run the following code: > > foo <- function (...) { >

Re: [R] Yule Kendall resistant measure of skewness

2008-06-27 Thread tolga . i . uzuner
Dear Jorge, Many thanks, this is great. Tolga "Jorge Ivan Velez" <[EMAIL PROTECTED]> 27/06/2008 18:11 To [EMAIL PROTECTED] cc r-help@r-project.org Subject Re: [R] Yule Kendall resistant measure of skewness Dear Tolga, See equation 2.6 here. Also try this: # Yule Kendall resistant mea

Re: [R] getting multiple argument names

2008-06-27 Thread Bert Gunter
You evidence a good deal of confusion. V&R's S PROGRAMMING, in particular Chapter 3 (especially section 3.5 on Computing on the Language) would be helpful to you. See also their example on p. 46. However in brief: foo <- function (...) { x <-3 list(...) } returns the evaluated ... arguments as

[R] include S4 class and methods in a package

2008-06-27 Thread baptiste Auguié
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 few methods (plot, summary, as.data.frame). It's al

Re: [R] Problems exporting graphs

2008-06-27 Thread hippie dream
This is solved for me. Upgrading R to 2.7.1 sorted out the issue somehow. Maybe there is a problem with Ubuntu 8.04 and R 2.6.2. Or maybe some other package was installed that fixed it. Whatever the case. Thanks! Prof Brian Ripley wrote: > > On Fri, 27 Jun 2008, stephen sefick wrote: > >> pdf(

Re: [R] R help

2008-06-27 Thread Martin Morgan
Martin Morgan wrote: Hi Rajasekaramya sapply(geneset[1:5431], "[[", "V1") or Bioconductor::subListExtract(geneset[1:5431], "V1") oops, I meant using the 'Biobase' package from Bioconductor, e.g., > library(Biobase) > subListExtract(geneset[1:5431], "V1") Sorry for the confusion, Martin

Re: [R] Error reading a table

2008-06-27 Thread jim holtman
Try read.table(,fill=TRUE) On Fri, Jun 27, 2008 at 12:00 PM, <[EMAIL PROTECTED]> wrote: > Hi, > > I get the following error when I try to read in a CSV file: > >> Path<-read.table('MetaCycSample2.csv',sep=',', header=FALSE) > Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.

Re: [R] Need ideas on how to show spikes in my data and how to code it in R

2008-06-27 Thread Thomas Frööjd
Hi Thank you very much for taking time to answer. The solution of using hist(data) for the main dataset and adding lines(density(refdata)) for the reference data seem to work great. I forgot to mention one thing however, I need to have frequency on the y azis instead of density as now. I know t

Re: [R] Yule Kendall resistant measure of skewness

2008-06-27 Thread Jorge Ivan Velez
Dear Tolga, See equation 2.6 here. Also try this: # Yule Kendall resistant measure of skewness YK=function(x){ qs=quantile(x,probs=c(0.25,0.5,.75)) res=(qs[1]-2*qs[2]+qs[3])/(qs[2]-qs[1]) names(res)=NULL res } #

[R] SAM FDR

2008-06-27 Thread Davendra Sohal
Hello all, I am doing SAM and the median of positive genes in the permutated sets is = false positives, and the "parent set" gives true positives. FDR = FP/TP * 100. My FDR comes to greater than 100. Is that possible? Please help! Thanks, -D. [[alternative HTML version deleted]] ___

Re: [R] plotting prcomp

2008-06-27 Thread Prof Brian Ripley
On Fri, 27 Jun 2008, Prof Brian Ripley wrote: On Fri, 27 Jun 2008, Dan Bolser wrote: Please consider the following PCA example; my.df <- data.frame(A=(x <- rnorm(100,mean=100, sd=10)), B=(y <- x + rnorm(100,mean=10, sd=10))) plot(my.df) my.pc <- prcomp(my.df, center=TRUE, scal

[R] Error reading a table

2008-06-27 Thread naw3
Hi, I get the following error when I try to read in a CSV file: > Path<-read.table('MetaCycSample2.csv',sep=',', header=FALSE) Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 17 did not have 5 elements Some of the rows have more columns than others. Also whe

Re: [R] plotting prcomp

2008-06-27 Thread Prof Brian Ripley
On Fri, 27 Jun 2008, Dan Bolser wrote: Please consider the following PCA example; my.df <- data.frame(A=(x <- rnorm(100,mean=100, sd=10)), B=(y <- x + rnorm(100,mean=10, sd=10))) plot(my.df) my.pc <- prcomp(my.df, center=TRUE, scale=TRUE) biplot(my.pc) my.x <- (my.pc$x)[,1] my

Re: [R] Problems exporting graphs

2008-06-27 Thread Prof Brian Ripley
On Fri, 27 Jun 2008, stephen sefick wrote: pdf( "yourfile.pdf", height=22, width=17) #yourcode dev.off() then use the gimp (free) to transform it to .png or whatever else (pdf makes good graph) So do R's graphics devices If you do want to convert PDF to PNG there are much better ways th

[R] getting multiple argument names

2008-06-27 Thread whizvast
hi, all- i wrote a function that accept multiple arguments, but don't know how to assign names automatically. run the following code: foo <- function (...) { x = list(...) names(x) <- deparse(substitute(...)) x } a = 1; b = 2; c = 3 y <- foo( a, b, c) names(y) as you can see, only the fir

Re: [R] NA value

2008-06-27 Thread Alfredo Alessandrini
>for (i in files_rwl) { > thisfile <- get(i) > thisfile[is.na(thisfile)] <- 0 > assign(i, thisfile) > } > > It's likely that you could condense it, but using the long form makes it > clear what's happening. ..it's work Thanks... Alfredo ___

Re: [R] R help

2008-06-27 Thread Martin Morgan
Hi Rajasekaramya sapply(geneset[1:5431], "[[", "V1") or Bioconductor::subListExtract(geneset[1:5431], "V1") Martin Rajasekaramya wrote: Hi, I have a problem in assessing the list element. i have list called geneset it contains the following elements > geneset [[1]]

Re: [R] NA value

2008-06-27 Thread Jorge Ivan Velez
Dear K. Elo, You're right! cimfasy_rwl=read.table(textConnection("1991 0.92 0.72 0.50 1.29 0.54 1.22 1992 2.15 1.28 1.23 2.26 1.22 3.17 1993 1.50 0.87 1.68 1.97 0.83 2.55 1994 0.69 0.00 0.76 1.89 0.60 0.87

[R] plotting prcomp

2008-06-27 Thread Dan Bolser
Please consider the following PCA example; my.df <- data.frame(A=(x <- rnorm(100,mean=100, sd=10)), B=(y <- x + rnorm(100,mean=10, sd=10))) plot(my.df) my.pc <- prcomp(my.df, center=TRUE, scale=TRUE) biplot(my.pc) my.x <- (my.pc$x)[,1] my.y <- (my.pc$x)[,2] plot(my.x, my.y, t

Re: [R] NA value

2008-06-27 Thread Sarah Goslee
Like this: for (i in files_rwl) { thisfile <- get(i) thisfile[is.na(thisfile)] <- 0 assign(i, thisfile) } It's likely that you could condense it, but using the long form makes it clear what's happening. Sarah -- Sarah Goslee http://www.functionaldiversity.or

Re: [R] Problems exporting graphs

2008-06-27 Thread stephen sefick
pdf( "yourfile.pdf", height=22, width=17) #yourcode dev.off() then use the gimp (free) to transform it to .png or whatever else (pdf makes good graph) On Thu, Jun 26, 2008 at 8:59 PM, Daniel Folkinshteyn <[EMAIL PROTECTED]> wrote: > not sure why it doesn't work, but try the following: > first, p

Re: [R] R help

2008-06-27 Thread Daniel Folkinshteyn
oh, unlist - very nice function, thanks :) on 06/27/2008 11:23 AM Jorge Ivan Velez said the following: Hi Ramya, Try something like this: as.character(unlist(lapply(geneset,function(x) x[1]))) HTH, Jorge On Fri, Jun 27, 2008 at 10:33 AM, Rajasekaramya <[EMAIL PROTECTED]> wrote: Hi, I h

Re: [R] R help

2008-06-27 Thread Daniel Folkinshteyn
try this: firstgenes = lapply(geneset, function(x){return(x[1,1])}) firstgenes = do.call(rbind(firstgenes)) on 06/27/2008 10:33 AM Rajasekaramya said the following: Hi, I have a problem in assessing the list element. i have list called geneset it contains the following elements

Re: [R] binomial distribution

2008-06-27 Thread Peter Dalgaard
Peng Jiang wrote: > Hi, xiechao > i don't think that is a R specific problem. you mean u got two random > variables X,Y and both > of them binomial distributed and you want to find the distribution of > a new variable Z = X/Y. > That is a basic transformation problem. u can start with introducing

Re: [R] Superimposing Multiple Vectors Plots in One Figure

2008-06-27 Thread Gundala Viswanath
Dear Petr, Thanks so much for your detailed guidance. I'll have a look at your suggestions. - Gundala Viswanath Jakarta - Indonesia On Fri, Jun 27, 2008 at 7:09 PM, Petr PIKAL <[EMAIL PROTECTED]> wrote: > Hi > > you mix base and lattice graphics. > > [EMAIL PROTECTED] napsal dne 27.06.2008 08:2

Re: [R] NA value

2008-06-27 Thread K. Elo
Hi, cimfasy_rwl[ is.na(cimfasy_rwl) ] <-0 Or did I understood Your right? HTH, Kimmo Alfredo Alessandrini wrote: I'm trying to replace NA with 0 value... I've write a loop, but don't work... Where's the problem? cimfasy_rwl 1991 0.92 0.72 0.50 1.29 0.54 1.22 199

Re: [R] NA value

2008-06-27 Thread Alfredo Alessandrini
> Don't use a loop for this. Do this. I need to use a loop... I've many data. Alfredo __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and p

Re: [R] matching problem

2008-06-27 Thread Gabor Grothendieck
Here is a solution using strapply from the gsubfn package: library(gsubfn) strapply(myexstrings, "(\\w+).*", backref = -1, simplify = c) It matches the first string of word characters following by anything else and then returns the first backreference in each match, i.e. the portion within parent

Re: [R] R help

2008-06-27 Thread Jorge Ivan Velez
Hi Ramya, Try something like this: as.character(unlist(lapply(geneset,function(x) x[1]))) HTH, Jorge On Fri, Jun 27, 2008 at 10:33 AM, Rajasekaramya <[EMAIL PROTECTED]> wrote: > > Hi, > > I have a problem in assessing the list element. > > i have list called geneset it contains the foll

[R] R help

2008-06-27 Thread Rajasekaramya
Hi, I have a problem in assessing the list element. i have list called geneset it contains the following elements > geneset [[1]] V1 V2 V3 ...V200 Genenamegene1 gene2gene200 [[2]] V1V2 V3 V4...V[240] Gen

Re: [R] NA value

2008-06-27 Thread Doran, Harold
Don't use a loop for this. Do this. X <- matrix(c(NA, 2, NA, 4),ncol=2) # Sample matrix X[is.na(X)] <- 0 # Do this instead > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Alfredo > Alessandrini > Sent: Friday, June 27, 2008 10:37 AM > To: r-help@

[R] permutation distribution for Friedman test

2008-06-27 Thread Michael Andric
Hi I am looking to generate permutations for data tested using the friedman.test. Just read a paper by Joachim Rohmel, "The permutation distribution of the Friedman test" (Computational Statistics & Data Analysis 1997, 26: 83-99). He offers APL code for carrying out these procedures; wondering if

Re: [R] xyplot and separate abline per plot

2008-06-27 Thread Sébastien Bihorel
Hi Karin, Try this xyplot(numbers~sqrt(breaks)|moltype+disttype, groups = type, data = alldata, panel = function(x, y, ...){ panel.abline(h = 0, col.line = 1) panel.xyplot(x, y, ..., pch = 1, col.symbol = 1)}) Look at panel.abline in the lattice help for more details. Here, "h = 0" will plot

[R] NA value

2008-06-27 Thread Alfredo Alessandrini
I'm trying to replace NA with 0 value... I've write a loop, but don't work... Where's the problem? > cimfasy_rwl 1991 0.92 0.72 0.50 1.29 0.54 1.22 1992 2.15 1.28 1.23 2.26 1.22 3.17 1993 1.50 0.87 1.68 1.97 0.83 2.55 1994

Re: [R] matching problem

2008-06-27 Thread Tom.O
Thanks guys, all of you. You have just made this weekend a much more happier weekend. Regards Tom Hans-Jörg Bibiko wrote: > > > On 27 Jun 2008, at 13:56, Tom.O wrote: > >> >> Well I have tried that and it's unfortuanally not the solution. >> This return all the characters in the string, but

Re: [R] binomial distribution

2008-06-27 Thread Peng Jiang
Hi, xiechao i don't think that is a R specific problem. you mean u got two random variables X,Y and both of them binomial distributed and you want to find the distribution of a new variable Z = X/Y. That is a basic transformation problem. u can start with introducing a new r.v. namely W, by

Re: [R] Switching entries in vector in by groups of two

2008-06-27 Thread Peter Dalgaard
Henrique Dallazuanna wrote: > Try this: > > ave(X, rep(1:(length(X)/2), each = 2), FUN=rev) > > Also, ix <- 2*rep(1:(length(X)/2-1), each = 2) + 2:1 X[ix] or ix <- seq_along(X) + c(1,-1) X[ix] > On Fri, Jun 27, 2008 at 11:11 AM, David Afshartous < > [EMAIL PROTECTED]> wrote: > > >> All, >>

Re: [R] [PS] Switching entries in vector in by groups of two

2008-06-27 Thread Ben Fairbank
Perhaps xnew <- x[1:length(x)+c(1,-1)] will do it. Ben Fairbank -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Afshartous Sent: Friday, June 27, 2008 9:11 AM To: r-help@r-project.org Subject: [PS] [R] Switching entries in vector in by groups o

Re: [R] Switching entries in vector in by groups of two

2008-06-27 Thread David Afshartous
Thanks Henrique, Marc, and Gabor! On 6/27/08 10:17 AM, "Henrique Dallazuanna" <[EMAIL PROTECTED]> wrote: > Try this: > > ave(X, rep(1:(length(X)/2), each = 2), FUN=rev) > > On Fri, Jun 27, 2008 at 11:11 AM, David Afshartous <[EMAIL PROTECTED]> > wrote: >> >> All, >> >> I have a long vector

Re: [R] Switching entries in vector in by groups of two

2008-06-27 Thread Marc Schwartz
on 06/27/2008 09:17 AM Marc Schwartz wrote: on 06/27/2008 09:11 AM David Afshartous wrote: All, I have a long vector that contains an even number of entries. I'd like to switch the 1st and 2nd entry, the 3rd and 4th, and so on, without writing a loop. This code works: X = c(8, 10, 6, 3, 20,

Re: [R] Similarity matching with probabilities

2008-06-27 Thread Hans-Joerg Bibiko
On 27 Jun 2008, at 14:30, francogrex wrote: Hello, It's just a strange coincidence that someone posted just very recently a question about matching. I know there are several match function in the base package (such as match, pmatch, charmatch, and the gsub etc) but I can't seem to use

Re: [R] Switching entries in vector in by groups of two

2008-06-27 Thread Henrique Dallazuanna
Try this: ave(X, rep(1:(length(X)/2), each = 2), FUN=rev) On Fri, Jun 27, 2008 at 11:11 AM, David Afshartous < [EMAIL PROTECTED]> wrote: > > All, > > I have a long vector that contains an even number of entries. I'd like to > switch the 1st and 2nd entry, the 3rd and 4th, and so on, without writ

Re: [R] Switching entries in vector in by groups of two

2008-06-27 Thread Marc Schwartz
on 06/27/2008 09:11 AM David Afshartous wrote: All, I have a long vector that contains an even number of entries. I'd like to switch the 1st and 2nd entry, the 3rd and 4th, and so on, without writing a loop. This code works: X = c(8, 10, 6, 3, 20, 1) index = c(2,1,4,3,6,5) X[index] But for a

Re: [R] Switching entries in vector in by groups of two

2008-06-27 Thread Gabor Grothendieck
You can do it without and index like this: c(matrix(X, 2)[2:1,]) or if you need the index for some purpose apart from this: c(matrix(seq_along(X), 2)[2:1,]) On Fri, Jun 27, 2008 at 10:11 AM, David Afshartous <[EMAIL PROTECTED]> wrote: > > All, > > I have a long vector that contains an even numb

Re: [R] matching problem

2008-06-27 Thread Hans-Joerg Bibiko
On 27 Jun 2008, at 13:56, Tom.O wrote: Well I have tried that and it's unfortuanally not the solution. This return all the characters in the string, but I dont want the characters after the ending non-character symbol. Only the starting characters ore of interest. gsub("\\W*","", myexst

[R] Switching entries in vector in by groups of two

2008-06-27 Thread David Afshartous
All, I have a long vector that contains an even number of entries. I'd like to switch the 1st and 2nd entry, the 3rd and 4th, and so on, without writing a loop. This code works: X = c(8, 10, 6, 3, 20, 1) index = c(2,1,4,3,6,5) X[index] But for a long list is there a way to generate the index?

[R] Optimisation of xyplot style

2008-06-27 Thread Sébastien
Dear R-users, The following provides a basis to illustrate some questions I have about xyplot() customization. x <- rep(1:2, times = 6) y <- numeric() for (i in 1:3) { y <- c(y, 1:4*10^(i-1)) } g <- rep(1:6, each = 2) ax <- rep(1:3, each = 4) tmp <- data.frame(x,y,g) xyplot(y ~ x | g, a

Re: [R] matching problem

2008-06-27 Thread Daniel Folkinshteyn
this should do what you want: > myexstrings = c("*AAA.AA","BBB BB","*.CCC.","**dd- d") > a = gsub("^\\W*","", myexstrings,perl=T) > b = gsub("\\W.*", "", a, perl=T) > b [1] "AAA" "BBB" "CCC" "dd" first one, removes any non-word characters from the beginning (as you already figured out) second o

Re: [R] matching problem

2008-06-27 Thread Tom.O
Well I have tried that and it's unfortuanally not the solution. This return all the characters in the string, but I dont want the characters after the ending non-character symbol. Only the starting characters ore of interest. > gsub("\\W*","", myexstrings,perl=T) [1] "A" "B" "CCC" "ddd"

[R] Similarity matching with probabilities

2008-06-27 Thread francogrex
Hello, It's just a strange coincidence that someone posted just very recently a question about matching. I know there are several match function in the base package (such as match, pmatch, charmatch, and the gsub etc) but I can't seem to use them wisely to be able to get what I need. suppose I ha

[R] xyplot and separate abline per plot

2008-06-27 Thread Karin Lagesen
Hello list! I have a set of data like this: > alldata[1:5,] breaks numbers disttype moltypetype 1 0.0006598 Gapped Distances 5S Between species 2 0.407 0 Gapped Distances 5S Between species 3 0.8135228 Gapped Distances 5S Between

Re: [R] assigning colors to barplot

2008-06-27 Thread Jim Lemon
On Fri, 2008-06-27 at 15:17 +0530, Archana Vagish wrote: > Hi, > I want to plot a series of numbers ( which lie in the range 1-20, there are > many such numbers) as a barplot. However instead of representing the values > in terms of height, i want to assign one unique color to each number. How > c

[R] binomial distribution

2008-06-27 Thread Xie Chao
Hi all, I am a biological student and need your help in statistics. I have two sets of binomial distributed numbers: {a1, a2, ..., an} and {b1, b2, ..., bn}. How can I get the distribution of the ratios of the two sets of numbers {a1/b1, a2/b2, ..., an/bn}? Is there a formula to transform the di

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

2008-06-27 Thread Jim Lemon
David Afshartous <[EMAIL PROTECTED]> wrote: > > All, > > > > I have data across 5 time points that I am graphing via xyplot, along with > > error bars. For one of the variables I have missing data for two of the > > time points. The code below is okay but I can't seem to get the lines to > >

Re: [R] matching problem

2008-06-27 Thread Hans-Joerg Bibiko
On 27 Jun 2008, at 12:23, Tom.O wrote: Hi R gurus I have a matching problem that I cant solve. I have tried multiple solutions and searched varius help-sites but I cant get it to work. This is the problem myexstrings = c("*AAA.AA","BBB BB","*.CCC.","**dd- d") what I want do do is to remov

Re: [R] finding the suitable distribution

2008-06-27 Thread Philip Twumasi-Ankrah
I think a first step in getting some help is to summarize your data for easy evaluation. Model fitting (?) will require some information providing some information like; 1. What is the response variable here 2. What are the covariates (cofactors and possibly the levels of factors) Then the dat

Re: [R] Sweave: controlling pointsize (pdf)

2008-06-27 Thread Lauri Nikkinen
Yes, I think so too. I already tried with options(SweaveHooks=list(fig=function() pdf(pointsize=10))) but as you said it tries to open pdf device and Sweaving fails... Best Lauri 2008/6/27, Duncan Murdoch <[EMAIL PROTECTED]>: > On 27/06/2008 7:12 AM, Lauri Nikkinen wrote: > > pdf.options() seem

Re: [R] Sweave: controlling pointsize (pdf)

2008-06-27 Thread Duncan Murdoch
On 27/06/2008 7:12 AM, Lauri Nikkinen wrote: pdf.options() seems to be a new function (from 2.7.0), so I quess I'll have to upgrade or write my own hook function for Sweave. Thanks. I'd recommend upgrading. I think it would be difficult to do this with a hook function: you'd basically need t

[R] Yule Kendall resistant measure of skewness

2008-06-27 Thread tolga . i . uzuner
Dear R Users, Is anyone aware of a package which calculates the Yule Kendall resistant (to errors,outliers) measure of skewness ? An easy calculation to perform, but was just wondering if a package exists (as the contents of that package would probably include other cool things I would also be

Re: [R] Sweave: controlling pointsize (pdf)

2008-06-27 Thread Lauri Nikkinen
pdf.options() seems to be a new function (from 2.7.0), so I quess I'll have to upgrade or write my own hook function for Sweave. Thanks. Best Lauri 2008/6/27, Duncan Murdoch <[EMAIL PROTECTED]>: > On 27/06/2008 6:23 AM, Lauri Nikkinen wrote: > > I'm working with Windows XP and R 2.6.0 > > > > > R

Re: [R] igraph (was Compilation error during package installation)

2008-06-27 Thread Gabor Csardi
Wanding, I'm the maintainer of igraph, but missed your previous email. Yes, currently the released version of igraph fails to compile with gcc 4.3.x. I made the required modifications to fix this, but these are still in the igraph development tree, as there has been no release since that. Yo

Re: [R] removing blanks from a string

2008-06-27 Thread Prof Brian Ripley
On Fri, 27 Jun 2008, john seers (IFR) wrote: Hello Yes, I am sure you are right. I guessed the intended question was not so specific. I have always thought of spaces and blanks as the same thing. And use "white space" for a more general catch all description for tabs etc. Is "white space" a

Re: [R] Sweave: controlling pointsize (pdf)

2008-06-27 Thread Duncan Murdoch
On 27/06/2008 6:23 AM, Lauri Nikkinen wrote: I'm working with Windows XP and R 2.6.0 R.Version() $platform [1] "i386-pc-mingw32" -Lauri 2008/6/27, Lauri Nikkinen <[EMAIL PROTECTED]>: Hello, Is there a way to control pointsize of pdf:s produced by Sweave? I would like to have the same points

Re: [R] removing blanks from a string

2008-06-27 Thread john seers (IFR)
Hello Yes, I am sure you are right. I guessed the intended question was not so specific. I have always thought of spaces and blanks as the same thing. And use "white space" for a more general catch all description for tabs etc. Is "white space" and "spaces" the same thing? Regards JS

[R] Sweave: controlling pointsize (pdf)

2008-06-27 Thread Lauri Nikkinen
Hello, Is there a way to control pointsize of pdf:s produced by Sweave? I would like to have the same pointsize from (not a working example) pdf(file="C:/temp/example.pdf", width=7, height=7, bg="white", pointsize=10) plot(1:10) etc.. dev.off() as \documentclass[a4paper]{article} \usepackage[la

Re: [R] igraph (was Compilation error during package installation)

2008-06-27 Thread Prof Brian Ripley
Please discuss this with the package maintainer (see the posting guide). He will need lots of details you have omitted, including the precise OS and the C++ compiler used. BTW, this illustrates a common problem with packages using C++, which people often test only under one compiler, and unti

[R] matching problem

2008-06-27 Thread Tom.O
Hi R gurus I have a matching problem that I cant solve. I have tried multiple solutions and searched varius help-sites but I cant get it to work. This is the problem myexstrings = c("*AAA.AA","BBB BB","*.CCC.","**dd- d") what I want do do is to remove any non-characters in the beginning and ever

[R] Odp: Superimposing Multiple Vectors Plots in One Figure

2008-06-27 Thread Petr PIKAL
Hi you mix base and lattice graphics. [EMAIL PROTECTED] napsal dne 27.06.2008 08:25:55: > Hi, > > I have 3 vectors which I want to plot as in one plot. > I was wondering why this code of mine only show the last vector: > > __BEGIN__ > library(lattice) > > out_fname <- paste("MyPlot.png",sep="

Re: [R] Sweave: controlling pointsize (pdf)

2008-06-27 Thread Lauri Nikkinen
I'm working with Windows XP and R 2.6.0 > R.Version() $platform [1] "i386-pc-mingw32" -Lauri 2008/6/27, Lauri Nikkinen <[EMAIL PROTECTED]>: > Hello, > > Is there a way to control pointsize of pdf:s produced by Sweave? I > would like to have the same pointsize from (not a working example) > > pdf(

Re: [R] bug in nls?

2008-06-27 Thread Prof Brian Ripley
As has already been pointed out, the syntax of formulae in nls() is not the same as in linear models. So things which are valid for linear models are not necessarily valid for others. Since nls() is sparsely documented on the help page, you need to look at the references (and you can also lea

Re: [R] removing blanks from a string

2008-06-27 Thread Prof Brian Ripley
There are well-informed answers given as examples on the sub() help page. Hint 1: there is no need to globally substitute patterns anchored at the end: they can only match in one place. There is also no need to substitute "" for "". Hint 2: 'blank characters' and 'spaces' are not the same th

[R] Odp: using contour() with x,y,z data?

2008-06-27 Thread Petr PIKAL
Hi you probably want to look to interp from arima package Petr Pikal [EMAIL PROTECTED] 724008364, 581252140, 581252257 [EMAIL PROTECTED] napsal dne 26.06.2008 20:00:48: > Hello list, > > I'm new to R and I have a problem :-) Below is what my data file that looks > like. I tried to import a

[R] assigning colors to barplot

2008-06-27 Thread Archana Vagish
Hi, I want to plot a series of numbers ( which lie in the range 1-20, there are many such numbers) as a barplot. However instead of representing the values in terms of height, i want to assign one unique color to each number. How can this be done in R? Thanks, archana, II yr PhD student, Dept of C

Re: [R] bug in nls?

2008-06-27 Thread Petr PIKAL
Thank you Berwin. Ok, I take your point. I normally do nls modelling interactively but this time I was given a set of data so I tried to use an approach which I use quite often in lm or in plotting to pdf file. I obviously was not successful and there is nothing about it in documentation or at

Re: [R] removing blanks from a string

2008-06-27 Thread john seers (IFR)
There is also the "trim" command in the gdata package. Removes blanks from the front of the string as well which may not be what you want. Regards JS --- -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of jim holtman Sent: 27 June 2008 10:27 To: jul

  1   2   >