[R] Classifying values by interval

2011-08-31 Thread Ted Harding
Greetings All! As is often the case on this list, the answer may well be under my nose but I can't see it! I am looking for a "smart" way to do the following. Say I have a vector of values, X. I set up bins" for X, say with breaks at B = c(b1,b2,...,b11) covering the range of X, i.e. bins numbere

Re: [R] Classifying values by interval

2011-08-31 Thread Dimitris Rizopoulos
Probably you're looking for function findInterval(). I hope it helps. Best, Dimitris On 8/31/2011 10:00 AM, Ted Harding wrote: Greetings All! As is often the case on this list, the answer may well be under my nose but I can't see it! I am looking for a "smart" way to do the following. Say

Re: [R] Classifying values by interval

2011-08-31 Thread Ted Harding
Thanks, Dimitris. That looks hopeful! Ted. On 31-Aug-11 08:06:23, Dimitris Rizopoulos wrote: > Probably you're looking for function findInterval(). > > I hope it helps. > > Best, > Dimitris > > On 8/31/2011 10:00 AM, Ted Harding wrote: >> Greetings All! >> As is often the case on this list, the

Re: [R] Classifying values by interval

2011-08-31 Thread Jim Lemon
On 08/31/2011 06:00 PM, Ted Harding wrote: Greetings All! As is often the case on this list, the answer may well be under my nose but I can't see it! I am looking for a "smart" way to do the following. Say I have a vector of values, X. I set up bins" for X, say with breaks at B = c(b1,b2,...,b1

Re: [R] Classifying values by interval

2011-08-31 Thread Ted Harding
On 31-Aug-11 08:25:15, Jim Lemon wrote: > On 08/31/2011 06:00 PM, Ted Harding wrote: >> Greetings All! >> As is often the case on this list, the answer may well >> be under my nose but I can't see it! >> >> I am looking for a "smart" way to do the following. >> >> Say I have a vector of values, X.

[R] Recoding observations in all columns of a data frame.

