Re: [R] clustering in R

2010-05-27 Thread Tal Galili
Hi Ayesha, hclust is a way to go (much better then trying to invent the wheel here). Please add what you used to create: distA And create a sample data set to show us what you did, using dput Best, Tal Contact Details:--- Con

[R] authorization for posting

2010-05-27 Thread Carlos Cano
I would like to post to this list from carloscanogutier...@gmail.com Thanks, Carlos Cano __ 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

[R] Help with ICD9 codes

2010-05-27 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 __ R-help@r-project.org m

[R] Problem loading RGtk2 (iconv.dll)

2010-05-27 Thread Tal Galili
Hello dear R-help list and Michael Lawrence. I wish to use GTK with R. I installed the newest RGtk2 and GTK from: http://sourceforge.net/projects/gladewin32/files/gtk%2B-win32-devel/2.12.9/gtk-dev-2.12.9-win32-2.exe/download on the path: C:\Program Files\Common Files\GTK\2.0\ And followed the ins

[R] Match 2 vectors

2010-05-27 Thread Kang Min
Hi, I have 2 dataframes of unequal length, and I would like to match a factor to them so that both dataframes will have the same number of rows. example: # create the 2 dataframes with unequal length data1 <- data.frame(letters, 1:26)[-c(5,10,19:21),] data2 <- data.frame(letters, 1:26)[-c(6,9,15:

Re: [R] how to create automatically names for vectors in a loop?

2010-05-27 Thread Lukas Schefczyk
Hallo, x=1 while (x<100) { vectorx<- rnorm(100) assign(paste("vector",x,sep=""),vectorx) x=x+1 } ls() HTH Lukas Schefczyk -- From: "Zoppoli, Gabriele (NIH/NCI) [G]" Sent: Friday, May 28, 2010 4:43 AM To: Subject: [R] how to create automa

Re: [R] something like vlookup in R?

2010-05-27 Thread Glen Barnett
Your question is impossible to parse "I would like sort of " ... sort of what? vlookup is an Excel function that returns the value in one column based on a value in another column; by default it finds the index of the largest value in the first column of the table less than the target, and returns

Re: [R] how to create automatically names for vectors in a loop?

