Re: [R] data frame manipulation change elements meeting criteria

2010-05-26 Thread arnaud Gaboury
Thank you for the answer. Is there any way to combine if() and switch() in one line? In my case, something like : >if(trade$Trade.Status=="DEL")switch(.) I would like to avoid the loop . From: Joris Meys [mailto:jorism...@gmail.com] Sent: Wednesday, May 26, 2010 9:15 PM To: arnaud Gaboury

Re: [R] data frame manipulation change elements meeting criteria

2010-05-26 Thread Joris Meys
The loop is due to the switch statement, not the condition. Without condition it would become: for (i in 1:length(Y)){ new.vect[i]<-switch( EXPR = X[i], Sell="Buy", Buy="Sell", X[i]) } You can make an sapply construct too off course : new.vect <- sapply

[R] connectivity analysis for spatial information: from raster to graph

2010-05-26 Thread Carlos Alberto Arnillas Merino
hello... I am trying to develop an analysis similar to the proposed by Urban and Keitt (2001) for connectivity between patches in a landscape. To do that, my first problem is to convert the raster map, into a graph (with area of the patch as an attribute for the node, and the distance between patch

Re: [R] R and ATLAS

2010-05-26 Thread Jonathan Greenberg
Peter and Dirk: Thanks for the quick response -- I'm trying to get multiple CPU responses as Peter indicated should happen, but those R commands only illicit a single CPU response. When I check the libraries: ldd /usr/lib/R/bin/exec/R linux-vdso.so.1 => (0x7fffd05ff000) libR

Re: [R] sequential treatment of a vector for formula

2010-05-26 Thread Wu Gong
I don't know if my understanding of P is right. P ?= (the number of lives at the end of the interval)/(the number of lives at the beginning of the interval) ### Compute proportion of a cohort that survives through the interval ### The formula is P0=L1/LO ## Original data is a vector of death da

[R] Packages for ICD9 codes

2010-05-26 Thread Vishwanath Sindagi
Hello: I am working on getting some statistics related to clinical trials and stuff. I have to work with ICD9 codes. Is anyone aware of any R package that deals with ICD9 codes verification and manipulation. Thanks Vishwanath [[alternative HTML version deleted]] ___

[R] LMM and unequal variances

2010-05-26 Thread Rebecca Lawrence
Hi all, I am running a LMM and have two fixed factors: Trt (with 2 levels) and Microhabitat (with 3 levels), and a randon factor: Group nested within Trt. I have unequal variances between the two Trt levels. Does this matter in a LMM? Thanks for your time Rebecca [[alternative HTML vers

Re: [R] list of complex objects?

2010-05-26 Thread Peter Langfelder
Simply keep track of the next free component, or use nextComp = length(list_of_lists)+1, then use list_of_lists[[nextComp]] = fitJC1 Unlike with vectors, with lists you don't have to specify length and can add as many list components as you want later The length of the list will automatically

Re: [R] RWinEdt

2010-05-26 Thread Meyners, Michael
I assume you installed WinEdt 6. See https://stat.ethz.ch/pipermail/r-help/2010-May/238540.html and related messages. RWinEdt does not work (yet) with WinEdt 6, so you'll have to downgrade back to WinEdt 5.x (or use another editor for the time being). HTH, Michael -Original Message- From

Re: [R] wildcard operator

2010-05-26 Thread Erik Iverson
Eric Fail wrote: Hi Ruser As so usual I'm trying to replicate some SAS code. I wold like to know if there is a wildcard operators, as " : " in SAS, in R? When running: lm(y ~ x1 + x2 + x3 + x4 + x5 + x6 x9860, data=mydata) I would like to be able to get around it by just writing somet

Re: [R] wildcard operator

2010-05-26 Thread Jorge Ivan Velez
Hi Eric, Try lm(y ~ . , data = mydata) HTH, Jorge On Thu, May 27, 2010 at 12:58 AM, Eric Fail <> wrote: > Hi Ruser > > As so usual I'm trying to replicate some SAS code. I wold like to know if > there is a wildcard operators, as " : " in SAS, in R? > > When running: > > lm(y ~ x1 + x2 + x3 +

[R] wildcard operator

2010-05-26 Thread Eric Fail
Hi Ruser As so usual I'm trying to replicate some SAS code. I wold like to know if there is a wildcard operators, as " : " in SAS, in R? When running: lm(y ~ x1 + x2 + x3 + x4 + x5 + x6 x9860, data=mydata) I would like to be able to get around it by just writing something like this:

Re: [R] list of complex objects?

2010-05-26 Thread Nick Matzke
Thanks! I tried that before but for some reason didn't notice that it was working correctly. PS: How would I append another element to the list? This doesn't work: x = append(list_of_fits, fitJC1) # still works, from original list construction x[3] # but this doesn't work x[4] Cheers! Ni

Re: [R] sequential treatment of a vector for formula

2010-05-26 Thread David Winsemius
On May 26, 2010, at 10:50 PM, David Winsemius wrote: On May 26, 2010, at 6:24 PM, Frostygoat wrote: Please pardon the simplicity of this question of biological nature. I'm trying to calculate a statistic, px, the proportion of a cohort that survives through the interval x:x+1. I have the ve

Re: [R] How to combine data columns to a single column

2010-05-26 Thread Gabor Grothendieck
This is a time series so its best to represent it as such using a ts object. Below tt is the vector of data you asked for and tt.ts is the same vector converted into a ts series: Lines <- "Year 1903 1904 1905 1906 Jan 125.0 30.0 113.0 5.0 Feb 128.0 100.0 70.0 388.0 Mar 155.0 79.0 230.0 323.0 Apr

Re: [R] sequential treatment of a vector for formula

2010-05-26 Thread David Winsemius
On May 26, 2010, at 6:24 PM, Frostygoat wrote: Please pardon the simplicity of this question of biological nature. I'm trying to calculate a statistic, px, the proportion of a cohort that survives through the interval x:x+1. I have the vector from which the calc is to be made but I can't figur

[R] How to combine data columns to a single column

2010-05-26 Thread Zablone Owiti
Dear users, I have several columns of data (each column containing monthly data for a particular year from january - december) . I would wish to combine the columns to get a Single column of continuous data as shown in (b) below. I have read this data as table in R (a) Data example Year

[R] how to pick equivalent degrees of freedom in a R package wmtsa

2010-05-26 Thread Moohwan Kim
Dear R family I have a question as to how to get an answer I want to derive with the outcome from R-package, "wmtsa". My concern is that I want to decide equivalent degrees of freedom (EDOF) based on the following outcome. library(wmtsa) W <- wavMODWT(X, wavelet="s8") z1 <- wavEDOF(W) print(z1) #

Re: [R] persp(); help with 'tck' option

2010-05-26 Thread Sean Anderson
On Wed, May 26, 2010 at 8:53 PM, Kim Jung Hwa wrote: > I'm using 'tck' option to *reduce* the length of tick marks but it is not > working, can anyone please tell me where I'm going wrong... > > require(graphics) > require(grDevices) > x <- seq(-10, 10, length= 30) > y <- x > f <- function(x,y) { r

[R] sequential treatment of a vector for formula

2010-05-26 Thread Frostygoat
Please pardon the simplicity of this question of biological nature. I'm trying to calculate a statistic, px, the proportion of a cohort that survives through the interval x:x+1. I have the vector from which the calc is to be made but I can't figure out how to tell R to take the current value and d

Re: [R] list of complex objects?

2010-05-26 Thread Peter Langfelder
c concatenates all arguments. For example, c(c(0,1,2), c(3,4,5)) gives a vector 0,1,2,3,4,5. Another example: > c(list(a=c(0,1), b = c(2,3)), list(c = c(4,5), d = c(5,6))) $a [1] 0 1 $b [1] 2 3 $c [1] 4 5 $d [1] 5 6 So instead of a list of two lists, you get a single list with 4 components. I

Re: [R] list of complex objects?

2010-05-26 Thread Nick Matzke
Erik Iverson wrote: Nick Matzke wrote: Hi all, If I would like to make a list of complex objects -- in my case, phylogenetic trees, but it could be e.g. statistical results from something like lm, or whatever -- how can I put them into a list? When I try the obvious methods, e.g. cat, app

[R] persp(); help with 'tck' option

2010-05-26 Thread Kim Jung Hwa
Hi All, I'm using 'tck' option to *reduce* the length of tick marks but it is not working, can anyone please tell me where I'm going wrong... require(graphics) require(grDevices) x <- seq(-10, 10, length= 30) y <- x f <- function(x,y) { r <- sqrt(x^2+y^2); 10 * sin(r)/r } z <- outer(x, y, f) z[is

Re: [R] forest() in {metafor} :: edit labels

2010-05-26 Thread Kim Jung Hwa
try 'slab=' option... HTH, Kim On Wed, May 26, 2010 at 7:29 PM, Xin Ge wrote: > Hi Kim and Others, > > Can anyone please help me on how can I edit default labels ( "Study 1", > "Study 2",...) > > using forest() - same question as below. Which option I should try? > > It would be a great help. T

[R] forest() in {metafor} :: edit labels

2010-05-26 Thread Xin Ge
Hi Kim and Others, Can anyone please help me on how can I edit default labels ( "Study 1", "Study 2",...) using forest() - same question as below. Which option I should try? It would be a great help. Thanks in advance, On Sun, Dec 13, 2009 at 7:14 PM, Kim Jung Hwa wrote: > Hi All, > > I'm usin

Re: [R] Is possible a mini-plot into a big plot with Lattice?

2010-05-26 Thread Walmes Marques Zeviani
Mr. Murrell, It is exactly what I want. Thanks very much. Walmes. > Date: Thu, 27 May 2010 10:27:02 +1200 > From: p.murr...@auckland.ac.nz > To: walmeszevi...@hotmail.com > CC: r-help@r-project.org > Subject: Re: [R] Is possible a mini-plot into a big plot with Lattice? > > Hi > > On 27/05/20

Re: [R] R and ATLAS

2010-05-26 Thread Dirk Eddelbuettel
Jonathan, That would have been a good question for the r-sig-debian list ... On 26 May 2010 at 14:16, Jonathan Greenberg wrote: | Rhelpers: | | I recently installed the 64-bit version of R on my Debian system, and | afterwards was asked if it was compiled using ATLAS. Is there a way | to test

Re: [R] Is possible a mini-plot into a big plot with Lattice?

2010-05-26 Thread Paul Murrell
Hi On 27/05/2010 8:09 a.m., Walmes Marques Zeviani wrote: Hello, I want to do with Lattice functions (qqmath, histogram) a figure like this below. n<- 1000 x<- rnorm(n) qqnorm(x); qqline(x) op<- par(fig=c(.02,.5,.5,.98), new=TRUE) hist(x, xlab="", ylab="", main="", axes=FALSE) box() par(op)

Re: [R] R and ATLAS

2010-05-26 Thread Peter Langfelder
If you didn't specify an external BLAS when you ran R configure script, you are not using ATLAS. If you're not sure and you still have the output of the configure script, at the end it'll say whether it uses an external BLAS. Alternatively, you may also want to generate two random 5000x5000 matric

Re: [R] counts of a vector

2010-05-26 Thread speretti
Thank you all! Particulary Wu Gong whose answer is very compact -- View this message in context: http://r.789695.n4.nabble.com/counts-of-a-vector-tp2232047p2232353.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org m

[R] R and ATLAS

2010-05-26 Thread Jonathan Greenberg
Rhelpers: I recently installed the 64-bit version of R on my Debian system, and afterwards was asked if it was compiled using ATLAS. Is there a way to test to see if R is using ATLAS? --j __ R-help@r-project.org mailing list https://stat.ethz.ch/mailm

Re: [R] counts of a vector

2010-05-26 Thread Wu Gong
### Special cumsum ### Do cumsum when TRUE, and reset to 0 when FALSE x <- c( TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE ) ## The rle function computes the lengths of equal values of a vector ## And gives two vecters: $lengths and $values ## The sequence function creates and concaten

Re: [R] Fill a matrix using logical arguments?

2010-05-26 Thread Joris Meys
Hi Alistair, ?match will help, but you need to extract the site names first. Quick and dirty : seed <- substr(rownames(bank.plot),1,5) site <- rownames(site.veg) for(i in 1:length(seed)){ bank.plot[i,]<-site.veg[match(seed[i],site),] } Cheers Joris On Wed, May 26, 2010 at 2:50 PM, Alistair Au

Re: [R] Pipe

2010-05-26 Thread Joe Stuart
Thanks for the info. I'll give that a try. On May 25, 2010, at 5:36 PM, jim holtman wrote: readLines will read until it reached an end-of -file. try readLines(con, n=1) to read one line at a time an then process it. On Tue, May 25, 2010 at 2:07 PM, Joe Stuart wrote: Hi, I'm trying to

Re: [R] More efficient way to use ifelse()? - A follow up

2010-05-26 Thread Joris Meys
Remove the "" around the options. You also have to put it in a sapply, as switch only works on single values. But I wouldn't call this optimal... elevation.DM <-sapply(Population,switch, CO= 2169, CN = 1121, Ga =500, KO = 2500, Mw = 625, Ng = 300 ) Cheers Joris

Re: [R] How to calculate mean of means

2010-05-26 Thread David Winsemius
On May 26, 2010, at 3:30 PM, ecvet...@uwaterloo.ca wrote: I have 3 columns of numbers, and i want to find the mean of each separately, and then the mean of all of the means. ive tried: av3daysB<- mean(mean(avr1), mean(avr2), mean(avr3)) av3daysB sapply(list(avr1, avr2, avr3), mean) mean(c

Re: [R] shapiro.test

2010-05-26 Thread David Winsemius
On May 26, 2010, at 3:36 PM, Stefan Scheurer wrote: Hi, I am not so sure about an error note I got when using shapiro.test. I imported some data into R by wrinting it into a .txt file via tab1<-read.table("etctxt",header=T) attach(tab1) The following object(s) are masked _by_ .Gl

Re: [R] How to calculate mean of means

2010-05-26 Thread Henrique Dallazuanna
Try this: av3daysB<- mean(c(mean(avr1), mean(avr2), mean(avr3))) On Wed, May 26, 2010 at 4:30 PM, wrote: > I have 3 columns of numbers, and i want to find the mean of each > separately, and then the mean of all of the means. > ive tried: > > av3daysB<- mean(mean(avr1), mean(avr2), mean(avr3))

Re: [R] Getting sink to work with "message" on R 2.11.0 - what didI miss?

2010-05-26 Thread Greg Snow
I think we agree for the most part. I also like Henrik's suggestion, but someone (probably multiple) with more experience in TTY and similar areas needs to be involved. I think it will be easier to do in R than in most other programs. I would be willing to contribute to such a project if ther

[R] shapiro.test

2010-05-26 Thread Stefan Scheurer
Hi, I am not so sure about an error note I got when using shapiro.test. I imported some data into R by wrinting it into a .txt file via > tab1<-read.table("etctxt",header=T) > attach(tab1) The following object(s) are masked _by_ .GlobalEnv : ozon > ozon$V1 [1] 2.5 3.0 5.6 4.

[R] question about repeated measure

2010-05-26 Thread HYOYOUNG CHOO-WOSOBA
Dear R- helper, I am trying to analyze repeated measure . there are three factors: a ,b and time a and b factors have two levels and time has 90 different timepoints. This is the r-code I've tried; gls(y~factor(a)*factor(b)*time, data=, corr=corAR1(form=~time|id)) Here, the reason why I did n

[R] How to calculate mean of means

2010-05-26 Thread ecvetano
I have 3 columns of numbers, and i want to find the mean of each separately, and then the mean of all of the means. ive tried: av3daysB<- mean(mean(avr1), mean(avr2), mean(avr3)) av3daysB but it only gives me the mean of the first column (avr1) Any suggestions? Thanks, Emilija __

Re: [R] More efficient way to use ifelse()? - A follow up

2010-05-26 Thread Ian Dworkin
# Thanks again to everyone who provided suggestions. # I was curious about which approaches would be the fastest... so a little benchmarking # My approach was by far the worst :) # The approach suggested by Duncan Murdoch and Peter Langfelder, based on indexing , was by far the fastest (~ 66times

[R] variance-covariance matrix of mlest in library(mvnmle)

2010-05-26 Thread Samantha
How does mlest generate the estimate for sigmahat, the variance-covariance matrix? It produces different values than when using cov(data.frame). -- View this message in context: http://r.789695.n4.nabble.com/variance-covariance-matrix-of-mlest-in-library-mvnmle-tp2232127p2232127.html Sent from

Re: [R] Linear Discriminant Analysis in R

2010-05-26 Thread Joris Meys
Why exactly do you need lda and not another method? For lda to be applicable, you should check : 1) whether the regressors are normally distributed within the classes 2) whether the variance-covariance matrices are equal for all classes Essentially, this means that the boundary between both classe

Re: [R] R editor

2010-05-26 Thread Paul
b...@email.unc.edu wrote: Erik, What R editor do you use? I've tried SciTE but it won't color the code. Brian If you're looking for code colouring then try StatEt and Eclipse (http://www.walware.de/goto/statet and http://www.eclipse.org/eclipse/). It's cross platform and runs really w

Re: [R] error "variable names are limited to 256 bytes" when sourcing code

2010-05-26 Thread Duncan Murdoch
Brian Frizzelle wrote: I've written a function that takes some input data output from a simulation model and creates some graphs. It's not very complicated code, and it works perfectly fine if I just run the code as is. But I have converted it into a function so we call it externally, and whe

Re: [R] Getting sink to work with "message" on R 2.11.0 - what didI miss?

2010-05-26 Thread Tal Galili
Hello Greg, First, I wish to thank/compliment you for the coding you did. I am sure it will help that guy more then what I had made - I simply didn't know how to do it the way you did it, so I did what I could. Regarding the formatting of tables - he needs that output to go for assignments he is

[R] Is possible a mini-plot into a big plot with Lattice?

2010-05-26 Thread Walmes Marques Zeviani
Hello, I want to do with Lattice functions (qqmath, histogram) a figure like this below. n <- 1000 x <- rnorm(n) qqnorm(x); qqline(x) op <- par(fig=c(.02,.5,.5,.98), new=TRUE) hist(x, xlab="", ylab="", main="", axes=FALSE) box() par(op) Is possible? Thanks. Walmes Zeviani.

Re: [R] R editor

2010-05-26 Thread Erik Iverson
Joris' suggestions are good ones. I use Emacs with ESS (and now org-babel) for R programming and for interaction with the R process. But I use Emacs for everything. Emacs is actually pretty easy to install these days on Windows, and Vincent Goulet provides a nice package with all you need to g

Re: [R] Kalman Filter

2010-05-26 Thread Giovanni Petris
To find out what tools are available in R, you can check out the Time Series task view on CRAN: http://cran.r-project.org/web/views/TimeSeries.html My personal preference is for package dlm, but here I am probably biased. [discaimer: the following is a sponsored link] For more information on D

Re: [R] R editor

2010-05-26 Thread Joris Meys
I'm not Erik, but what the heck. What platform, linux or Windows? On Windows, I use Tinn-R, which is great for using with R as you get full control over the console. You need to take into account that you should install R with the SDI option, and that you have to configure Tinn-R the first time fr

Re: [R] error "variable names are limited to 256 bytes" when sourcing code

2010-05-26 Thread Brian Frizzelle
Well, that's embarrassing. Thank you for finding that. -- View this message in context: http://r.789695.n4.nabble.com/error-variable-names-are-limited-to-256-bytes-when-sourcing-code-tp2231800p2232244.html Sent from the R help mailing list archive at Nabble.com. ___

[R] R editor

2010-05-26 Thread bgf
Erik, What R editor do you use? I've tried SciTE but it won't color the code. Brian __ 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 provi

Re: [R] Getting sink to work with "message" on R 2.11.0 - what didI miss?

2010-05-26 Thread Greg Snow
Inline below: > From: Tal Galili [mailto:tal.gal...@gmail.com] > Sent: Wednesday, May 26, 2010 12:26 AM > To: Greg Snow > Cc: Faiz Rasool; R-help@r-project.org > Subject: Re: [R] Getting sink to work with "message" on R 2.11.0 - what didI > miss? > > Hello Greg, > Thank you for the coding. > >

Re: [R] error "variable names are limited to 256 bytes" when sourcing code

2010-05-26 Thread Joris Meys
I was about to say the same. loading the code line per line gave the error a few lines after that one. Which explains... Cheers Joris On Wed, May 26, 2010 at 9:27 PM, Erik Iverson wrote: > Is the '`' character supposed to be there before the ## Add error bars > comment? > > If that is the probl

Re: [R] error "variable names are limited to 256 bytes" when sourcing code

2010-05-26 Thread Erik Iverson
Is the '`' character supposed to be there before the ## Add error bars comment? If that is the problem, let it be a good lessonto use an editor with syntax highlighting. :) Brian Frizzelle wrote: All, I think there may be some misunderstanding about my problem. In my code, which is

Re: [R] counts of a vector

2010-05-26 Thread William Dunlap
Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of speretti > Sent: Wednesday, May 26, 2010 10:22 AM > To: r-help@r-project.org > Subject: [R] counts of a vector > > >

Re: [R] error "variable names are limited to 256 bytes" when sourcing code

2010-05-26 Thread Brian Frizzelle
All, I think there may be some misunderstanding about my problem. In my code, which is written as an R function, all of my variable names are short. I get that error when I try to source the function so I can call it. I just do not know why I'm getting the error, especially since I have written o

Re: [R] data frame manipulation change elements meeting criteria

2010-05-26 Thread Joris Meys
see ?switch X<- rep(c("Buy","Sell","something else"),each=5) Y<- rep(c("DEL","INS","DEL"),5) new.vect <- X for (i in which(Y=="DEL")){ new.vect[i]<-switch( EXPR = X[i], Sell="Buy", Buy="Sell", X[i]) } cbind(new.vect,X,Y) On Wed, May 26, 2010 at 7:43 P

Re: [R] error "variable names are limited to 256 bytes" when sou

2010-05-26 Thread Ted Harding
On 26-May-10 18:40:46, Barry Rowlingson wrote: > On Wed, May 26, 2010 at 6:00 PM, Wu Gong wrote: >> >> I can only repeat your error message :) >> >>> n256 <- paste(rep("A",256),collapse="") >>> assign(n256, 1) >>> n257 <- paste(rep("A",257),collapse="") >>> assign(n257, 1) >> Error in assign(n257,

Re: [R] error "variable names are limited to 256 b ytes" when sourcing code

2010-05-26 Thread Ben Bolker
Barry Rowlingson lancaster.ac.uk> writes: > If a variable name can have 26 upper case + 26 lower case + 10 > numbers then the number of possible variable names is: > > 711659926691456588820198688981513283237719214167524272940980007340737850\ > 0715055503674260501908537449489553399876624278448108

Re: [R] Peak Over Threshold values

2010-05-26 Thread Clint Bowman
How about? hi.rle<-rle(walevel>5.79) lo.rle<-rle(walevel<5.36) plot(walevel) abline(h=5.8,col=2,lty=3) abline(h=5.35,col=3,lty=3) hi.lo.rle<-sort(c(cumsum(hi.rle$lengths),cumsum(lo.rle$lengths))) abline(v=hi.lo.rle) You can use the $values from the rle to sort things out. Probably want to igno

Re: [R] error "variable names are limited to 256 bytes" when sourcing code

2010-05-26 Thread Barry Rowlingson
On Wed, May 26, 2010 at 6:00 PM, Wu Gong wrote: > > I can only repeat your error message :) > > >> n256 <- paste(rep("A",256),collapse="") >> assign(n256, 1) >> n257 <- paste(rep("A",257),collapse="") >> assign(n257, 1) > Error in assign(n257, 1) : variable names are limited to 256 bytes > If a

[R] R/Rmetrics Meielisalp Summer School and User/Developer Workshop 2010

2010-05-26 Thread Diethelm Wuertz
Computational Finance and Financial Engineering 1st R/Rmetrics Summer School and 4th User/Developer Meeting Meielisalp, Lake Thune Switzerland, June 27 - July 1, 2010 Late Registration: https://www.rmetrics.org/meielisalp2010-registration Students: Apply for Student Scholarships

Re: [R] counts of a vector

2010-05-26 Thread Gabor Grothendieck
Check out this thread for numerous solutions: https://stat.ethz.ch/pipermail/r-help/2007-June/134557.html On Wed, May 26, 2010 at 1:22 PM, speretti wrote: > > Hi, > > I need help to find an efficient way to transform a vector like: > > a<-c(1,1,0,1,0,0,0,1,1,1,1,0,1,0,1,1) > > in a vector that co

Re: [R] counts of a vector

2010-05-26 Thread Erik Iverson
speretti wrote: Hi, I need help to find an efficient way to transform a vector like: a<-c(1,1,0,1,0,0,0,1,1,1,1,0,1,0,1,1) in a vector that counts only di 1 elements, like: b<-c(1,2,0,1,0,0,0,1,2,3,4,0,1,0,1,2) Thank you! One way: rl <- rle(a) unlist(mapply("*", lapply(rl$lengths, fun

Re: [R] error "variable names are limited to 256 bytes" when sourcing code

2010-05-26 Thread Wu Gong
I can only repeat your error message :) > n256 <- paste(rep("A",256),collapse="") > assign(n256, 1) > n257 <- paste(rep("A",257),collapse="") > assign(n257, 1) Error in assign(n257, 1) : variable names are limited to 256 bytes - A R learner. -- View this message in context: http://r.7896

[R] counts of a vector

2010-05-26 Thread speretti
Hi, I need help to find an efficient way to transform a vector like: a<-c(1,1,0,1,0,0,0,1,1,1,1,0,1,0,1,1) in a vector that counts only di 1 elements, like: b<-c(1,2,0,1,0,0,0,1,2,3,4,0,1,0,1,2) Thank you! -- View this message in context: http://r.789695.n4.nabble.com/counts-of-a-vector-tp

[R] Linear Discriminant Analysis in R

2010-05-26 Thread cobbler_squad
Dear R gurus, Thank you all for continuous support and guidance -- learning without you would not be efficient. I have a question regarding LD analysis and how to best code it up in R. I have a file of (V52 and 671 time points across all columns) and another file of phonetic features (each vow

Re: [R] Problem with plotting survival predictions from cph model

2010-05-26 Thread Frank E Harrell Jr
On 05/26/2010 10:55 AM, Michal Figurski wrote: Dear R-helpers, I am working with 'cph' models from 'rms' library. When I build simple survival models, based on 'Surv(time, event)', everything is fine and I can make nice plots using plot(Predict(f, time=3)). However, recently I tried to be more

Re: [R] Custom axis function in lattice:::xyplot

2010-05-26 Thread Gavin Simpson
> > # There must a better way, but this works; add > >labels = levels(dat$fac)[panel.number()], > > # to your panel.axis() call in axis.VarLabs. Thanks Peter. I had tried that but it didn't work. Now just realised I was hitting a scoping problem and that my example was subtly different to

Re: [R] Custom axis function in lattice:::xyplot

2010-05-26 Thread Deepayan Sarkar
On Wed, May 26, 2010 at 10:20 AM, Peter Ehlers wrote: > On 2010-05-26 4:03, Gavin Simpson wrote: >> >> Dear List, >> >> I have been writing a Lattice function to draw what we call >> stratigraphic diagrams, these are diagrams with a panel for each species >> showing a time series of abundance, but

[R] data frame manipulation change elements meeting criteria

2010-05-26 Thread arnaud Gaboury
Dear group, Here is my df : trade <- structure(list(Trade.Status = c("DEL", "INS", "INS"), Instrument.Long.Name = c("SUGAR NO.11", "CORN", "CORN"), Delivery.Prompt.Date = c("Jul/10", "Jul/10", "Jul/10"), Buy.Sell..Cleared. = c("Sell", "Buy", "Buy"), Volume = c(1L, 2L, 1L), Price = c("15.2500",

Re: [R] Custom axis function in lattice:::xyplot

2010-05-26 Thread Peter Ehlers
On 2010-05-26 4:03, Gavin Simpson wrote: Dear List, I have been writing a Lattice function to draw what we call stratigraphic diagrams, these are diagrams with a panel for each species showing a time series of abundance, but drawn vertically to represent time passing from bottom of plot towards

Re: [R] how to Store loop output from a function

2010-05-26 Thread Changbin Du
tree.pred <- yourfunction works! Thanks, Josh! On Wed, May 26, 2010 at 9:35 AM, Joshua Wiley wrote: > If you use return you need to assign the results to an object. For > instance > > tree.pred <- yourfunction > > then tree.pred will contain whatever data you returned from your > function.

[R] rjags installation problem in Ubuntu 10.04

2010-05-26 Thread Scott Brogan
I've not been able to install rjags successfully in Ubuntu 10.04 : ** testing if installed package can be loaded Error : .onLoad failed in loadNamespace() for 'rjags', details: call: dyn.load(file, DLLpath = DLLpath, ...) error: unable to load shared library '/home/scott/R/i486-pc-linux-gnu-li

Re: [R] how to Store loop output from a function

2010-05-26 Thread Joshua Wiley
If you use return you need to assign the results to an object. For instance tree.pred <- yourfunction then tree.pred will contain whatever data you returned from your function. If you truly want your function to assign objects internally that are available in your general workspace, instead of

[R] how to Store loop output from a function

2010-05-26 Thread Changbin Du
HI, Dear R community, I am writing the following function to create one data set(*tree.pred*) and one vector(*valid.out*) from loops. Later, I want to use the data set from this loop to plot curves. I have tried return, list, but I can not use the *tree.pred* data and *valid.out* vector. auc.t

Re: [R] how to avoid a subset of a matrix to become a column vector

2010-05-26 Thread Joris Meys
What exactly are you trying to do? An example (which you should have provided) > A <- matrix(1:100,nrow=10,ncol=10) > B <- A[10,1:3] > B [1] 10 20 30 > is.matrix(B) [1] FALSE > matrix(B) [,1] [1,] 10 [2,] 20 [3,] 30 This is logic, as you convert a vector to a matrix, and he will a

Re: [R] cluster analysis and supervised classification: an alternative to knn1?

2010-05-26 Thread Joris Meys
Not a direct answer, but from your description it looks like you are better of with supervised classification algorithms instead of unsupervised clustering. see the library randomForest for example. Alternatively, you can try a logistic regression or a multinomial regression approach, but these are

Re: [R] how to avoid a subset of a matrix to become a column vector

2010-05-26 Thread David Winsemius
On May 26, 2010, at 11:58 AM, wrote: I am assigning subset of a matrix A [n,3] where n>1 to a temporary matrix TMP I do not know how many rows of A will be assigned to TMP because this is established by a run-time test. I expect TMP to be a matrix [m,3], m >=1 But when 1 row only is tra

[R] Problem with plotting survival predictions from cph model

2010-05-26 Thread Michal Figurski
Dear R-helpers, I am working with 'cph' models from 'rms' library. When I build simple survival models, based on 'Surv(time, event)', everything is fine and I can make nice plots using plot(Predict(f, time=3)). However, recently I tried to be more specific and used 'Surv(start, stop, event)'

[R] how to avoid a subset of a matrix to become a column vector

2010-05-26 Thread mauede
I am assigning subset of a matrix A [n,3] where n>1 to a temporary matrix TMP I do not know how many rows of A will be assigned to TMP because this is established by a run-time test. I expect TMP to be a matrix [m,3], m >=1 But when 1 row only is transferred from A to TMP then TMP becomes [3,1]

Re: [R] Code to calculate internal rate of return

2010-05-26 Thread Dimitri Shvorob
Unfortunately, this is not a robust implementation, and is derailed by Error in uniroot(f, c(-1, 1)) : f() values at end points not of opposite sign -- View this message in context: http://r.789695.n4.nabble.com/Code-to-calculate-internal-rate-of-return-tp864645p2231910.html Sent from the R

[R] cluster analysis and supervised classification: an alternative to knn1?

2010-05-26 Thread abanero
Hi, I have a 1.000 observations with 10 attributes (of different types: numeric, dicotomic, categorical ecc..) and a measure M. I need to cluster these observations in order to assign a new observation (with the same 10 attributes but not the measure) to a cluster. I want to calculate for the

Re: [R] condition apply to elements of a data frame column

2010-05-26 Thread arnaud Gaboury
Joris, I want to add a line in a function with a print "warning" if one element of the column is <>0. I could use if(sum(u$POSITION)<>0) as a condition, but I can imagine having one element equal to -2, and another one to 2. So in this case, sum=0, but the condition is false in fact (minimum of o

[R] Survival analysis extrapolation

2010-05-26 Thread TReason
Dear all, I'm trying to fit a curve to some 1 year failure-time data, so that I can extrapolate and predict failure rates up to 3 years. The data is in the general form: Treatment Time Status Treatment A28 0 Treat

[R] Autocorrelation in R for NLS

2010-05-26 Thread ruchita gupta
Hello Can someone please let me know how to test for Autocorrelation in R ( eg. like durbin-watson statistic or any other test) after performing Non linear least squares and what can be the best solution for it. Thanks Regards Ruchita [[alternative HTML version deleted]] __

[R] error "variable names are limited to 256 bytes" when sourcing code

2010-05-26 Thread Brian Frizzelle
I've written a function that takes some input data output from a simulation model and creates some graphs. It's not very complicated code, and it works perfectly fine if I just run the code as is. But I have converted it into a function so we call it externally, and when I try to source the co

Re: [R] Hierarchical clustering using own distance matrices

2010-05-26 Thread new...@r
new...@r wrote: > > Hey Everyone! > > I wanted to carry out Hierarchical clustering using distance matrices i > have calculated ( instead of euclidean distance etc.) > > I understand as.dist is the function for this, but the distances in the > dendrogram i got by using the following script(1)

[R] Fill a matrix using logical arguments?

2010-05-26 Thread Alistair Auffret
Hello all, I am going slightly mad trying to create a table for running co-correspondence analysis. What I have is seed bank and vegetation data, and my aim is to see if the vegetation found in a site (containing several seed bank samples) can predict the composition of a seed bank sample wi

Re: [R] More efficient way to use ifelse()?

2010-05-26 Thread David Winsemius
On May 26, 2010, at 1:25 AM, Ian Dworkin wrote: # This is more about trying to find a more effecient way to code some simple vectorized computations using ifelse(). # Say you have some vector representing a factor with a number of levels (6 in this case), representing the location that samples

Re: [R] Socket establishment

2010-05-26 Thread Allan Engelhardt
Presumably nothing is accepting connections on port 9754. Unless you've got a server listening for connections there, then this is the expected behaviour. (If you wanted to write a server then, obviously, use server=TRUE.) If there is a server, then it is probably not working. Very unlikely

[R] stress function in isoMDS

2010-05-26 Thread Joris Meys
Dear all, as far as my understanding goes, isoMDS uses the Kruskal definition of stress, i.e. : "the square root of the ratio of the sum of squared differences between the input distances and those of the configuration to the sum of configuration distances squared." (as stated in the help files).

[R] Socket establishment

2010-05-26 Thread wesley mathew
Dear All I have some doubt about socket establishment. I am sending this question again. Sorry to bothering you a lot. Example : make.socket(host = "localhost", port=9754, fail = TRUE, server = FALSE) *Error in make.socket(host = "localhost", port = 9754, fail = TRUE, server = FALSE) : socket not

Re: [R] Lattice: relation = 'free' in scales

2010-05-26 Thread Deepayan Sarkar
On Tue, May 25, 2010 at 9:30 PM, Peter Ehlers wrote: > Albart, > > On 2010-05-25 1:51, Albart wrote: >> >> Hello list, >> >> I am making graphics for an article which I want to publish. The article >> is >> about several methods (to calculate breeding values of individuals) >> applied >> in severa

Re: [R] condition apply to elements of a data frame column

2010-05-26 Thread Joris Meys
Arnaud, check the vector : > u$POSITION<>0 [1] TRUE TRUE ... what I do is putting u$POSITION==0 [1] FALSE FALSE ... when you apply the sum() function on that vector, FALSE becomes 0 and TRUE becomes 1. So this actually gives you a way of counting the amount of positions that are not zero. if you

[R] extracat , JGR, iWidgets install problems

2010-05-26 Thread Michael Friendly
[Environment: Win XP, R 2.10.1] I'm trying to install the packages JGR and iWidgets required by the extracat package to make the interactive plots in the package work. I've tried various things, but nothing seems to work. Here is my most recent attempt, followed by my sessionInfo(). Does an

Re: [R] Relative Risk/Hazard Ratio plots for continuous variables

2010-05-26 Thread Terry Therneau
I prefer smoothing splines, Frank prefers regression splines. The former is built into the survival package: options(na.action=na.exclude) # This should be the default IMHO coxfit1<- coxph(Surv(rtime,rcens) ~ pspline(cts), data=data1) summary(coxfit1) #shows the linear and nonlinear tests

  1   2   >