2011-08-31 Thread C.H.
Dear all, Suppose I have a data frame like this: [code] var1 <- c(1,999,2) var2 <- c(999,1,2) var3 <- c(1,2,999) example <- data.frame(var1,var2,var3) [/code] I want to replace all 999 to NA in all observations in all columns. I know how to do it in each individual column. [code] example$var1[e

Re: [R] Recoding observations in all columns of a data frame.

2011-08-31 Thread Jorge I Velez
Dear CH, Try example[example == 999] <- NA example HTH, Jorge On Wed, Aug 31, 2011 at 4:48 AM, C.H. <> wrote: > Dear all, > > Suppose I have a data frame like this: > > [code] > var1 <- c(1,999,2) > var2 <- c(999,1,2) > var3 <- c(1,2,999) > example <- data.frame(var1,var2,var3) > [/code] > >

Re: [R] Error: evaluation nested too deeply: infinite recursion / options(expressions=)?

2011-08-31 Thread Patrick Connolly
. . -- .- -.-- -... . ... --- -- . .-. . .--. .-. --- -.. ..- -.-. .- -... .-.. . -.-. --- -.. . .-- --- ..- .-.. -.. . .-.. .--. ..- ... .- -. ... .-- . .-. -.-- --- ..- .-. --.- ..- . ... - .. --- -. ... - --- .--. .- .--. --- .-.. --- --. .. . ... ..-. --- .-.

Re: [R] algorithm to merge same entries in a matrix

2011-08-31 Thread Paul Hiemstra
Hi, Take a look at the rle() function. This finds runs of equal values in vectors. Using apply this can quite easily be run for all the rows/columns of a matrix. cheers, Paul On 08/30/2011 04:58 PM, Martin Batholdy wrote: > Hi, > > I have the following, rather unorthodox problem: > > > I have a

Re: [R] Error: evaluation nested too deeply: infinite recursion / options(expressions=)?

2011-08-31 Thread Jim Lemon
On 08/31/2011 07:06 PM, Patrick Connolly wrote: . . -- .- -.-- -... . ... --- -- . .-. . .--. .-. --- -.. ..- -.-. .- -... .-.. . -.-. --- -.. . .-- --- ..- .-.. -.. . .-.. .--. ..- ... .- -. ... .-- . .-. -.-- --- ..- .-. --.- ..- . ... - .. --- -. ... - --- .--. .- .--. --

[R] Building help fails for package BBMM

2011-08-31 Thread Levent B.
Hi alltogether! I just tried to install the package BBMM and got the following error message: Error in file 'BBMM-package.Rd': \cr does not fit tabular format {ll} Fehler: building help failed für Paket ‘BBMM’ Is there a workaroung to this problem or will i have to wait until it gets fixed?

[R] Convert CSV file to FASTA

2011-08-31 Thread anyone
Hi there, I have large excel files which I can save as CSV files. Each excel file contains two columns. One contains the chromosome number and the second contains a DNA sequence. I need to convert this into a fasta file that looks like this >chromosomenumber CGTCGAGCGTCGAGCGGAGCG Can anyon

[R] Fitting the negative hypergeometric distribution

2011-08-31 Thread Wilson, Andrew
I'd like to fit the (1-displaced) negative hypergeometric distribution to data samples such as the following:- x <- c(370, 311, 299, 266, 265, 232, 197, 198, 170, 154, 133, 123, 120, 103, 80, 72, 69, 67, 67, 50, 36, 35, 26, 23, 15, 11, 9, 6, 5, 3, 3, 2, 2, 2) i.e., I want to estimate the paramete

[R] reshape/aggregate

2011-08-31 Thread Kai Megerle
Hi all, I apologize for this probably stupid question, but I really can't figure it out. I have a dataframe like this: group <- c(rep('A', 8), rep('B', 15), rep('C', 6)) time <- c(rep(seq(1:4), 2), rep(seq(1:5), 3), rep(seq(1:3), 2)) value <- runif (29, 1, 10) dfx <- data.frame (group, time, value

[R] QUANSTRAT: error with applySignal

2011-08-31 Thread mayouf.k
hi everyone, I want to backtest a simple strategy with RSI, im using "sigThreshold". i took example from the http://blog.fosstrading.com/ site to understand how quanstrat works. but now, i have a problem with my code that i really don't understand, R says me: Error in match.names(column, colna

[R] Odp: reshape/aggregate

2011-08-31 Thread Petr PIKAL
Hi > Hi all, > I apologize for this probably stupid question, but I really can't figure it > out. > I have a dataframe like this: > > group <- c(rep('A', 8), rep('B', 15), rep('C', 6)) > time <- c(rep(seq(1:4), 2), rep(seq(1:5), 3), rep(seq(1:3), 2)) > value <- runif (29, 1, 10) > dfx <- data.fr

Re: [R] Odp: reshape/aggregate

2011-08-31 Thread Ista Zahn
The plyr solution is: library(plyr) ddply(dfx, .(group, time), summarize, mean = mean(value), sd = sd(value)) Best, Ista On Wed, Aug 31, 2011 at 7:13 AM, Petr PIKAL wrote: > Hi > >> Hi all, >> I apologize for this probably stupid question, but I really can't figure > it >> out. >> I have a dat

[R] Programming examples added to r4stats.com

2011-08-31 Thread Muenchen, Robert A (Bob)
Hi All, I now have programming examples for common research tasks done in R, SAS, SPSS and Stata at http://r4stats.com. The examples fall into the following categories: Data Import & Export Data Management Enhancing Output Graphics, ggplot2 Graphics, Traditional Selecting Variables and Observa

Re: [R] reshape/aggregate

2011-08-31 Thread jim holtman
You can use data.table: > group <- c(rep('A', 8), rep('B', 15), rep('C', 6)) > time <- c(rep(seq(1:4), 2), rep(seq(1:5), 3), rep(seq(1:3), 2)) > value <- runif (29, 1, 10) > dfx <- data.frame (group, time, value) > require(data.table) > dfx <- data.table(dfx) > dfx[, + list(mean = mean(value),

Re: [R] Building help fails for package BBMM

2011-08-31 Thread Uwe Ligges
The CRAN check page at http://cran.r-project.org/web/checks/check_results_BBMM.html suggests it works under all tested platforms. Therefore I guess you R is outdated. Please upgrade R and report to the package maintainer that (s)he should add a dependency statement on a fairly recent version of

[R] assign group letters to T/F matrix

2011-08-31 Thread eldor ado
dear R community, i appologize as this is kind of a newbie question, but: I want to assign group letters (like in anova post-hoc tests) to data with combined means and SDs. It's easy to apply t-test formulas to get a materix like (A - D are treatments | A B C D ---

Re: [R] assign group letters to T/F matrix

2011-08-31 Thread Dimitris Rizopoulos
Have a look at package multcomp at: http://cran.r-project.org/package=multcomp I hope it helps. Best, Dimitris On 8/31/2011 2:30 PM, eldor ado wrote: dear R community, i appologize as this is kind of a newbie question, but: I want to assign group letters (like in anova post-hoc tests) to

Re: [R] : reshape/aggregate

2011-08-31 Thread Petr PIKAL
Hi > The plyr solution is: > > library(plyr) > ddply(dfx, .(group, time), summarize, mean = mean(value), sd = sd(value)) I tried to do the task by ddply but I had difficulties to understand the correct syntax. Maybe in next issue of plyr summarise could be referenced in ddply help page. Or

Re: [R] Convert CSV file to FASTA

2011-08-31 Thread Mike Marchywka
> Date: Wed, 31 Aug 2011 01:36:51 -0700 > From: oliviacree...@gmail.com > To: r-help@r-project.org > Subject: [R] Convert CSV file to FASTA > > Hi there, > > I have large excel files which I can save as CSV files. > > Each excel file contain

Re: [R] Convert CSV file to FASTA

2011-08-31 Thread Martin Morgan
On 08/31/2011 01:36 AM, anyone wrote: Hi there, I have large excel files which I can save as CSV files. Each excel file contains two columns. One contains the chromosome number and the second contains a DNA sequence. I need to convert this into a fasta file that looks like this chromosomenumb

Re: [R] reading data from multiple files with multiple headers

2011-08-31 Thread Weidong Gu
If you know how many lines to skip, you can set skip=xx in read.table. The question is what you can do if you have variable lines to skip in various files but you have characters indicating the begining of the data, like ~A. What you can do is get the file in using readLines, use grep to find the

Re: [R] Fitting my data to a Weibull model

2011-08-31 Thread Dennis Murphy
Hi: Things work if x is the response and y is the covariate. To use the approach I describe below, you need RStudio and its manipulate package (which is only available in RStudio - you won't find it on CRAN). You can download and install RStudio freely from http://rstudio.org/ ; it is available fo

[R] How to modify the dot-dot-dot argument using level names instead of position

2011-08-31 Thread Sébastien Bihorel
Dear R-users, In the R internals manual, it is said that one can extract the elements of the dot-dot-dot argument using the special symbols ..1 or ..2. It seems to work just fine but I was wondering if there is a way one can extract or modify the content of the dot-dot-dot argument using a level n

Re: [R] Gradients in optimx

2011-08-31 Thread Ravi Varadhan
Hi Reuben, I am puzzled to note that the gradient check in "optimx" does not work for you. Can you send me a reproducible example so that I can figure this out? John - I think the best solution for now is to issue a "warning" rather than an error message, when the numerical gradient is not suf

Re: [R] How to modify the dot-dot-dot argument using level names instead of position

2011-08-31 Thread Sébastien Bihorel
Hi, I thought "..2 <- 1" was a correct way to modify the content of the 2nd level of dot-dot-dot because it did not return any error message. However, this appears to have no effect whatsoever on the content of dot-dot-dot. So, I guess I should modify my question to: is it possible to modify the c

Re: [R] How to modify the dot-dot-dot argument using level names instead of position

2011-08-31 Thread Duncan Murdoch
On 31/08/2011 9:41 AM, Sébastien Bihorel wrote: Hi, I thought "..2<- 1" was a correct way to modify the content of the 2nd level of dot-dot-dot because it did not return any error message. However, this appears to have no effect whatsoever on the content of dot-dot-dot. So, I guess I should modi

[R] Getting the values out of histogram (lattice)

2011-08-31 Thread Monica Pisica
Hi,   I have a relatively big dataset and I want to construct some histograms using the histogram function in lattice. One thing I am interested in is to look at differences between density and percent. I know I can use the hist function but it seems that this function gives sometimes some wr

[R] Redirect output of traceback() to a file?

2011-08-31 Thread . .
Hi all, I am getting evaluation nested too deeply: infinite recursion / options(expressions=)? in my code. Trying to investigate it with traceback() returns a very long list, index go even more then 495, so I can not read everything because it is not possible to scroll more. Is it possible to re

Re: [R] Redirect output of traceback() to a file?

2011-08-31 Thread David Winsemius
On Aug 31, 2011, at 9:58 AM, . . wrote: Hi all, I am getting evaluation nested too deeply: infinite recursion / options(expressions=)? in my code. Splitting this into another thread seems unnecessary. Trying to investigate it with traceback() returns a very long list, index go even more t

Re: [R] Error: evaluation nested too deeply: infinite recursion / options(expressions=)?

2011-08-31 Thread . .
I found that replacing "dcom" by "dexp"( that is what dcom will become is this case) solve the problem. But I need some mechanics like this provided by dcom, because I am planning to also use dgamma and many others... So, if some one have any idea it will be very appreciable. Thanks in advance.

Re: [R] Redirect output of traceback() to a file?

2011-08-31 Thread Duncan Murdoch
On 31/08/2011 9:58 AM, . . wrote: Hi all, I am getting evaluation nested too deeply: infinite recursion / options(expressions=)? in my code. Trying to investigate it with traceback() returns a very long list, index go even more then 495, so I can not read everything because it is not possible t

[R] !!!function to do the knn!!!

2011-08-31 Thread jiliguala
hi, r users i have a problem with KNN. i have 2 datasets, X0 and X1. >dim(X0) >1471*13 dim(X1) >5221*13 and for every instances in the dataset X1, i want to find the nearest neighbour(1nn) in the dataset X0. and i dont have the true classifications of dataset X1. but the function knn() need

Re: [R] How to modify the dot-dot-dot argument using level names instead of position

2011-08-31 Thread Sébastien Bihorel
Thanks Duncan On Wed, Aug 31, 2011 at 9:43 AM, Duncan Murdoch wrote: > On 31/08/2011 9:41 AM, Sébastien Bihorel wrote: >> >> Hi, >> >> I thought "..2<- 1" was a correct way to modify the content of the >> 2nd level of dot-dot-dot because it did not return any error message. >> However, this appea

Re: [R] Error: evaluation nested too deeply: infinite recursion / options(expressions=)?

2011-08-31 Thread David Winsemius
On Aug 31, 2011, at 10:25 AM, . . wrote: I found that replacing "dcom" by "dexp"( that is what dcom will become is this case) solve the problem. But I need some mechanics like this provided by dcom, because I am planning to also use dgamma and many others... In R functions are "things" but th

Re: [R] Fitting my data to a Weibull model

2011-08-31 Thread Justin Haynes
This is what I use... fit.func<-function(x){ require(MASS) est<-fitdistr(x$wind_speed, 'weibull')$estimate data.frame(shape=est[1],scale=est[2]) } feel free to correct me if this is wrong! Justin On Wed, Aug 31, 2011 at 6:21 AM, Dennis Murphy wrote: > Hi: > > Things work if x is the r

Re: [R] !!!function to do the knn!!!

2011-08-31 Thread David Winsemius
Thank your for your entry in the Poorly Capitalized and Inadequately Searched Posting Contest. You will be advised of your ranking in due course. In the meantime, you may want to consult the recommended search site for []functions and []Task Views that have "clustering" and "classification

Re: [R] Error: evaluation nested too deeply: infinite recursion / options(expressions=)?

2011-08-31 Thread Bert Gunter
> > In R functions are "things" but they are not "strings" and cannot be > executed by just asserting a character vector element. ... But note that they can be executed by by asserting a list of functions component (as well as by do.call below) > x <- c(rnorm, rt, rweibull) ## this is a list of f

[R] R code to calculate elixhauser comorbidity score

2011-08-31 Thread Cindy Chen
Hello, I need to calculate elixhauser comorbidity score using ICD9 code. I can find SAS code for the calculation online, but not R code. If you wrote the R code or are aware of existence of this kind of R code, could you please let me know? Thanks! Qingxia (Cindy) Chen __

Re: [R] Error: evaluation nested too deeply: infinite recursion / options(expressions=)?

2011-08-31 Thread David Winsemius
On Aug 31, 2011, at 11:05 AM, Bert Gunter wrote: In R functions are "things" but they are not "strings" and cannot be executed by just asserting a character vector element. ... But note that they can be executed by by asserting a list of functions component (as well as by do.call below) x

[R] counting the duplicates in an object of list

2011-08-31 Thread zhenjiang xu
Hi all, I have a list x:  > x=list(a=c('1','2'),b=c('2','3'),c=c('1','2'),d=c('2','3')) I can get the unique elements with unique(), but how can I get the number of duplicates for each unique elements? > unique(x) [[1]] [1] "1" "2" [[2]] [1] "2" "3" Thanks -- Best, Zhenjiang ___

Re: [R] sum of two lists

2011-08-31 Thread zhenjiang xu
Thanks, Henrique. It works. On Mon, Aug 29, 2011 at 6:45 PM, Henrique Dallazuanna wrote: > Try this: > as.list(colSums(merge(m, n, all = TRUE), na.rm = TRUE)) > > On Mon, Aug 29, 2011 at 7:39 PM, zhenjiang xu > wrote: >> >> Hi R users, >> >> Suppose I have two lists and the names of list 'm' are

Re: [R] counting the duplicates in an object of list

2011-08-31 Thread William Dunlap
table(match(x, x)) gives you the numbers but the labels are a bit more work. E.g., I'll define another list > x <- list(c("1", "2", "4"), c("1", "2", "4"), 2^(0:4), 3^(1:2), 2^(0:4)) > tb <- table(m <- match(x, x)) > m [1] 1 1 3 4 3 > tb 1 3 4 2 2 1 which says that the first elem

[R] how to create data.frames from vectors with duplicates

2011-08-31 Thread zhenjiang xu
Hi R users, suppose I have two vectors, > x=c(1,2,3,4,5) > y=c('a','b','c','a','c') How can I get a data.frame like this? > xy count a 5 b 2 c 8 I know a few ways to fulfill the task. However, I have a huge number of this kind calculations, so I'd like an efficient solution. T

Re: [R] how to create data.frames from vectors with duplicates

2011-08-31 Thread Jorge I Velez
Hi Zhenjiang, Try table(unlist(mapply(function(x, y) rep(x, y), y, x))) HTH, Jorge On Wed, Aug 31, 2011 at 12:45 PM, zhenjiang xu <> wrote: > Hi R users, > > suppose I have two vectors, > > x=c(1,2,3,4,5) > > y=c('a','b','c','a','c') > How can I get a data.frame like this? > > xy > cou

Re: [R] how to create data.frames from vectors with duplicates

2011-08-31 Thread Henrique Dallazuanna
Try this: rowsum(x, y) On Wed, Aug 31, 2011 at 1:45 PM, zhenjiang xu wrote: > > Hi R users, > > suppose I have two vectors, >  > x=c(1,2,3,4,5) >  > y=c('a','b','c','a','c') > How can I get a data.frame like this? > > xy >      count > a     5 > b     2 > c     8 > > I know a few ways to fulfill

Re: [R] how to create data.frames from vectors with duplicates

2011-08-31 Thread Marc Schwartz
On Aug 31, 2011, at 11:45 AM, zhenjiang xu wrote: > Hi R users, > > suppose I have two vectors, >> x=c(1,2,3,4,5) >> y=c('a','b','c','a','c') > How can I get a data.frame like this? >> xy > count > a 5 > b 2 > c 8 > > I know a few ways to fulfill the task. However, I have a huge

Re: [R] how to create data.frames from vectors with duplicates

2011-08-31 Thread Jorge I Velez
Also tapply(x, y, sum) HTH, Jorge On Wed, Aug 31, 2011 at 12:50 PM, Jorge I Velez <> wrote: > Hi Zhenjiang, > > Try > > table(unlist(mapply(function(x, y) rep(x, y), y, x))) > > HTH, > Jorge > > > On Wed, Aug 31, 2011 at 12:45 PM, zhenjiang xu <> wrote: > >> Hi R users, >> >> suppose I have tw

Re: [R] how to create data.frames from vectors with duplicates

2011-08-31 Thread Bert Gunter
Inline below: On Wed, Aug 31, 2011 at 9:50 AM, Jorge I Velez wrote: > Hi Zhenjiang, > > Try > > table(unlist(mapply(function(x, y) rep(x, y), y, x))) Yikes! How about simply tapply(x,y,sum) ?? ?tapply -- Bert > > HTH, > Jorge > > > On Wed, Aug 31, 2011 at 12:45 PM, zhenjiang xu <> wrote: > >> H

Re: [R] how to create data.frames from vectors with duplicates

2011-08-31 Thread Bert Gunter
For the record, Henrique's use of rowsum() is about 10 times faster than using tapply (and presumably anything with table() ) on my computer. It call a C primitive. -- Bert On Wed, Aug 31, 2011 at 9:55 AM, Henrique Dallazuanna wrote: > Try this: > > rowsum(x, y) > > On Wed, Aug 31, 2011 at 1:45

[R] ggplot2 to create a "square" plot

2011-08-31 Thread Alaios
Dear all, I am using ggplot with geom_tile to print as an image a matrix  I have. My matrix is a squared one of 512*512 cells.  The code that does that is written below > print(v + geom_tile(aes(fill=dB))+ > opts(axis.text.x=theme_text(size=20),axis.text.y=theme_text(size=20), > axis.title.x=

Re: [R] !!!function to do the knn!!!

2011-08-31 Thread jiliguala
help, help ,help!!! -- View this message in context: http://r.789695.n4.nabble.com/function-to-do-the-knn-tp3781137p3781738.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/

Re: [R] how to create data.frames from vectors with duplicates

2011-08-31 Thread William Dunlap
I'll put in a plug for vapply(). > # 100,000 numbers in 17576 groups: > y <- rep(do.call(paste, c(list(sep=""), expand.grid(LETTERS,letters,letters))), length=1e5) > x <- seq_along(y)^2 > system.time(val.vapply <- vapply(split(x, y), FUN=sum, FUN.VALUE=0)) user system elapsed

[R] Entering Multiline Commands With ESS

2011-08-31 Thread Rich Shepard
If there's a separate ESS user mail list, please point me to it. I'm using emacs with ESS and want to enter multiline commands for plots. Examples in my reference books show each line terminating with a comma so labels and other attributes can be specified for the plot before it is submitted

Re: [R] Entering Multiline Commands With ESS [SOLVED]

2011-08-31 Thread Rich Shepard
On Wed, 31 Aug 2011, Rich Shepard wrote: Please explain how I enter these commands. Got it: put the options within the enclosing parentheses. Rich __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read t

Re: [R] Entering Multiline Commands With ESS

2011-08-31 Thread Marc Schwartz
On Aug 31, 2011, at 12:42 PM, Rich Shepard wrote: > If there's a separate ESS user mail list, please point me to it. https://stat.ethz.ch/mailman/listinfo/ess-help > I'm using emacs with ESS and want to enter multiline commands for plots. > Examples in my reference books show each line termin

[R] formatting a 6 million row data set; creating a censoring variable

2011-08-31 Thread Juliet Hannah
List, Consider the following data. gender mygroup id 1 F A 1 2 F B 2 3 F B 2 4 F B 2 5 F C 2 6 F C 2 7 F C 2 8 F D 2 9 F D 2 10 F D 2 11 F D 2 12 F

[R] How to estimate shape parameters for generalized lambda distribution (GLD) in R

2011-08-31 Thread James Shaw
Is anyone aware of an R package that enables one to estimate the shape parameters (lambda3 and lambda4) for the generalized lambda distribution (GLD) based on known mean, variance, skewness, and kurtosis? I am aware of a package for generating data from a generalized lambda distribution. However,

[R] booklet on principal component analysis and linear discriminant analysis

2011-08-31 Thread Coghlan, Avril
Dear all, I've written a short booklet on how to use R for multivariate analysis, focussing on principal component analysis and linear discriminant analysis: http://little-book-of-r-for-multivariate-analysis.readthedocs.org/ Any comments or corrections will be very welcome. By the way, this has

[R] density function cannot work well on UNIX R version 2.13.

2011-08-31 Thread alex46015
Hi, there, I found density function cannot work well on UNIX.R version 2.13.1 (2011-07-08), Platform: i386-pc-solaris2.10 (32-bit) Here is an example from R doucments which can work well on other version. plot(density(c(-20,rep(0,98),20)), xlim = c(-4,4))# But right now the estimated probab

[R] Weights using Survreg

2011-08-31 Thread Boris Beranger
Dear R users, I have been trying to understand what the Weights arguments is doing in the estimation of the parameters when using the Surreg function. I looked through the function's code but I am not sure if I got it or not. For example, if I inclue the Surv function in it: survreg(Surv(vector,

[R] unequal bins in filled.contour

2011-08-31 Thread Dan Carpenter
Hello, I am trying to plot SADIE red-blue plots of cluster indicies using filled.contour. I want a plot which only has three bins for the data: <-1.5, -1.5 - 1.5, >1.5, but I am having trouble getting there. example X1 X2 X3 X4 X5 1 -5 -4.5 1.0 4.5 6 2 -3 -2.0 1.2 -1.0 3 3 0 0.0 0.0

[R] VisualBasic "select case" commad in R

2011-08-31 Thread Antonio Silva
Hello I'm translating a Visual Basic routine to R. Which command in R is similar to "select case" in VB? See the example: select case int(AG) case 0, 5, 8, 10 VAR = 37 case 1, 4 VAR = 70 case 3, 6, 9 VAR = 90 case 2, 7 VAR = 112 end select A chain of "if else" would not be very ele

Re: [R] reshape/aggregate

2011-08-31 Thread Kai Megerle
thanks everybody! On Wed, Aug 31, 2011 at 5:03 AM, jim holtman wrote: > You can use data.table: > > > group <- c(rep('A', 8), rep('B', 15), rep('C', 6)) > > time <- c(rep(seq(1:4), 2), rep(seq(1:5), 3), rep(seq(1:3), 2)) > > value <- runif (29, 1, 10) > > dfx <- data.frame (group, time, value) >

Re: [R] add a legend to a periodogram

2011-08-31 Thread Peter Maclean
Hi: Trying for hours to add a legend to a periodogram. Any help will be appreciated. For example, how can I add a legent (showing x1, x2, x3, x4) to both plots (generated by spec.program() and plot()? Here is a worked example. require(TSA) require(graphics) require(stats) t<-1986:2011 x1<-cos(t*1

[R] Treat an Unquoted Character String as a Data Frame

2011-08-31 Thread dbateman
I have several datasets that come from different studies (fv02 and fv03), they represent different levels (patients and lesions), and they have different patient populations (itt, mitt, mitt3). I wanted to write some code that would pass my three requirements into a function I wrote, produce the o

[R] generate correlated qualitative data

2011-08-31 Thread Ram H. Sharma
Dear R experts: I have following problem: # myfunction mfun1 <- function(x) { if ( x == 2){ xv <- sample(c(2,1,0),100, replace = T, prob = c(0.6, 0.2, 0.2)) } if ( x == 1){ xv <- sample(c(1,0),100, replace = T, prob = c(0.6, 0.4)) } if ( x == 0) { xv <- sample(c(0,0),100, replace = T, pro

Re: [R] VisualBasic "select case" commad in R

2011-08-31 Thread R. Michael Weylandt
? switch Might do the job. On Wed, Aug 31, 2011 at 1:27 PM, Antonio Silva wrote: > Hello > > I'm translating a Visual Basic routine to R. > > Which command in R is similar to "select case" in VB? > > See the example: > > select case int(AG) > case 0, 5, 8, 10 > VAR = 37 > case 1, 4 > VAR = 7

[R] looping by grouping variable

2011-08-31 Thread jour4life
Hello all, I hope something is not already posted regarding this exact problem I am trying to solve. I've read through the forums and previous postings and am still confused as to how to approach this. Basically, what I am trying to do is construct variables that utilizes an average of a variable

Re: [R] unequal bins in filled.contour

2011-08-31 Thread Duncan Murdoch
On 31/08/2011 10:33 AM, Dan Carpenter wrote: Hello, I am trying to plot SADIE red-blue plots of cluster indicies using filled.contour. I want a plot which only has three bins for the data: <-1.5, -1.5 - 1.5,>1.5, but I am having trouble getting there. example X1 X2 X3 X4 X5 1 -5 -4.5 1

[R] subsetting by rows

2011-08-31 Thread Joao Fadista
Dear all, I would like to know how to subset a data.frame by rows. Example: Probesets348843488834892 1 19676_at A AA 2 10001_atP P P 3 10002_at

Re: [R] Fitting my data to a Weibull model

2011-08-31 Thread Marcio
Thanks for the answers. Indeed, I wrote wrong in my examples the variables x and y I meant to say > y <- c(1,7,14,25,29,30) > x <- c(1,2,3,4,10,20) Thanks -- View this message in context: http://r.789695.n4.nabble.com/Fitting-my-data-to-a-Weibull-model-tp3780169p3781746.html Sent from the R h

Re: [R] subsetting by rows

2011-08-31 Thread R. Michael Weylandt
Suppose your data is called df. df[rowSums(df == "P")>0,] In short, this tests each element for equality for "P", sums the number of "P"s found and subsets when that number is >0. Michael On Wed, Aug 31, 2011 at 1:28 PM, Joao Fadista wrote: > Dear all, > > I would like to know how to subset a

Re: [R] subsetting by rows

2011-08-31 Thread Patrick Burns
If your data frame is called 'df', then something like the following should work: df[ apply(as.matrix(df[,-1]), 1, function(x) any(x == "P")), ] This creates a logical vector as long as the number of rows. As Bill Dunlap recently noted, 'apply' really wants a matrix and not a data frame. On 31

Re: [R] VisualBasic "select case" commad in R

2011-08-31 Thread Jorge I Velez
Hi Antonio, Take a look at require(car) ?recode for an alternative. HTH, Jorge On Wed, Aug 31, 2011 at 1:27 PM, Antonio Silva <> wrote: > Hello > > I'm translating a Visual Basic routine to R. > > Which command in R is similar to "select case" in VB? > > See the example: > > select case int(

Re: [R] looping by grouping variable

2011-08-31 Thread jim holtman
you can use 'ave' to add a new column with the state average: > id<-as.character(c(01001:01010, 02001:02010)) > st<-substr(id,1,1) > cnty<-substr(id,2,5) > tfr10<-rnorm(1:20) > > mydata<-data.frame(id,st,cnty,tfr10) > mydata$stAvg <- ave(mydata$tfr10, mydata$st) > print(mydata) id st cnty

Re: [R] add a legend to a periodogram

2011-08-31 Thread David Winsemius
On Aug 31, 2011, at 12:06 PM, Peter Maclean wrote: Hi: Trying for hours to add a legend to a periodogram. Any help will be appreciated. For example, how can I add a legent (showing x1, x2, x3, x4) to both plots (generated by spec.program() and plot()? Here is a worked example. require(T

Re: [R] VisualBasic "select case" commad in R

2011-08-31 Thread Antonio Silva
Thanks Jorge and Michael "recode" was exactly what I was looking for. AG<-2.7 VAR<-recode(as.integer(AG),"c(0,5,8,10)=37;c(1,4)=70;c(3,6,9)=90;c(2,7)=112") VAR [1] 112 Great! All the best, Antônio 2011/8/31 Jorge I Velez > Hi Antonio, > > Take a look at > > require(car) > ?recode > > for an

Re: [R] Fitting my data to a Weibull model

2011-08-31 Thread Marcio
Hi djmuseR, I tried installing and running the script that you suggested. But with every value I tried for a, b, c and d I get one of those 2 error messages Error in nls(y ~ a - b * exp(-c * x^d), start = list(a = 10, b = 30, c = 0.4, : singular gradient Error in numericDeriv(form[[3L]], name

Re: [R] Simulating distribution of max of two die

2011-08-31 Thread Greg Snow
For this example you can work out every possibility, you can use this in place (or in addition to) the simulations. Here is a quick example with a couple other ways to look at what is happening: all.rolls <- expand.grid(1:6,1:6) max.roll <- apply(all.rolls, 1, max) round(prop.table(table(max.ro

Re: [R] subsetting by rows

2011-08-31 Thread Jorge I Velez
Hi Joao, Here is one way (d is your data set): d[apply(d == 'P', 1, any),] HTH, Jorge On Wed, Aug 31, 2011 at 1:28 PM, Joao Fadista <> wrote: > Dear all, > > I would like to know how to subset a data.frame by rows. > > Example: > > Probesets34884348883489

[R] Integration methods

2011-08-31 Thread . .
Hi all, I was using integrate to do some integration. Also tried a little bit of the AdaptIntegrate from the cubature package. Is there other functions in R for numerical integration? May be a compound of function for this purpose... __ R-help@r-projec

[R] agnes not working

2011-08-31 Thread Dimitri Liakhovitski
Hello! I created a distances matrix for 13 objects using daisy (see the attached file). I am trying to clusteranalyse it using agnes but it's not working. What might be the problem: mydistances<-read.csv("Results of daisy.csv") mycluster<-agnes(mydistances, method="ward") I am getting: Error in

Re: [R] !!!function to do the knn!!!

2011-08-31 Thread Uwe Ligges
And with this one the OP won the contest David talked about with a highscore. Uwe Ligges On 31.08.2011 19:35, jiliguala wrote: help, help ,help!!! -- View this message in context: http://r.789695.n4.nabble.com/function-to-do-the-knn-tp3781137p3781738.html Sent from the R help mailing list

Re: [R] density function cannot work well on UNIX R version 2.13.

2011-08-31 Thread David Winsemius
On Aug 31, 2011, at 1:04 PM, alex46...@yahoo.com wrote: Hi, there, I found density function cannot work well on UNIX.R version 2.13.1 (2011-07-08), Platform: i386-pc-solaris2.10 (32-bit) Here is an example from R doucments which can work well on other version. plot(density(c(-20,rep(0,98

Re: [R] formatting a 6 million row data set; creating a censoring variable

2011-08-31 Thread William Dunlap
I'll assume that all of an individual's data rows are contiguous and that an individual always passes through the groups in order (or, least, the individual never leaves a group and then reenters it), so we can find everything we need to know by comparing each row with the previous row. You can us

Re: [R] ggplot2 to create a "square" plot

2011-08-31 Thread Dennis Murphy
Hi: I'd suggest using ggsave(); in particular, see its height = and width = arguments. If you have some time, you could look at some examples of ggplot2 themes: https://github.com/hadley/ggplot2/wiki/themes and some examples of how to use various opts(): https://github.com/hadley/ggplot2/wiki/%2Bo

[R] weibull shape parameter hypothese testing

2011-08-31 Thread David Schmidt
Hello r-project team, to my data I have an estimate for the shape parameter gamma of a fitted weibull distribution. Now I want to test it against the exponential distribution hypothesis, i.e. gamma = 1. Does anybody know how to do it? I think I can run a t-test, but I am not sure how to get there.

[R] completion in R console when using Lion OSX

2011-08-31 Thread Nathan Hutcheson
R version: 2.13.1 64 bit for macOSX R console version: R for Mac OS X GUI 1.40-devel Leopard build 64-bit (5874) Problem: When I go to use the auto completion feature it keeps tagging on all the listed options instead of just allowing me to pick one. Is there a fix for this? _

[R] Convert List of Data.Frames to Data.Frame when List has NULL

2011-08-31 Thread Mark Ebbert
Dear R gurus, I trying to convert a list of data frames to one data frame, but one of the values within the list is NULL, so I get the error "arguments imply differing number of rows." Do you know of a quick way to tell R to combine all that are not null? Here is a simple example: > tmp<-list(

Re: [R] completion in R console when using Lion OSX

2011-08-31 Thread Marc Schwartz
On Aug 31, 2011, at 2:40 PM, Nathan Hutcheson wrote: > R version: 2.13.1 64 bit for macOSX > R console version: R for Mac OS X GUI 1.40-devel Leopard build 64-bit (5874) > > > Problem: When I go to use the auto completion feature it keeps tagging > on all the listed options instead of just al

Re: [R] Convert List of Data.Frames to Data.Frame when List has NULL

2011-08-31 Thread Jorge I Velez
Hi Mark, Try do.call(rbind, tmp[!sapply(tmp, is.null)]) HTH, Jorge On Wed, Aug 31, 2011 at 4:02 PM, Mark Ebbert <> wrote: > Dear R gurus, > > I trying to convert a list of data frames to one data frame, but one of the > values within the list is NULL, so I get the error "arguments imply > dif

[R] Converting anova/ancova summary to data frame

2011-08-31 Thread Shane Phillips
Hi! Can anyone tell me how to convert the anova/ancova summary output into a data frame? Thanks! Shane Phillips [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do

[R] implementation of split or two-piece normal distribution?

2011-08-31 Thread diana
Dear all, Are you aware of any implementation of the split normal distribution (also called two-piece normal) in R? For a description, please consult: http://en.wikipedia.org/wiki/Split_normal_distribution By implementation, I mean functions like dnorm, rnorm, qnorm, etc. Thanks for your help

Re: [R] Converting anova/ancova summary to data frame

2011-08-31 Thread Uwe Ligges
On 31.08.2011 22:33, Shane Phillips wrote: Hi! Can anyone tell me how to convert the anova/ancova summary output into a data frame? For the first component of such an object: as.data.frame(summary.aov_object[[1]]) Uwe Ligges Thanks! Shane Phillips [[alternative HTML version

Re: [R] Convert List of Data.Frames to Data.Frame when List has NULL

2011-08-31 Thread Mark Ebbert
Yeah, I never would have come up with that one. Thanks! On Aug 31, 2011, at 2:18 PM, Jorge I Velez wrote: Hi Mark, Try do.call(rbind, tmp[!sapply(tmp, is.null)]) HTH, Jorge On Wed, Aug 31, 2011 at 4:02 PM, Mark Ebbert <> wrote: Dear R gurus, I trying to convert a list of data frames to one

  1   2   >