2010-05-27 Thread Erik Iverson
Zoppoli, Gabriele (NIH/NCI) [G] wrote: Hi, I want to generate a number of vectors and store them with different names, like this: x=1 while (x<100) { vector#x# = rnorm(100) x=x+1 } where each vector has, at its hand, instead of #x# a number which goes from 1 to 99. How can I do t

[R] how to create automatically names for vectors in a loop?

2010-05-27 Thread Zoppoli, Gabriele (NIH/NCI) [G]
Hi, I want to generate a number of vectors and store them with different names, like this: x=1 while (x<100) { vector#x# = rnorm(100) x=x+1 } where each vector has, at its hand, instead of #x# a number which goes from 1 to 99. How can I do this? Thanks Gabriele Zoppoli, MD Ph.D. F

Re: [R] Wait for keystroke or timeout

2010-05-27 Thread biostatmatt
On Thu, 2010-05-27 at 19:08 -0400, Prof. John C Nash wrote: > I would like to have a function that would wait either until a specified > timeout (in > seconds preferably) or until a key is pressed. I've found such a function > quite useful in > other programming environments in setting up dialogs

Re: [R] vlookup in R?

2010-05-27 Thread Joshua Wiley
Does this do what you are looking for? ### #Create data based off what you provided datasamp <- structure(list(cdf = c(0, 0.00156, 0.0155, 0.053, 0.116, 0.197, 0.288, 0.38, 0.468, 0.548, 0.618, 0.679, 0.732, 0.776, 0.813, 0.844, 0.87, 0.892, 0.91, 0.926, 0.938, 0.949, 0.95

Re: [R] vlookup in R?

2010-05-27 Thread jim holtman
?findInterval On Thu, May 27, 2010 at 9:20 PM, Roslina Zakaria wrote: > Hi R-users, > > I would like to search for the values of seq that match my rand values.  In > excel I will use =VLOOKUP(G2,$E$2:$F$32,2).  For example, for rand=.262 it > will give me approximately seq=120 and rand=0.964293

Re: [R] vlookup in R?

2010-05-27 Thread Joshua Wiley
Hello, I'm trying to figure out exactly what you want. You have data with three columns (cdf, seq, and rand). You want to take a number in column "rand", find the closest match to it in "cdf" and return the value of "seq" for the same row as the closest match in "cdf"? Since you did not fix (i.

[R] clustering in R

2010-05-27 Thread Ayesha Khan
i have a matrix with the following dimensions 136 3 and it looks something like [,1] [,2] [,3] [1,] 402 675 1.802758 [2,] 402 696 1.938902 [3,] 402 699 1.994253 [4,] 402 945 1.898619 [5,] 424 470 1.812857 [6,] 424 905 1.816345 [7,] 470 905 1.871252 [8,

[R] Data frame manipulation

2010-05-27 Thread LCOG1
Hello All, Please consider the following: TotEmp<-c(19,6,1,1,8,44,2,33,48,1) ClusterType<-c("AGF","CNS","OSV","RTL","RTL","TRN","REL","ACC_CLUST","RTL","WHL") Taz<-c(0,0,0,100,100,100,101,101,102,103) AllCtTypes_<-c("AGF","CNS","OSV","RTL","TRN","REL","ACC_CLUST","WHL","ADM_CLUST", "HLH","HLH_C

[R] vlookup in R?

2010-05-27 Thread Roslina Zakaria
Hi R-users,   I would like to search for the values of seq that match my rand values.  In excel I will use =VLOOKUP(G2,$E$2:$F$32,2).  For example, for rand=.262 it will give me approximately seq=120 and rand=0.964293344, seq=460 and etc.   E   F G cdf         seq   rand 0.00E+00    0

[R] something like vlookup in R?

2010-05-27 Thread Roslina Zakaria
Hi r users,   I would like sort of   cdf         seq   rand 0.00E+00    0 0.262123478 1.56E-03    20    0.964293344 1.55E-02    40    0.494827113 5.30E-02    60    0.733726005 1.16E-01    80    0.800408948 1.97E-01    100   0.925748466 2.88E-01    120   0.047578356 3.80E-01    140   0.2660603

[R] simulate time series with various "colors" of noise

2010-05-27 Thread Andy Rominger
Hello, I'm trying to simulate time series with various "colors" of noise to verify some other code I've written. I'm using the fractal package, specifically FDSimulate. I have a detailed question about this particular function, but I'd also be happy to receive any suggestions for other packages,

Re: [R] Wait for keystroke or timeout

2010-05-27 Thread biostatmatt
On Thu, 2010-05-27 at 19:08 -0400, Prof. John C Nash wrote: > I would like to have a function that would wait either until a specified > timeout (in > seconds preferably) or until a key is pressed. I've found such a function > quite useful in > other programming environments in setting up dialo

[R] Suggestion for rm() help file

2010-05-27 Thread Eric Goodwin
It could be useful to add a mention of gc() in the rm() help file. They seem related enough to warrant cross-reference under the "See Also" heading, and this could save a journey through googlespace to a 3rd party site such as http://www.ats.ucla.edu/stat/r/faq/memory_usage_pc.htm Releived to fi

[R] Wait for keystroke or timeout

2010-05-27 Thread Prof. John C Nash
I would like to have a function that would wait either until a specified timeout (in seconds preferably) or until a key is pressed. I've found such a function quite useful in other programming environments in setting up dialogs with users or displaying results, rather like a timed slideshow that

Re: [R] Rprofile: distinguish between Rgui, Rterm, JGR?

2010-05-27 Thread Michael Friendly
Duncan Murdoch wrote: Michael Friendly wrote: [Environment: Win XP, R 2.10.1] In my Rprofile I have startup code to do various things, intended for when I use the Rgui console. Some of these are causing problems in JGR now that I've installed it. How can I test for R running with Rgui to do

Re: [R] 4D Plot

2010-05-27 Thread Mike Prager
On Thu, 27 May 2010 10:42:54 +0200, "Spitzner, Andrea" wrote: >Hello, >I need some help with a 4D-Plot. I can't offer a lot of help, other than to note that There is code for a 4D plot at the R graphics gallery (I am the author) and perhaps looking at that might help. http://addictedtor.free.

Re: [R] How to catch Error Messages in R

2010-05-27 Thread Henrique Dallazuanna
Try this: x <- tryCatch(rnorm(-1), error = c) On Thu, May 27, 2010 at 5:25 PM, wrote: > As we knew, if a function is not used correctly, > an error message will throw/display in R: > > > rnorm(-1) > Error in rnorm(-1) : invalid arguments > > I would like to catch the error message or assign an

Re: [R] How to catch Error Messages in R

2010-05-27 Thread Erik Iverson
?try g...@ucalgary.ca wrote: As we knew, if a function is not used correctly, an error message will throw/display in R: rnorm(-1) Error in rnorm(-1) : invalid arguments I would like to catch the error message or assign an error message to a variable so that I can use them some where else. So

[R] How to catch Error Messages in R

2010-05-27 Thread guox
As we knew, if a function is not used correctly, an error message will throw/display in R: > rnorm(-1) Error in rnorm(-1) : invalid arguments I would like to catch the error message or assign an error message to a variable so that I can use them some where else. So, how to catch error messages in

Re: [R] Peak Over Threshold values

2010-05-27 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of William Dunlap > Sent: Thursday, May 27, 2010 12:24 PM > To: Hutchinson,David [PYR]; Tonja Krueger > Cc: r-help@r-project.org > Subject: Re: [R] Peak Over Threshold values > > He

Re: [R] list of complex objects?

2010-05-27 Thread Peter Langfelder
On Thu, May 27, 2010 at 9:43 AM, William Dunlap wrote: >> -Original Message- >> 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 adjust. > > 'Nonrecursive' vectors (i.e

Re: [R] Peak Over Threshold values

2010-05-27 Thread William Dunlap
Here is another version, loopless, but still a bit clumsy (can the call to which be removed?): f <- function (x = walevel, startThreshhold = 5.45, stopThreshhold = 5.3, plot = TRUE) { stopifnot(startThreshhold > stopThreshhold) isFirstInRun <-

Re: [R] Rprofile: distinguish between Rgui, Rterm, JGR?

2010-05-27 Thread Duncan Murdoch
Michael Friendly wrote: [Environment: Win XP, R 2.10.1] In my Rprofile I have startup code to do various things, intended for when I use the Rgui console. Some of these are causing problems in JGR now that I've installed it. How can I test for R running with Rgui to do some of these things o

[R] Henze-Zirkler in R

2010-05-27 Thread Aurélio Faria
* Hi, Can some help please How to apply Henze*-*Zirkler in R to test *multivariate normality Best regards [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/m

[R] One application of Tcltk2

2010-05-27 Thread Abelian
Dear All I utilize the Tcltk2 to develop a Gui for application. In order to make my function more clearly, i use a function ,tk2notebook, to build several notes for different application. I have studied the example of this function. In the R- help, it provided a example below. tt2 <- tktoplevel()

[R] Packages for ICD9 codes

2010-05-27 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 __ R-help@r-project.org m

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

2010-05-27 Thread Wu Gong
Thank you very much David. I'm sorry for this fault , hope it has not confused Frostygoat. I was clueless of recursive reference and I didn't meet any error when I test the code. So I wonder if there are some useful tips to prevent making this kind of faults:) The revised code is followed. ###

Re: [R] Peak Over Threshold values

2010-05-27 Thread Hutchinson,David [PYR]
Perhaps not elegant, but does the job threshold <- 5.45 meetThreshold <- walevel >= threshold d <- rle(meetThreshold) startPos <- c(1, 1 + cumsum(d$lengths[-length(d$lengths)])) abv <- which(d$values == TRUE) p.o.t <- data.frame() for (i in seq( along = abv ) ) { a <- startPos[abv[i]] b <-

Re: [R] Installation on 64bit redhat linux question

2010-05-27 Thread Marc Schwartz
On May 27, 2010, at 11:51 AM, Paul Geeleher wrote: > Hi all, > > I'm trying to compile R 2.11.0 on a redhat machine, but I'm getting > the following error when I run ./configure: > > checking whether gfortran appends underscores to external names... yes > checking whether gfortran appends extra

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

2010-05-27 Thread Michal Figurski
Actually, I have another problem with the same data - this time with plotting simple KM lines. The dataset is attached. In this excercise I was testing two ways of representing time from the previously attached interval dataset. Here t1 is the "stop" time at the last interval for each patient,

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

2010-05-27 Thread Bert Gunter
Are you using R's search capabilities (to say nothing of Google's)? RSiteSearch("Gompertz", restr="func") brings up several functions/packages that might do what you need. Bert Gunter Genentech Nonclinical Biostatistics -Original Message- From: r-help-boun...@r-project.org [mailto:r

Re: [R] median test

2010-05-27 Thread Frank E Harrell Jr
Please note that the median test is considered obsolete by many, because of its very low power. See the reference below. -Frank @Article{fri00sho, author = {Freidlin, Boris and Gastwirth, Joseph L.}, title ={Should the median test be retired from general use?}

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

2010-05-27 Thread David Winsemius
On May 27, 2010, at 12:32 PM, Frostygoat wrote: Thanks very much David. Bert, I've seen the Survival package and it survival ... correct capitalization is important in R. does not do what I need, which is to fit Gompertz curves to survival data and compute lifetable statistics for other f

[R] Installation on 64bit redhat linux question

2010-05-27 Thread Paul Geeleher
Hi all, I'm trying to compile R 2.11.0 on a redhat machine, but I'm getting the following error when I run ./configure: checking whether gfortran appends underscores to external names... yes checking whether gfortran appends extra underscores to external names... no checking whether mixed C/Fortr

Re: [R] list of complex objects?

2010-05-27 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Peter Langfelder > Sent: Wednesday, May 26, 2010 11:06 PM > To: r-help@r-project.org > Subject: Re: [R] list of complex objects? > > Simply keep track of the next free component,

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

2010-05-27 Thread Frostygoat
Thanks very much David. Bert, I've seen the Survival package and it does not do what I need, which is to fit Gompertz curves to survival data and compute lifetable statistics for other functions. There is the SSgompertz package for growth curves, not what I need either. ___

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

2010-05-27 Thread Michal Figurski
Well, I am very proud of myself. Here is something to help you. The dataset is attached, with "anonymized" column names. The code to reproduce the error is below: library(rms) d <- datadist(x) options(datadist="d") f <- cph(Surv(start,stop,status)~P1*P2 + P3, data=x, x=T, y=T, surv=T) plot(Pre

Re: [R] Linear Discriminant Analysis in R

2010-05-27 Thread cobbler_squad
Joris, You are a life saver. Based on two sample files above, I think lda should go something like this: vowel_features <- read.table(file = "mappings_for_vowels.txt") mask_features <- data.frame(as.matrix(read.table(file = "3dmaskdump_ICA_37_Combined.txt"))) G <- vowel_features[15] cvc_lda <-

Re: [R] median test

2010-05-27 Thread Joshua Wiley
Hello Linda, The "problem" is actually the median of your data. What the function median.test() does first is combine both groups. Look at this: median(c(group1, group2)) the median is 1, but the lowest value of the groups is also 1. So when the function does the logical check z < m where z =

[R] PROBLEM SOLVED: how to extract the 1st field from a vector of strings

2010-05-27 Thread mauede
-Messaggio originale- Da: mau...@alice.it Inviato: gio 27/05/2010 16.37 A: r-h...@stat.math.ethz.ch Oggetto: how to extract the 1st field from a vector of strings I have the following vector of strings (shown only the first 3 elements) > desc[1:3] [1] "hsa-let-7a MIMAT062 Homo sapi

Re: [R] Apply: Output matrix orientation

2010-05-27 Thread David Winsemius
On May 27, 2010, at 7:24 AM, Johannes Graumann wrote: Hi, Why is the result of below "apply" call rotated with respect to the input and how to remedy this? Because the processing you requested is with respect to rows and the construction of matrices is by default by columns. ?t Th

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

2010-05-27 Thread Ulrich Bodenhofer
> > What do you suggest in order to assign a new observation to a determined > cluster? > As I mentioned already, I would simply assign the new observation to the cluster to whose exemplar the new observation is most similar to (in a knn1-like fashion). To compute these similarities, you can use t

[R] median test

2010-05-27 Thread linda Porz
Hi all, I have found the following function online median.test<-function(y1,y2){ z<-c(y1,y2) g <- rep(1:2, c(length(y1),length(y2))) m<-median(z) fisher.test(zhttp://www.mail-archive.com/r-help@r-project.org/msg95278.html I have the following data > group1 <- c(2, 2, 2, 1, 4, 3, 1, 1) >

[R] LDA with unstandardized discriminant functions

2010-05-27 Thread Samuel Royer Tardif
Hi, I am currently performing a LDA on soil fatty acid compositions (68 sites, 19 FAs). However, because FAs abundance is caculated in mol% (the molar amount of each FA divided by total molar amount of FAs in the sample), I would like to get unstandardized discriminant functions computed on

[R] bigmemory unable to find an inherited method

2010-05-27 Thread Anthony Fox
I am experiencing a problem trying to use a method from the bigmemory. Specifically, I am using attach.big.matrix but the problem manifests when trying to call attach.resource. My environment is as follows: > sessionInfo() R version 2.10.1 (2009-12-14) x86_64-pc-linux-gnu locale: [1] LC_CTYPE=

Re: [R] how to extract the 1st field from a vector of strings

2010-05-27 Thread Henrique Dallazuanna
Try this: gsub(" MIMA.*", "\\1", desc) On Thu, May 27, 2010 at 11:37 AM, wrote: > I have the following vector of strings (shown only the first 3 elements) > > > desc[1:3] > [1] "hsa-let-7a MIMAT062 Homo sapiens let-7a" > [2] "hsa-let-7a* MIMAT0004481 Homo sapiens let-7a*" > [3] "hsa-let-7a

Re: [R] shapiro.test

2010-05-27 Thread Greg Snow
Others pointed out that the error message is due to ozon being a data frame, but I think the true source of confusion comes a bit earlier. You really need to understand more about data objects and the search path. You first read in a table and name it tab1. Then you attach tab1 to the search p

[R] how to extract the 1st field from a vector of strings

2010-05-27 Thread mauede
I have the following vector of strings (shown only the first 3 elements) > desc[1:3] [1] "hsa-let-7a MIMAT062 Homo sapiens let-7a" [2] "hsa-let-7a* MIMAT0004481 Homo sapiens let-7a*" [3] "hsa-let-7a-2* MIMAT0010195 Homo sapiens let-7a-2*" > is.vector(desc) [1] TRUE > A <- unlist(strs

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

2010-05-27 Thread Terry Therneau
> but 'plot(Predict(f, time=3))' throws an error: > "Error in summary.survfit(g, print.it = FALSE, times = times) : >object 'n.enter' not found" Congratulations! You just discovered a new, never-before-encountered bug in the survival package. I should have a repair posted to Rforge by the e

Re: [R] Methods to explore R data structures

2010-05-27 Thread Greg Snow
The TkListView function in the TeachingDemos package is an interactive tool for looking at the structure and contents of lists and other objects. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 > -Original Message- > Fro

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

2010-05-27 Thread Christian Hennig
Christian wrote: and the implement nearest neighbours classification myself if I needed it. It should be pretty straightforward to implement. Do you intend modify the code of the knn1() function by yourself? No; if you understand what the nearest neighbours method does, it's not very compl

Re: [R] help calculating variable based on factor level of another

2010-05-27 Thread Joshua Wiley
Sorry that last bit of code was redundant, it should be: x2 <- ifelse(x1=="social and cultural specialists", "1", "0") ifelse() leaves NAs by default so no need to manually do it. On Thu, May 27, 2010 at 7:30 AM, Joshua Wiley wrote: > Dear Simon, > > It is a bit hard to tell what you want witho

Re: [R] help calculating variable based on factor level of another

2010-05-27 Thread Joshua Wiley
Dear Simon, It is a bit hard to tell what you want without a reproducible example, below is my guess. I created x1 as a factor with some data in it based off of what I think you are working with and then x2 from x1. data <- c("social and cultural specialists", "l

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

2010-05-27 Thread abanero
Ulrich wrote: >Affinity propagation produces quite a number of clusters. I tried with q=0 and produces 17 clusters. Anyway that's a good idea, thanks. I'm looking to test it with my dataset. So I'll probably use daisy() to compute an appropriate dissimilarity then apcluster() or another meth

Re: [R] help calculating variable based on factor level of another

2010-05-27 Thread Ivan Calandra
Hi, I'm really confused about your question. For many reasons: - because I'm a beginner myself? - what are you trying to do with x1? You define the levels of x1, but you don't give any values to it. Which could (also) explain why your code does not work - your if...else statement is weird for m

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

2010-05-27 Thread David Winsemius
On May 27, 2010, at 12:42 AM, Wu Gong wrote: 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) In standard actuarial parlance one would use lower case p_x for that quantity and wo

[R] help calculating variable based on factor level of another

2010-05-27 Thread Simon Kiss
Dear colleagues, I want to calculate the value of x2 based on the value of x1. x1 is a factor with three separate levels. I want to make sure that missing values remain as NA in X2, but non-missing values take on a value of either 0 or 1 dependending on the value in x1. This is the code I'm wo

[R] Rprofile: distinguish between Rgui, Rterm, JGR?

2010-05-27 Thread Michael Friendly
[Environment: Win XP, R 2.10.1] In my Rprofile I have startup code to do various things, intended for when I use the Rgui console. Some of these are causing problems in JGR now that I've installed it. How can I test for R running with Rgui to do some of these things only there? -- Michael Fr

[R] library installation problem, invalid regular expression in help indices

2010-05-27 Thread Rainer Machne
Hi, I have a strange package installation problem after update to R 2.11.0 on Fedora Core 12. A colleague of mine with the very same Fedora and R versions doesn't have this problem, while logging on to his computer but installing from my settings and into my local library path also shows the prob

Re: [R] Apply: Output matrix orientation

2010-05-27 Thread Hadley Wickham
Use aaply from the plyr package. Hadley On Thu, May 27, 2010 at 6:24 AM, Johannes Graumann wrote: > Hi, > > Why is the result of below "apply" call rotated with respect to the input > and how to remedy this? > > Thanks, Joh > > .ZScore <- function(input){ >  #cat(input,"\n") >  z <- (input - mea

Re: [R] Methods to explore R data structures

2010-05-27 Thread Martin Morgan
On 05/27/2010 02:13 AM, Timothy Wu wrote: > Hi, > > I'm very confused about R structures and the methods to go with them. > I'm using R for microarray analysis with Bioconductors. Suppose > without reading the documentations, what's the best way to explore a > data structure when you know nothing a

Re: [R] Survival analysis extrapolation

2010-05-27 Thread Terry Therneau
A few suggestions 1. Use the data argument wfit <- survreg(Surv(Time, Status) ~ Treatment, data=survdata) summary(wfit) 2. Use the predict function to look at your survival curve. This avoids any parameter change mistakes. It also works for any distribution. pp <- 0:60/100 wsurv <-

Re: [R] switch function

2010-05-27 Thread arnaud Gaboury
Thanks to Joris, this line does what I want : trades$Buy.Sell..Cleared.[which(trades$Trade.Status=="DEL")] <- sapply(trades$Buy.Sell..Cleared.[which(trades$Trade.Status=="DEL")], switch,Sell="Buy",Buy="Sell") > -Original Message- > From: jim holtman [mailto:jholt...@gmail.com] >

Re: [R] switch function

2010-05-27 Thread jim holtman
try this: > toBuy <- trades$Trade.Status == "DEL" & trades$Buy.Sell..Cleared. == "Sell" > toSell <- trades$Trade.Status == "DEL" & trades$Buy.Sell..Cleared. == "Buy" > x <- trades # make a copy to change > x$Buy.Sell..Cleared.[toBuy] <- "Buy" > x$Buy.Sell..Cleared.[toSell] <- "Sell" > x Trade.S

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

2010-05-27 Thread Ulrich Bodenhofer
Sorry, Joris, I overlooked that you already mentioned daisy() in your posting. I should have credited your recommendation in my previous message. Cheers, Ulrich -- View this message in context: http://r.789695.n4.nabble.com/cluster-analysis-and-supervised-classification-an-alternative-to-knn1-t

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

2010-05-27 Thread Ulrich Bodenhofer
> > I had a look at the documentation of the package apcluster. > That's interesting but do you have any example using it with both > categorical > and numerical variables? I'd like to test it with a large dataset.. > Your posting has opened my eyes: problems where both numerical and categorical f

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

2010-05-27 Thread Joris Meys
I'm confusing myself :-) randomForest cannot handle character vectors as predictors. (Which is why I, to my surprise, found out that a categorical variable could not be used in the function). It can handle categorical variables as predictors IF they are put in as a factor. Obviously they handle c

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

2010-05-27 Thread Joris Meys
Hi Abanero, first, I have to correct myself. Knn1 is a supervised learning algorithm, so my comment wasn't completely correct. In any case, if you want to do a clustering prior to a supervised classification, the function daisy() can handle any kind of variable. The resulting distance matrix can b

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

2010-05-27 Thread abanero
Hi, thank you Joris and Ulrich for you answers. Joris Meys wrote: >see the library randomForest for example I'm trying to find some example in randomForest with categorical variables but I haven't found anything. Do you know any example with both categorical and numerical variables? Anyway I

[R] Apply: Output matrix orientation

2010-05-27 Thread Johannes Graumann
Hi, Why is the result of below "apply" call rotated with respect to the input and how to remedy this? Thanks, Joh .ZScore <- function(input){ #cat(input,"\n") z <- (input - mean(input))/sd(input) return(z) } apply(data.frame(x1=c(1,2,3,4,5),x2=c(2,3,4,5,6),x3=c(3,4,5,6,7)),1,.ZScore) __

Re: [R] switch function

2010-05-27 Thread arnaud Gaboury
Maybe should I be more precise. Here is what I have : trades <- 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, 1

Re: [R] stripplot, lattice

2010-05-27 Thread Kay Cichini
...layout=..., of course. - Kay Cichini Postgraduate student Institute of Botany Univ. of Innsbruck -- View this message in context: http://r.789695.n4.nabble.com/stripplot-lattice-tp2232908p2232959.html Sent from the R help mailing list

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

2010-05-27 Thread arnaud Gaboury
Sorry Joris, but I am totally lost on this issue!! >tradenews<-sapply(trades$Buy.Sell..Cleared[which(trades$Trade.Status=="DEL" )],switch,Sell="Buy",Buy="Sell") > tradenews Sell "Buy" Not really what I want !! From: Joris Meys [mailto:jorism...@gmail.com] Sent: Thursday, May 27, 2010 10:38

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

2010-05-27 Thread arnaud Gaboury
Maybe should I be more precise. Here is what I have : trades <- 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

[R] 4D Plot

2010-05-27 Thread Spitzner, Andrea
Hello, I need some help with a 4D-Plot. Here is my code: Lab.palette <- colorRampPalette(c("blue","turquoise","green","yellow","orange","red","violet"),space = "Lab") par(las=3,omi=c(0.8,0.1,0.1,0.1)) filled.contour(x,log10(y),log10(z=daten),col=Lab.palette(27),zlim = c(0,max(log10(daten))),p

Re: [R] RWinEdt

2010-05-27 Thread Yves Aragon
I had the problem with WinEdt 5.x but I have seen R.ini was placed at the installation in another directory ; I moved it to the right place. And it works. Thanks, Yves -Message d'origine- De : Meyners, Michael [mailto:meyner...@pg.com] Envoyé : jeudi 27 mai 2010 08:05 À : Yves Aragon; r

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

2010-05-27 Thread Alistair Auffret
Thanks a lot Joris, that worked wonderfully! Another solution which a colleague at the department came up with was this, which avoids curly brackets, which some people may or may not be frightened by... ##matrices bank.plot<-matrix(,5,3,dimnames=list(c("AB 01 01", "AB 01 02", "AB 02 01","AB 03

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

2010-05-27 Thread Christian Hennig
Dear abanero, In principle, k nearest neighbours classification can be computed on any dissimilarity matrix. Unfortunately, knn and knn1 seem to assume Euclidean vectors as input, which restricts their use. I'd probably compute an appropriate dissimilarity between points (have a look at Gowe

Re: [R] R and ATLAS

2010-05-27 Thread Dirk Eddelbuettel
On 26 May 2010 at 20:29, Jonathan Greenberg wrote: | 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/bi

[R] stripplot, lattice

2010-05-27 Thread Kay Cichini
hello, i can't figure out how to set position of panels of my stripplot - i`d like the panels of one level of the factor stage (nr. of panels within each stage, A: 12, B: 12, C: 12, D: 4, each panel representing a site) to be in one column, with A to D from left to right and with descending site

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

2010-05-27 Thread Ulrich Bodenhofer
abanero wrote: > > Do you know something like “knn1” that works with categorical variables > too? > Do you have any suggestion? > There are surely plenty of clustering algorithms around that do not require a vector space structure on the inputs (like KNN does). I think agglomerative clustering w

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

2010-05-27 Thread ONKELINX, Thierry
Dear Faiz, Maybe the xtable package can be helpfull for you. It adds markup tags to a table. You can choose between LaTeX and HTML. Microsoft can open HTML files. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuu

Re: [R] glm.diag

2010-05-27 Thread Stephan Kolassa
Hi Helga, did you load the boot library, which contains glm.diag(), by calling library(boot)? HTH Stephan Helga margrete holmestad schrieb: I have made a poisson regression by using glm. Then I want to check if I have over-dispersion in my model. I tried to use glm.diag(fit.1), but then R

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

2010-05-27 Thread Faiz Rasool
I should thank members of R community who have engaged in a lengthy discussion on making R's output easier to handle for Blinds. Since my email started all the discussion, I feel I should clarify what exactly I needed, and in my opinion what can make things easier for Blind users of R. I a

Re: [R] adding column to data frame conditionally

2010-05-27 Thread Stephan Kolassa
Hi Kristina, Thierry's solution is certainly the "correct" one in terms of keeping within R's philosophy... but I personally find a series of conditional assignments easier to understand - see below for an example. HTH, Stephan # # Example

Re: [R] adding column to data frame conditionally

2010-05-27 Thread Kristina Schmitz
Dear Thierry, thank you so much! Quoting "ONKELINX, Thierry" : Dear Kristina, Use ifelse(). Note that you must use '==' to test for equality. '=' is an assignment. Freqg$condition <- with(freqg, ifelse(mat==1 & flank==1, 1, ifelse(mat == 2 & flank == 1, 2, NA))) HTH, Thierry -

[R] glm.diag

2010-05-27 Thread Helga margrete holmestad
I have made a poisson regression by using glm. Then I want to check if I have over-dispersion in my model. I tried to use glm.diag(fit.1), but then R told me it couldn't find the function glm.diag. Does anybody know why? Or is there an other methode to check if there is over-dispersion in my

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

2010-05-27 Thread Gabor Grothendieck
On Wed, May 26, 2010 at 10:51 PM, Gabor Grothendieck wrote: > 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 3

Re: [R] adding column to data frame conditionally

2010-05-27 Thread ONKELINX, Thierry
Dear Kristina, Use ifelse(). Note that you must use '==' to test for equality. '=' is an assignment. Freqg$condition <- with(freqg, ifelse(mat==1 & flank==1, 1, ifelse(mat == 2 & flank == 1, 2, NA))) HTH, Thierry ir.

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

2010-05-27 Thread Joris Meys
Ah, OK. sapply -evidently- only gives an output for every case that goes in. Which is only one, as there is only one DEL case. You can use that output to change the corresponding value in the dataframe, like : tradenews <- trades tradenews$Buy.Sell..Cleared.[which(trades$Trade.Status=="DEL")] <-

[R] adding column to data frame conditionally

2010-05-27 Thread Kristina Schmitz
Dear all and thanks in advance for helping me with a rather stupid question: I imported a data set ("freqg") into R consisting of 14 variables. Now a want to compute a variable and add it in an additional column to my data frame. The value of this new variable ("condition") depends on the va

[R] leave-one-out cross validation

2010-05-27 Thread azam jaafari
Hi   I did leave-one-out cross validation in R for prediction error of logistic regression by cv.glm. But I don't know what are the produced data? does delta show me error estimation?   please help me    Thanks alot     --- On Wed, 5/26/10, Joris Meys wrote: From: Joris Meys Subject: Re: [R

Re: [R] shapiro.test

2010-05-27 Thread Stephan Kolassa
Hi, David Winsemius schrieb: This would imply that ozon is a list or dataframe. And you tried to give the whole list to a function that only wants a vector. And whenever you suspect that your data types clash, try str() to find out just what kind of thing your data is. Here: str(ozon)

  1   2   >