[R] change the name of file

2006-07-24 Thread Robert Mcfadden
Dear R Users, Is it possible to make file names dependent on a changing variable? For instance. I generate random numbers in a loop and at each iteration I want data to write to file (I do not want to write everything in one file using 'append'): for (i in 1:50){ x-matrix(runif(100,

Re: [R] change the name of file

2006-07-24 Thread Ingmar Visser
Use paste(Data_,i, sep=) From: Robert Mcfadden [EMAIL PROTECTED] Date: Mon, 24 Jul 2006 11:06:38 +0200 To: r-help@stat.math.ethz.ch Subject: [R] change the name of file Dear R Users, Is it possible to make file names dependent on a changing variable? For instance. I generate random

[R] Referring on the value of a counter in a loop

2006-07-24 Thread Chris Kopp
Dear all The following is a very basic and beginner's question on loops. Suppose you have data (say, 1000 cases) with two variables named answer (string) and class (numeric). The latter runs from 1 to 78 and categorizes the data. I need to create a file answer_1.txt for the cases with

Re: [R] change the name of file

2006-07-24 Thread Adaikalavan Ramasamy
Do you mean write.table instead of Write() ? Try fn - paste(Data_, i, .txt, sep=) write.table( t(x), file=fn, sep=\t ) Regards, Adai On Mon, 2006-07-24 at 11:06 +0200, Robert Mcfadden wrote: Dear R Users, Is it possible to make file names dependent on a changing variable? For instance. I

Re: [R] change the name of file

2006-07-24 Thread Johannes Hüsing
Of course file name Data_i.txt will be the same for changing i, unfortunately. ?paste, e.g. paste(Data_, i, .txt, sep=) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide

Re: [R] change the name of file

2006-07-24 Thread Robert Mcfadden
Great, little change and it works. Thank you. Look for (i in 1:50){ x-matrix(runif(100, min=0,max=1),nrow=5,ncol=20) write(t(x),file=paste(data_,i,.txt,sep=),ncolumns=5,sep=\t) } -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, July 24, 2006

Re: [R] change the name of file

2006-07-24 Thread Thilo Kellermann
Dear Robert, maybe (!) the following might do the job: for (i in 1:50){ x-matrix(runif(100, min=0,max=1),nrow=5,ncol=20) Write(t(x),file=paste(Data_ i .txt, sep=),ncolumns=5,sep=\t) } Hope it really does... Thilo On Monday 24 July 2006 11:06, Robert Mcfadden wrote: Dear R Users, Is it

Re: [R] Referring on the value of a counter in a loop

2006-07-24 Thread jim holtman
for (i in 1:78){ write.table(answer[class == i], paste(answer_,i, .txt, sep='')) # if you want the variable assign(paste(k_, i, sep=''), answer[class == i]) } On 7/24/06, Chris Kopp [EMAIL PROTECTED] wrote: Dear all The following is a very basic and beginner's question on

Re: [R] diff, POSIXct, POSIXlt, POSIXt

2006-07-24 Thread Martin Maechler
Gabor == Gabor Grothendieck [EMAIL PROTECTED] on Sun, 23 Jul 2006 09:02:35 -0400 writes: Gabor Moving this to r-devel. [would have been a good idea ... but you didn't; I think it's too late now; rather keep the msg thread together] Gabor Looking at the diff.POSIXt Gabor code

[R] Correlations by group

2006-07-24 Thread Peter J. Lee
I'm aware that S N Krishna asked the same question. However, I have failed to implement the posted solution for running rank order correlations on multiple subsets of data using the by() function. Here is my problem: Take a set of data from two subjects, who provided numerical infant

Re: [R] Can make no plots !!!

2006-07-24 Thread Bernat Claramunt i Lopez
Thank you for your suggestion Phil, but they are already installed... Any other idea, please ? Thanks in advance Bernat A Dijous 20 Juliol 2006 20:22, Phil Spector va escriure: Bernat - Just a guess, but maybe you need to install the packages xfonts-100dpi and

[R] conflict of package Matrix and summary of lme object

2006-07-24 Thread Dirk Enzmann
After loading the package Matrix (version 0.995-12), using the summary function with an lme (package nlme version 3.1-75) object results in an error message saying Fehler in dim(x) : kein Slot des Namens Dim für dieses Objekt der Klasse correlation (translated: 'Error in dim(x) : no slot of

Re: [R] Correlations by group

2006-07-24 Thread Gabor Grothendieck
On 7/24/06, Peter J. Lee [EMAIL PROTECTED] wrote: I'm aware that S N Krishna asked the same question. However, I have failed to implement the posted solution for running rank order correlations on multiple subsets of data using the by() function. Here is my problem: Take a set of data from

[R] Correlations by group

2006-07-24 Thread Peter J. Lee
Many thanks, your solutions solve a number of my problems (not least weening myself off SAS) Best wishes, Peter _ Peter James Lee Assistant Professor Psikoloji Bölümü Bilkent University Bilkent Ankara Turkey 06800 e-mail: [EMAIL PROTECTED] office: (90) 312 290 1807

[R] Plotting league tables/ caterpillar plots

2006-07-24 Thread Eik Vettorazzi
Dear list, I was wondering if there is a function to plot league tables, sometimes also known as caterpillar plots? A league table is conceptually very similar to a box plot. One difference is that the inter-quartile ranges are not shown. If there isn't such a function a first attempt for a

Re: [R] conflict of package Matrix and summary of lme object

2006-07-24 Thread Martin Maechler
Dirk == Dirk Enzmann [EMAIL PROTECTED] on Mon, 24 Jul 2006 13:55:44 +0200 writes: Dirk After loading the package Matrix (version 0.995-12), Dirk using the summary function with an lme (package nlme Dirk version 3.1-75) object results in an error message Dirk saying Dirk

[R] trim function in R

2006-07-24 Thread Wade Wall
Hi all, I am looking for a function in R to trim the last two characters of an 8 character string in a vector. For example, I have the codes 37-079-2, 370079-3,37-079-8 and want to trim them to 37-079 by removing the last two characters. Is sub the correct function to use, and if so how can I

Re: [R] trim function in R

2006-07-24 Thread Gesmann, Markus
See ?substr and ?nchar Try: substr(Hello World, 0, nchar(Hello World)-2) Regards Markus Gesmann FPMA Lloyd's Market Analysis Lloyd's * One Lime Street * London * EC3M 7HA Telephone +44 (0)20 7327 6472 Facsimile +44 (0)20 7327 5718 http://www.lloyds.com -Original Message- From: [EMAIL

[R] (no subject)

2006-07-24 Thread Tauber, Dr E.
Eran Tauber (PhD) Lecturer in Molecular Evolution Dept. of Genetics University of Leicester University Rd, Leicester LE1 7RH England Phone: 44 (0)116 252-3455, 252-3421 (lab) Fax: 44 (0)116 252-3378 www.le.ac.uk/genetics/et22

Re: [R] trim function in R

2006-07-24 Thread Gabor Grothendieck
A . (dot) matches any character and $ matches the end of string so this replaces the last two characters with the empty string: sub(..$, , x) On 7/24/06, Wade Wall [EMAIL PROTECTED] wrote: Hi all, I am looking for a function in R to trim the last two characters of an 8 character string in

[R] Identifying peaks (or offsets) in a time series

2006-07-24 Thread Tauber, Dr E.
Dear R-users, We are monitoring the activity of animals during a few days period. The data from each animal (crossing of infra-red beam) are collected as a time series (in 30 min bins). An example is attached below. y - c(0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,3,28,27,46,76,77,60,19,35,55,59,48

[R] random section of samples based on group membership

2006-07-24 Thread Wade Wall
Hi all, I have a matrix of 474 rows (samples) with 565 columns (variables). each of the 474 samples belong to one of 120 groups, with the groupings as a column in the above matrix. For example, the group column would be: 1 1 1 2 2 2 . . . 120 120 I want to randomly select one from each group.

Re: [R] Identifying peaks (or offsets) in a time series

2006-07-24 Thread Gabor Grothendieck
Try: RSiteSearch(finding peaks) On 7/24/06, Tauber, Dr E. [EMAIL PROTECTED] wrote: Dear R-users, We are monitoring the activity of animals during a few days period. The data from each animal (crossing of infra-red beam) are collected as a time series (in 30 min bins). An example is

[R] grouping by consecutive integers

2006-07-24 Thread Kevin J Emerson
Hello R-helpers! I have a question concerning extracting sequence information from a vector. I have a vector (representing the bins of a time series where the frequency of occurrences is greater than some threshold) where I would like to extract the min, median and max of each group of

Re: [R] grouping by consecutive integers

2006-07-24 Thread Niels Vestergaard Jensen
Look at index vectors in the R intro. Best Niels On Mon, 24 Jul 2006, Kevin J Emerson wrote: Hello R-helpers! I have a question concerning extracting sequence information from a vector. I have a vector (representing the bins of a time series where the frequency of occurrences is

Re: [R] random section of samples based on group membership

2006-07-24 Thread Carlos J. Gil Bellosta
Dear Wade, Say that your groups are groups - sort(sample(1:10, 100, replace = TRUE)) Create a dummy rows - 1:length(groups) Then tapply( rows, groups, function(x) sample(x, 1)) does the trick to select the row numbers you need for your sampling. Sincerely, Carlos J. Gil Bellosta

Re: [R] random section of samples based on group membership

2006-07-24 Thread Mike Nielsen
Well, how you do it might be a matter of taste with respect to how you want the results. You could try using by with sample by(x,x[,3],function(y){y[sample(nrow(y),1),]}) This will return a list with one list element for each sample group. You can the combine the list back into a matrix.

Re: [R] grouping by consecutive integers

2006-07-24 Thread Carlos J. Gil Bellosta
Dear Kevin, Try something like groups - cut( tmp, c(-Inf, which(diff(tmp) 1 ) + 0.5, Inf) ) Sincerely, Carlos J. Gil Bellosta http://www.datanalytics.com http://www.data-mining-blog.com Quoting Kevin J Emerson [EMAIL PROTECTED]: Hello R-helpers! I have a question concerning extracting

Re: [R] grouping by consecutive integers

2006-07-24 Thread Kevin J Emerson
Let me clarify one thing that I dont think I made clear in my posting. I am looking for the max, min and median of the indicies, not of the time series frequency counts. I am looking to find the max, min, and median time of peaks in a time series, so i am looking for the information concerning

[R] unique, but keep LAST occurence

2006-07-24 Thread davidr
?unique says Value: An object of the same type of 'x'. but if an element is equal to one with a smaller index, it is removed. However, I need to keep the one with the LARGEST index. Can someone please show me the light? I thought about reversing the row order twice, but I couldn't

Re: [R] Plotting league tables/ caterpillar plots

2006-07-24 Thread Chris Evans
Eik Vettorazzi sent the following at 24/07/2006 13:04: Dear list, I was wondering if there is a function to plot league tables, sometimes also known as caterpillar plots? A league table is conceptually very similar to a box plot. One difference is that the inter-quartile ranges are not

Re: [R] unique, but keep LAST occurence

2006-07-24 Thread Marc Schwartz (via MN)
On Mon, 2006-07-24 at 12:00 -0500, [EMAIL PROTECTED] wrote: ?unique says Value: An object of the same type of 'x'. but if an element is equal to one with a smaller index, it is removed. However, I need to keep the one with the LARGEST index. Can someone please show me the

Re: [R] Saving R objects

2006-07-24 Thread Nair, Murlidharan T
I explicitly did is this way isoforms-as.vector(rownames(mult.comp$estimate)) estimate-as.vector(mult.comp$estimate) lower-as.vector(mult.comp$conf.int[,1]) upper-as.vector(mult.comp$conf.int[,2]) p.val.raw-as.vector(mult.comp$p.value.raw) p.val.bon-as.vector(mult.comp$p.value.bon)

Re: [R] grouping by consecutive integers

2006-07-24 Thread Berton Gunter
As you do not seem to have received what you consider to be satisfactory reply, here is a function that I **think** does what you want: sequences - function(x,incr = 1) { ix - which(abs(diff(c(FALSE,diff(x) == 1))) ==incr) if(length(ix)%%2)c(ix,length(x)) else ix } This

Re: [R] unique, but keep LAST occurence

2006-07-24 Thread Berton Gunter
Try: largestDF - DF[nrow(DF)- which(!duplicated(rev(DF$t)))+1,] You can then sort this however you like in the usual way. Row names will be preserved. -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA The business of the statistician is to catalyze the scientific

[R] Memory exceeding for split

2006-07-24 Thread Eduardo Dutra de Armas
Hi R-users I'm working with a data.frame of 4 x 10, for which I need to apply the split function. The result is very long and cannot be stored in a variable due to memory exceeding. I've tried to send the result directly to a file through sink(filename) function, but the problem still occurs.

Re: [R] grouping by consecutive integers

2006-07-24 Thread jim holtman
This might work: tmp - c(24,25,29,35,36,37,38,39,40,41,42,43,44,45,46,47,68,69,70,71) # generate breaks group - c(0, cumsum(diff(tmp) != 1)) tapply(tmp, group, summary) $`0` Min. 1st Qu. MedianMean 3rd Qu.Max. 24.00 24.25 24.50 24.50 24.75 25.00 $`1` Min. 1st Qu.

[R] RandomForest vs. bayes svm classification performance

2006-07-24 Thread Eleni Rapsomaniki
Hi This is a question regarding classification performance using different methods. So far I've tried NaiveBayes (klaR package), svm (e1071) package and randomForest (randomForest). What has puzzled me is that randomForest seems to perform far better (32% classification error) than svm and

Re: [R] unique, but keep LAST occurence

2006-07-24 Thread davidr
Thank you, Bert and Mark. I believe Mark's solution works, but it was taking a very long time. Bert's is very fast. My day is saved! David L. Reiner Rho Trading Securities, LLC Chicago IL 60605 312-362-4963 -Original Message- From: Berton Gunter [mailto:[EMAIL PROTECTED] Sent:

[R] (robust) mixed-effects model with covariate

2006-07-24 Thread Giuseppe Pagnoni
Dear all, First of all I apologize if you received this twice: I was checking the archive and I noticed that the text was scrubbed from the message, probably due to some setting in my e-mail program. I am unsure about how to specify a model in R and I thought of asking some advice to the

Re: [R] grouping by consecutive integers: Correction

2006-07-24 Thread Berton Gunter
Sorry, all. My previous post was mixed up. Here's the corrected version: sequences - function(x,incr = 1) { ix - which(abs(diff(c(FALSE,diff(x) == incr))) ==1) if(length(ix)%%2)c(ix,length(x)) else ix } -- Bert Gunter Genentech Non-Clinical Statistics South San

Re: [R] Identifying peaks (or offsets) in a time series

2006-07-24 Thread jim holtman
Here is something that will mark the beginning/end of your sequence. You will have to adjust the low limits and the lengths to fit your requirements. y - c(0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,3,28,27,46,76,77,60,19,35,55,59,48

Re: [R] Saving R objects

2006-07-24 Thread Gabor Grothendieck
out.data.mat can be created compactly using with: out.data.mat - with(mult.comp, cbind(estimate, conf.int, p.value.raw = c(p.value.raw), p.value.bon, p.value.adj) ) On 7/24/06, Nair, Murlidharan T [EMAIL PROTECTED] wrote: I explicitly did is this way

Re: [R] random section of samples based on group membership

2006-07-24 Thread Sebastian Luque
On Mon, 24 Jul 2006 11:18:10 -0400, Wade Wall [EMAIL PROTECTED] wrote: Hi all, I have a matrix of 474 rows (samples) with 565 columns (variables). each of the 474 samples belong to one of 120 groups, with the groupings as a column in the above matrix. For example, the group column would be:

[R] running jobs in background

2006-07-24 Thread Nair, Murlidharan T
Can I run jobs in the background and the check the status of it from time to time in Windows version of R? Thanks ../Murli [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list

Re: [R] unique, but keep LAST occurence

2006-07-24 Thread johan Faux
I have a question about deparse function in R What is the reason that deparse use an argument like width.cutoff ? Why the maximum cutoff is 500? I was manipulating an R formula and used deparse. Since the length of user's formula was greater then 500, my code didnt work. thanks Johan

[R] deparse - width.cutoff

2006-07-24 Thread johan Faux
I have a question about deparse function in R What is the reason that deparse use an argument like width.cutoff ? Why the maximum cutoff is 500? I was manipulating an R formula and used deparse. Since the length of user's formula was greater then 500, my code didnt work. thanks Johan johan

[R] standardized random effects with ranef.lme()

2006-07-24 Thread Dirk Enzmann
Using ranef() (package nlme, version 3.1-75) with an 'lme' object I can obtain random effects for intercept and slope of a certain level (say: 1) - this corresponds to (say level 1) residuals in MLWin. Maybe I'm mistaken here, but the results are identical. However, if I try to get the

Re: [R] RandomForest vs. bayes svm classification performance

2006-07-24 Thread roger bos
I can't add much to your question, being a complete novice at classification, but I have tried both randomForest and SVM and I get better results from randomForest than SVM (even after tuning). randomForest is also much, much faster. I just thought randomForest was a much better algorithm,

Re: [R] Memory exceeding for split

2006-07-24 Thread jim holtman
Here is an example of creating the set of indices (instead of the dataframes) and then using them to compute on some of the values. # create some test data n - 1000 x - data.frame(a=sample(letters[1:5], n, TRUE), b=sample(LETTERS[1:5], n, TRUE), c=sample(1:10, n, 1000)) x.split -

Re: [R] fracdiff

2006-07-24 Thread Melissa Ann Haltuch
Hi Spencer, Thanks for the direction. Yes, I am after the sigma for the estimated variance of the whitened residuals. I'll give your code a try! Cheers, Melissa On Sun, 23 Jul 2006, Spencer Graves wrote: Confidence intervals for the fracdiff parameter estimates shouldn't be too

[R] Overplotting: plot() invocation looks ugly ... suggestions?

2006-07-24 Thread John McHenry
Hi WizaRds, I'd like to overplot UK fuel consumption per quarter over the course of five years. Sounds simple enough? Unless I'm missing something, the following seems very involved for what I'm trying to do. Any suggestions on simplifications? The way I did it is awkward mainly because of

Re: [R] Overplotting: plot() invocation looks ugly ... suggestions?

2006-07-24 Thread Gabor Grothendieck
Try: matplot(levels(data$Quarter), matrix(data$Consumption, 4), type = o) On 7/24/06, John McHenry [EMAIL PROTECTED] wrote: Hi WizaRds, I'd like to overplot UK fuel consumption per quarter over the course of five years. Sounds simple enough? Unless I'm missing something, the following

Re: [R] Overplotting: plot() invocation looks ugly ... suggestions?

2006-07-24 Thread Gabor Grothendieck
And if lattice is ok then try this: library(lattice) xyplot(Consumption ~ Quarter, group = Year, data, type = o) On 7/24/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: Try: matplot(levels(data$Quarter), matrix(data$Consumption, 4), type = o) On 7/24/06, John McHenry [EMAIL PROTECTED]

[R] PCA with not non-negative definite covariance

2006-07-24 Thread Quin Wills
Am I correct to understand from the previous discussions on this topic (a few years back) that if I have a matrix with missing values my PCA options seem dismal if: (1) I don’t want to impute the missing values. (2) I don’t want to completely remove cases with missing values. (3)