[R] Legend and Main Title positioning

2008-12-05 Thread Antje
Hi folks, can anybody give me a hint how to solve the following problem? I have several plots in one window like this: layout(matrix(c(1,2,3,4), nrow = 2, byrow = TRUE)) plot(rnorm(100)) plot(rnorm(200)) plot(rnorm(300)) plot(rnorm(400)) Now, I'd like to create a legend below each plot and

[R] complex(?) reshaping question

2008-12-05 Thread Lauri Nikkinen
Hello, I have a problem with data reshaping. Here's my data DF - structure(list(idvar1 = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c(patient1, patient2 ), class = factor), idvar2 = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L), .Label =

Re: [R] setwd and list.files / linux

2008-12-05 Thread Lars Beckmann
Hey Marc, sorry I forgot to mention it. I am the owner of the path, which is in my home directory. I can change the read/write/execute privileges. All users have - at least - read privileges for all files and the directory: hpc36 40: ls -la *.tped -rw-r--r-- 1 cremer C020 205487231 Dec 3

[R] help needed

2008-12-05 Thread gauravbhatti
I need some help in comparing t values avalaible from two data frames. I have two data frames with each containing a column for t valuse For example one data frame looks like as follows IDlogFCt P.Value adj.P.Val B 39 a39 -1.737037118

Re: [R] help needed

2008-12-05 Thread Jim Lemon
gauravbhatti wrote: ... I have to plot the t values obtained for each id against each other. Since the order of the IDs in the two data frames is different , I am finding it difficult to plot the t values. Can anyone help in arranging the t values in the increasing order of the ID values like

[R] Seasonality in time series

2008-12-05 Thread Matthias
Hi, I?m looking for a package which includes a test for seasonality in time series. Any help and input would be greatly appreciated. Thanks, Matthias __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the

Re: [R] Changing 'record' option in open graphics device

2008-12-05 Thread Prof Brian Ripley
On Thu, 4 Dec 2008, Andrew Hooker wrote: Hi, I am wondering if there is a way to change the value of the record option in a graphics device that is already open (and accepts this option). I don't want to open a new device with, for example dev.new(record=T), but just want to change the

[R] Lexical Permutation Algorithm in R

2008-12-05 Thread Rory.WINSTON
Hi all Here is a rather naive implementation of the SEPA algorithm for generating lexical permutations: lexperm3 - function(x, n=length(x)) { perms - list() k - 1 perms[[k]] - x k - k + 1 for (y in 1:(factorial(n)-1)) { i - n-1 while (x[i] x[i+1] i 0) { i - i - 1 } # i is

Re: [R] Seasonality in time series

2008-12-05 Thread GR
Here's something that may help you get started: library(ts) ?decompose ?stl Thanks, -Girish On Dec 5, 1:55 pm, Matthias [EMAIL PROTECTED] wrote: Hi, I?m looking for a package which includes a test for seasonality in time series. Any help and input would be greatly appreciated. Thanks,

Re: [R] Strplit code

2008-12-05 Thread John Fox
Dear Wacek, I've thought a bit more about this problem, and recall that I originally wrote Strsplit() [and replacements for sub() and gsub(), which were not then in S-PLUS] for the version of the car package that I released for S-PLUS, because other functions in the package used these. The

Re: [R] Lexical Permutation Algorithm in R

2008-12-05 Thread Robin Hankin
Rory there are several packages that perform this. I would use permn() of the combinat library, then, if lexicographical order is important, sort it explicitly. HTH rksh [EMAIL PROTECTED] wrote: Hi all Here is a rather naive implementation of the SEPA algorithm for generating lexical

Re: [R] Strplit code

2008-12-05 Thread Wacek Kusnierczyk
John Fox wrote: Dear Wacek, I've thought a bit more about this problem, and recall that I originally wrote Strsplit() [and replacements for sub() and gsub(), which were not then in S-PLUS] for the version of the car package that I released for S-PLUS, because other functions in the package

[R] constructing a relative path

2008-12-05 Thread Mark Heckmann
Dear R-users, I want to construct a relative path in R, but I am not able to do it or to find a function that does it. My solution is somewhat awkward as it uses string manipulation. The problem: I have the following folder structure. project_folder | |- data |-

Re: [R] constructing a relative path

2008-12-05 Thread Prof Brian Ripley
On Fri, 5 Dec 2008, Mark Heckmann wrote: Dear R-users, I want to construct a relative path in R, but I am not able to do it or to find a function that does it. My solution is somewhat awkward as it uses string manipulation. The problem: I have the following folder structure. project_folder

[R] Trouble with gridBase and inset plots

2008-12-05 Thread Lorenzo Isella
Dear All, I ma having a trouble in generating a figure containing 3 insets with the gridBase package. I always get an error message of the kind: Error in gridPLT() : Figure region too small and/or viewport too large No matter which parameters I choose. The plots works nicely with two insets

[R] Logical inconsistency

2008-12-05 Thread emma jane
Dear colleagues Please could someone kindly explain the following inconsistencies I've discovered when performing logical calculations in R: 8.8 - 7.8 1 TRUE 8.3 - 7.3 1 TRUE Thank you, Emma Jane [[alternative HTML version deleted]]

Re: [R] Logical inconsistency

2008-12-05 Thread Chuck Cleland
On 12/5/2008 7:23 AM, emma jane wrote: Dear colleagues Please could someone kindly explain the following inconsistencies I've discovered when performing logical calculations in R: 8.8 - 7.8 1 TRUE 8.3 - 7.3 1 TRUE See R FAQ 7.31

Re: [R] Logical inconsistency

2008-12-05 Thread Berwin A Turlach
Dear Emma, On Fri, 5 Dec 2008 04:23:53 -0800 (PST) emma jane [EMAIL PROTECTED] wrote: Please could someone kindly explain the following inconsistencies I've discovered__when performing logical calculations in R: 8.8 - 7.8 1 TRUE 8.3 - 7.3 1 TRUE Gladly: FAQ 7.31

[R] How to retrieve a method

2008-12-05 Thread Christian Hoffmann
Hi there, I am interested in the inner workings of wilcox.test: wilcox.test function (x, ...) UseMethod(wilcox.test) environment: namespace:stats how can I get at the code, if it is R-code? For Methods one should be able to learn what extension to use, but here default or such do not help.

[R] levels update

2008-12-05 Thread Antje
Hello, I hope this question is not too stupid. I would like to know how to update levels after subsetting data from a data.frame. df - data.frame(factor(c(a,a,c,b,b)), c(4,5,6,7,8), c(9,1,2,3,4)) names(df) - c(X1,X2,X3) my.sub - subset(df, X1 == a | X1 == b) levels(my.sub$X1) # still gives

[R] Quantile Regression for longitudinal data

2008-12-05 Thread axionator
Hi all, does anybody know about R implementations for quantile regression for longitudinal data? I am just aware of a very basic version of R. Koenker's approach using fixed effects. Thanks in advance Armin __ R-help@r-project.org mailing list

[R] Comparing survival curves with survdiff strata help

2008-12-05 Thread Richardson, Patrick
ExpeRts, I'm trying to compare three survival curves using the function survdiff in the survival package. Following is my code and corresponding error message. survdiff(Surv(st_months, status) ~ strata(BOR), data=mydata) Error in survdiff(Surv(st_months, status) ~ strata(BOR), data = mydata) :

Re: [R] levels update

2008-12-05 Thread jim holtman
try this: df - data.frame(factor(c(a,a,c,b,b)), c(4,5,6,7,8), c(9,1,2,3,4)) names(df) - c(X1,X2,X3) my.sub - subset(df, X1 == a | X1 == b) levels(my.sub$X1) [1] a b c my.sub$X1 - factor(my.sub$X1) levels(my.sub$X1) [1] a b On Fri, Dec 5, 2008 at 7:50 AM, Antje [EMAIL PROTECTED] wrote:

Re: [R] complex(?) reshaping question

2008-12-05 Thread hadley wickham
I'm trying to omit NA:s in this DF and produce a reduced DF. The problem is that I cannot completely omit NA rows. I tried library(reshape) g - melt(DF, id=c(idvar1, idvar2)) g - na.omit(g) You're missing an id variable: DF$idvar3 - 1:2 g - melt(DF, id=c(idvar1, idvar2, idvar3), na.rm =

Re: [R] levels update

2008-12-05 Thread Erich Neuwirth
I do the following for a subsetted dataframe: cleanfactors - function(mydf){ outdf-mydf for (i in 1:dim(mydf)[2]){ if (is.factor(mydf[,i])) outdf[,i]-factor(mydf[,i]) } outdf } Antje wrote: Hello, I hope this question is not too stupid. I would like to know how to update levels

Re: [R] How to retrieve a method

2008-12-05 Thread Prof Brian Ripley
On Fri, 5 Dec 2008, Christian Hoffmann wrote: Hi there, I am interested in the inner workings of wilcox.test: wilcox.test function (x, ...) UseMethod(wilcox.test) environment: namespace:stats how can I get at the code, if it is R-code? For Methods one should be able to learn what

Re: [R] levels update

2008-12-05 Thread hadley wickham
On Fri, Dec 5, 2008 at 6:50 AM, Antje [EMAIL PROTECTED] wrote: Hello, I hope this question is not too stupid. I would like to know how to update levels after subsetting data from a data.frame. df - data.frame(factor(c(a,a,c,b,b)), c(4,5,6,7,8), c(9,1,2,3,4)) names(df) - c(X1,X2,X3) my.sub

Re: [R] levels update

2008-12-05 Thread Prof Brian Ripley
On Fri, 5 Dec 2008, jim holtman wrote: try this: df - data.frame(factor(c(a,a,c,b,b)), c(4,5,6,7,8), c(9,1,2,3,4)) names(df) - c(X1,X2,X3) my.sub - subset(df, X1 == a | X1 == b) levels(my.sub$X1) [1] a b c my.sub$X1 - factor(my.sub$X1) I find my.sub$X1 - my.sub$X1[drop=TRUE] a lot more

Re: [R] Logical inconsistency

2008-12-05 Thread Wacek Kusnierczyk
Berwin A Turlach wrote: Dear Emma, On Fri, 5 Dec 2008 04:23:53 -0800 (PST) emma jane [EMAIL PROTECTED] wrote: Please could someone kindly explain the following inconsistencies I've discovered__when performing logical calculations in R: 8.8 - 7.8 1 TRUE 8.3 - 7.3 1

[R] Cartesian Product Of Character Vectors

2008-12-05 Thread Rory.WINSTON
Hi all (I'm sure this question has been asked before, but I cant find it). If I have two character vectors: x - c(aaa,bbb,ccc) y - c(1,2,3) How can I get the cartesian product of the string values? expand.grid(x,y) Gives me a data frame with separate columns...however, I cant seem to get

[R] Loop swith String replacement

2008-12-05 Thread Michael Pearmain
Hi All, I'm trying to split my dataset, into multiple datasets that i'll analyse later, i wanted to do this dynamically as i might need to rerun the code later. I was looking at doing this via a loop, (Are other methods more appropriate? Would a function be better?) However i'm not sure in R how

[R] Changing order of x factor in interaction plot

2008-12-05 Thread Kota Hattori
Hi all, I would like to ask one simple question. I wanna know how you can ask R to change the order of x factor when you draw interaction plot. I find that R puts factors in an alphabetic order (e.g., dog, lamb, and monkey etc). But I simply want to control the order. How can I do this? Aloha,

Re: [R] Changing order of x factor in interaction plot

2008-12-05 Thread jim holtman
Check out the 'levels' option on 'factor' On Fri, Dec 5, 2008 at 8:32 AM, Kota Hattori [EMAIL PROTECTED] wrote: Hi all, I would like to ask one simple question. I wanna know how you can ask R to change the order of x factor when you draw interaction plot. I find that R puts factors in an

[R] legend at fixed distance form the bottom

2008-12-05 Thread Christophe Genolini
Hi the list I would like to add a legend under a graph but at a fixed distance from the graphe. Is it possible ? More precisely, here is my code : --- 8 symboles - c(3,4,5,6) dn - rbind(matrix(rnorm(20),,5),matrix(rnorm(20,2),,5)) listSymboles - rep(symboles,each=2)

Re: [R] How to get Greenhouse-Geisser epsilons from anova?

2008-12-05 Thread Skotara
Dear Mr. Daalgard. thank you very much for your reply, it helped me to progress a bit. The following works fine: dd - expand.grid(C = 1:7, B= c(r, l), A= c(c, f)) myma - as.matrix(myma) #myma is a 12 by 28 list mlmfit - lm(myma~1) mlmfit0 - update(mlmfit, ~0) anova(mlmfit, mlmfit0, X= ~C+B, M =

[R] applying a function several times

2008-12-05 Thread Carlos Cuartas
I am sorry. I am not sure if the mail a send before to this list was rejected because of header (subject). I've changed it. The first maybe was not appropriate. I did a function (sec_conop) whose arguments are syndic, well and wellconop.

Re: [R] Legend and Main Title positioning

2008-12-05 Thread Richard . Cotton
layout(matrix(c(1,2,3,4), nrow = 2, byrow = TRUE)) plot(rnorm(100)) plot(rnorm(200)) plot(rnorm(300)) plot(rnorm(400)) Now, I'd like to create a legend below each plot and generate a common title. How can I do that? If you are laying plots out in grids like this then lattice graphics

Re: [R] comparing SAS and R survival analysis with time-dependent covariates

2008-12-05 Thread Terry Therneau
This query of why do SAS and S give different answers for Cox models comes up every so often. The two most common reasons are that a. they are using different options for the ties b. the SAS and S data sets are slightly different. You have both errors. First, make sure I have

Re: [R] Plotting a kriging on a map

2008-12-05 Thread Jon Loehrke
Rodrigo, This is an old and quite basic Krig, my data was continuous measurements in lat, long so binned first. library(geoR) counts-bins2d(long, lat,bin=c(0.1,0.1),plot=FALSE, nlevels=15, color.palette=heat.colors, xaxs='i', yaxs='i', las=1, main='') countsgeo-as.geodata(counts)

[R] determine assortative mixing in networks (igraph-library)

2008-12-05 Thread Rainer Tischler
Dear all, I'm looking for a method to quantify assortative mixing in undirected graphs, preferably something that is compatible with the igraph-library for network analysis. Is anybody aware of an already existing function/library for this or an easy way to implement this functionality in R?

Re: [R] Cartesian Product Of Character Vectors

2008-12-05 Thread David Winsemius
Does this satisfy? levels(interaction(x,y)) [1] aaa.1 bbb.1 ccc.1 aaa.2 bbb.2 ccc.2 aaa.3 bbb.3 ccc.3 -- David Winsemius On Dec 5, 2008, at 8:12 AM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi all (I'm sure this question has been asked before, but I cant find it). If I have two

Re: [R] Cartesian Product Of Character Vectors

2008-12-05 Thread Rory.WINSTON
Hi David Perfect - if I specify sep=, it gives me exactly what I need. Cheers Rory Winston RBS Global Banking Markets Office: +44 20 7085 4476 -Original Message- From: David Winsemius [mailto:[EMAIL PROTECTED] Sent: 05 December 2008 14:16 To: WINSTON, Rory, GBM Cc:

Re: [R] Cartesian Product Of Character Vectors

2008-12-05 Thread Rory.WINSTON
Sorry, I spoke too soon... interaction() only works for sequences of equal length. Anyone know a method that works with unequal-length vectors? Rory Winston RBS Global Banking Markets Office: +44 20 7085 4476 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On

[R] read.gal3.R

2008-12-05 Thread Annachiara Saguatti
Hello everybody, I'm trying to perform a ESDA on some data about per capita GDP among European regions and I'm trying to learn how to make R and GeoDa interact. I'm reading that in order to import a GAL file from GeoDa to R it's best to source into R the read.gal3.R file. But where can I get it

Re: [R] levels update

2008-12-05 Thread Antje
Thanks a lot!!! the drop thing was exactly what I was looking for (I already used it some time ago but forgot about it). Thanks to everybody else too. Antje Prof Brian Ripley schrieb: On Fri, 5 Dec 2008, jim holtman wrote: try this: df - data.frame(factor(c(a,a,c,b,b)), c(4,5,6,7,8),

Re: [R] levels update

2008-12-05 Thread Richard . Cotton
I hope this question is not too stupid. I would like to know how to update levels after subsetting data from a data.frame. df - data.frame(factor(c(a,a,c,b,b)), c(4,5,6,7,8), c(9,1,2,3,4)) names(df) - c(X1,X2,X3) my.sub - subset(df, X1 == a | X1 == b) levels(my.sub$X1) # still

Re: [R] setwd and list.files / linux

2008-12-05 Thread Marc Schwartz
Hi Lars, I am having trouble replicating this problem, using the default file/folder permissions on my Fedora 10 system. When creating a new folder, I get: mkdir Test drwxrwxr-x 2 marcs marcs 4096 2008-12-05 08:17 Test When creating a new file, I get: touch Test.txt -rw-rw-r-- 1 marcs

Re: [R] Cartesian Product Of Character Vectors

2008-12-05 Thread Rory.WINSTON
Got it...I completely overlooked the collapse argument to paste(): apply(expand.grid(x,y),1,function(x) paste(x,collapse=)) Rory Winston RBS Global Banking Markets Office: +44 20 7085 4476 -Original Message- From: WINSTON, Rory, GBM Sent: 05 December 2008 14:30 To: WINSTON, Rory,

[R] Sink does not send graphs to sink file

2008-12-05 Thread John Sorkin
Wiindows XP R 2.7 I am using sink() to send the results of my analyses to a text file. Unfortunately my graphs do not become part of the file. Is there anyway that I can have both the text and graphic output of my analyses appear in a file? Thanks, John John David Sorkin M.D., Ph.D. Chief,

Re: [R] How to get Greenhouse-Geisser epsilons from anova?

2008-12-05 Thread John Fox
Dear Nils, You might also take a look at the Anova() function in the car package, which though less flexible than anova() should get you the tests that you want more simply. ?Anova has an example of a repeated-measures ANOVA with two within-subject and two between-subject factors. I hope that

Re: [R] Cartesian Product Of Character Vectors

2008-12-05 Thread Henrique Dallazuanna
Try this also: with(expand.grid(x,y), paste(Var1, Var2, sep = )) On Fri, Dec 5, 2008 at 1:08 PM, [EMAIL PROTECTED] wrote: Got it...I completely overlooked the collapse argument to paste(): apply(expand.grid(x,y),1,function(x) paste(x,collapse=)) Rory Winston RBS Global Banking Markets

Re: [R] Sink does not send graphs to sink file

2008-12-05 Thread Richard . Cotton
I am using sink() to send the results of my analyses to a text file. Unfortunately my graphs do not become part of the file. Is there anyway that I can have both the text and graphic output of my analyses appear in a file? You can create a latex document with text, graphs and R-code using

[R] systematically matching the numbers in two sequences

2008-12-05 Thread emj83
I am having trouble writing a code for matching two pairs of sequences with differing lengths: for example sequence1= 1,2,3,4,5,6,7 sequence2=1,2,3,4,5,6,7,8,9,10 I want to create several new pairs of sequences in several dataframes such that: 1st dataframe is 1,10 (start of sequence1, end of

Re: [R] Sink does not send graphs to sink file

2008-12-05 Thread Philipp Pagel
I am using sink() to send the results of my analyses to a text file. Unfortunately my graphs do not become part of the file. Is there anyway that I can have both the text and graphic output of my analyses appear in a file? Well, how would you expect the graphs to be represented in a text

Re: [R] 2D density tophat

2008-12-05 Thread Aaron Robotham
In case anyone other than me was interested, a pretty efficient circular tophat can be made using the fields function fields.rdist.near: CircHat=function (x, y, h=1, gridres = c((max(x)-min(x))/25,(max(y)- min(y))/25), lims = c(range(x), range(y)),density=FALSE) { require(fields)

Re: [R] systematically matching the numbers in two sequences

2008-12-05 Thread Henrique Dallazuanna
Try this: s1 - 1:7 s2 - 1:10 lapply(seq(length(s1)), function(i)cbind(head(s1, i), tail(s2, i))) On Fri, Dec 5, 2008 at 1:44 PM, emj83 [EMAIL PROTECTED] wrote: I am having trouble writing a code for matching two pairs of sequences with differing lengths: for example sequence1=

[R] How to calculate the distance between two density functions

2008-12-05 Thread Chang Jia-Ming
Dear all, I wrote the following code to calculate the density functions for two data sets, respectively. den_str -density(str_data$Similarity); den_non_str -density(nonstr_data$Similarity); However, I would like to knowing the difference between den_str and den_non_str, that is, the

[R] systematically matching the numbers in two sequences

2008-12-05 Thread emj83
I am having trouble writing a code for matching two pairs of sequences with differing lengths: for example sequence1= 1,2,3,4,5,6,7 sequence2=1,2,3,4,5,6,7,8,9,10 I want to create several new pairs of sequences in several dataframes such that: 1st dataframe is 1,10 (start of sequence1, end of

[R] Problems with lattice-histograms or png within loops

2008-12-05 Thread Mark Heckmann
Dear R-users, I have a question concerning the use of lattice plots within for-loops. I want to create a png file containing a lattice histogram which works out fine (part 1). When I loop the whole code, the graphic file does not contain anything (part 2). I can fix it by wrapping the histogram

Re: [R] Strplit code

2008-12-05 Thread William Dunlap
[R] Strplit code pomchip at free.fr pomchip at free.fr Wed Dec 3 20:52:21 CET 2008 Dear R-users, The strsplit function does not exist in S-plus and I would like to use it. How could I reproduce the function in Splus or access to its source code? Thank you in advance,

Re: [R] Problems with lattice-histograms or png within loops

2008-12-05 Thread Richard . Cotton
I have a question concerning the use of lattice plots within for-loops. I want to create a png file containing a lattice histogram which works out fine (part 1). When I loop the whole code, the graphic file does not contain anything (part 2). I can fix it by wrapping the histogram

Re: [R] comparing SAS and R survival analysis with time-dependent covariates

2008-12-05 Thread Svetlana Eden
Thank you so much, this was very helpful. Svetlana Terry Therneau wrote: This query of why do SAS and S give different answers for Cox models comes up every so often. The two most common reasons are that a. they are using different options for the ties b. the SAS and S

Re: [R] legend at fixed distance form the bottom

2008-12-05 Thread Greg Snow
It is best to create the graphics device at the final size desired, then do the plotting and add the legend. For getting a fixed distance, look at the function grconvertY for one possibility. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED]

Re: [R] How to calculate the distance between two density functions

2008-12-05 Thread David Winsemius
A similar question was posed and answered: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/119793.html Two aspects needed to be addressed ... specifying the same domain, and getting the x-values to line up prior to the subtraction (or whatever function is desired). What are you going to

[R] Help with wavCWTPeaks

2008-12-05 Thread mauede
I cannot understand the following error printed out when I try to get the extrema of my time series. I would appreciate some suggestion as I really cannot interpret the error. I might not be using a proper set of parameters in calling such functions. I am learning by doing ... aa.peak -

Re: [R] Sink does not send graphs to sink file

2008-12-05 Thread Barry Rowlingson
2008/12/5 Philipp Pagel [EMAIL PROTECTED]: I am using sink() to send the results of my analyses to a text file. Unfortunately my graphs do not become part of the file. Is there anyway that I can have both the text and graphic output of my analyses appear in a file? Well, how would you expect

Re: [R] Sink does not send graphs to sink file

2008-12-05 Thread Bert Gunter
I think Sweave and/or odfWeave are the real answer, though. Obviously, a bigger and more elaborate kettle of fish. -- Bert Gunter -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Barry Rowlingson Sent: Friday, December 05, 2008 9:21 AM To: Philipp Pagel

Re: [R] Sink does not send graphs to sink file

2008-12-05 Thread Greg Snow
Others mentioned Sweave, which is the best way to go if you have a planned set of routines to do. If you are more just playing and want a transcript of what you are doing (unpreplanned) that includes graphics in the final version, then look at etxtStart from the TeachingDemos package. You

[R] Running R Script on a Sequence of Files

2008-12-05 Thread Chris Poliquin
Hi, I have about 900 files that I need to run the same R script on. I looked over the R Data Import/Export Manual and couldn't come up with a way to read in a sequence of files. The files all have unique names and are in the same directory. What I want to do is: 1) Create a list of

[R] [R-pkgs] RMySQL 0.7-2 now available on CRAN

2008-12-05 Thread Jeffrey Horner
Dear R users, RMySQL 0.7-2 is now available on CRAN: http://cran.r-project.org/web/packages/RMySQL/index.html From the NEWS file: * New maintainer is Jeffrey Horner [EMAIL PROTECTED]. * We no longer distribute libmysql.dll. This library is now found either by reading the MYSQL_HOME

Re: [R] Running R Script on a Sequence of Files

2008-12-05 Thread Kyle.
Have you thought about using one of the Python/R interface modules? http://www.omegahat.org/RSPython/ http://rpy.sourceforge.net/ Admittedly, I have not had much success in getting these to work on my machine, but I know others who have. Kyle H. Ambert Graduate Student Department of Medical

Re: [R] Running R Script on a Sequence of Files

2008-12-05 Thread Ajay ohri
This is almost a macro problem. It could be done in SAS language using the WPS product (660 USD) I think. It is a familiar problem and I would be quite interested in the result. Is there any concept of Macros in R or a package to do the same. Regards, Ajay On Fri, Dec 5, 2008 at 11:31 PM,

Re: [R] Running R Script on a Sequence of Files

2008-12-05 Thread Barry Rowlingson
2008/12/5 Chris Poliquin [EMAIL PROTECTED]: Hi, I have about 900 files that I need to run the same R script on. I looked over the R Data Import/Export Manual and couldn't come up with a way to read in a sequence of files. The files all have unique names and are in the same directory.

Re: [R] Running R Script on a Sequence of Files

2008-12-05 Thread Bert Gunter
R has quite a few functions to get and manipulate filenames to facilitate exactly what you want to do. See ?files and especially the links at the end to the file name manipulation functions. e.g. dir(pathname) lists all file names in the directory pathname. ?list.files gives details. -- Bert

Re: [R] Help with wavCWTPeaks

2008-12-05 Thread stephen sefick
#my suggestion would be to use the morlet wavelet as opposed to the mexican hat wavelet (default). aa - (structure(list(X.0.85 = c(-1.02, -1.17, -1.29, -1.39, -1.46, -1.5, -1.52, -1.5, -1.46, -1.39, -1.3, -1.19, -1.07, -0.93, -0.79, -0.65, -0.5, -0.36, -0.22, -0.08, 0.05, 0.18, 0.3, 0.41, 0.52,

Re: [R] Running R Script on a Sequence of Files

2008-12-05 Thread Kyle.
Thanks, Barry. I'll use that in the future. ---Kyle. On Fri, Dec 5, 2008 at 11:01 AM, Barry Rowlingson [EMAIL PROTECTED] wrote: 2008/12/5 Chris Poliquin [EMAIL PROTECTED]: Hi, I have about 900 files that I need to run the same R script on. I looked over the R Data Import/Export

Re: [R] Running R Script on a Sequence of Files

2008-12-05 Thread Gabor Grothendieck
Use dir to get the names and then lapply over them with a custom anonymous function where L is a list of the returned values: # assumes file names are those in # current directory that end in .dat filenames - dir(pattern = \\.dat$) L - lapply(filenames, function(x) { DF - read.table(x,

Re: [R] Running R Script on a Sequence of Files

2008-12-05 Thread Philipp Pagel
I can't believe the two 'solutions' already posted. It's easy: Me neither. ?list.files That's what I would use, too. If the OP is on a UNIX platform, run the R-script in a loop in the shell is an alternative. Something like this (bourne shell syntax): for datafile in *.csv ; do

Re: [R] Running R Script on a Sequence of Files

2008-12-05 Thread Gustavo Carvalho
Is there a way to list only the files in a given directory without passing pattern=... to list.files()? On Fri, Dec 5, 2008 at 5:10 PM, Kyle. [EMAIL PROTECTED] wrote: Thanks, Barry. I'll use that in the future. ---Kyle. On Fri, Dec 5, 2008 at 11:01 AM, Barry Rowlingson [EMAIL PROTECTED]

Re: [R] Running R Script on a Sequence of Files

2008-12-05 Thread Gabor Grothendieck
Try this: dir()[!file.info(dir())$isdir] On Fri, Dec 5, 2008 at 2:30 PM, Gustavo Carvalho [EMAIL PROTECTED] wrote: Is there a way to list only the files in a given directory without passing pattern=... to list.files()? On Fri, Dec 5, 2008 at 5:10 PM, Kyle. [EMAIL PROTECTED] wrote: Thanks,

Re: [R] Running R Script on a Sequence of Files

2008-12-05 Thread Jagat.K.Sheth
This is almost a macro problem. It could be done in SAS language using the WPS product (660 USD) I think. ... OUCH! Why do it the complicated way??? Check out ?dir, ?list.files, and then ?lapply for a simple start. Don't give up so soon! When it comes to R there is no need to punt - you can

Re: [R] Running R Script on a Sequence of Files

2008-12-05 Thread Ajay ohri
Thanks for the solution . I especially liked the analogy along with the code of course. Regards, Ajay www.decisionstats.com On Sat, Dec 6, 2008 at 1:23 AM, [EMAIL PROTECTED] wrote: This is almost a macro problem. It could be done in SAS language using the WPS product (660 USD) I think. ...

Re: [R] Running R Script on a Sequence of Files

2008-12-05 Thread Steve_Friedman
It seems that you have 900 files with the same parameters in each file (I might be reading more between the lines here than you inferred). However if this is the case, why not import each of the files into a common database and then link the database using ODBC connectivity options. If that is

[R] adding rows as arithmatic calculation on original rows

2008-12-05 Thread Ferry
Dear R users, Suppose I have the following data.frame: myID myType myNum1 myNum2 myNum3 a Single 10 11 12 b Single 15 25 35 c Double 22 33 44 d Double4 6 8 and I want

Re: [R] How to calculate the distance between two density functions

2008-12-05 Thread Lucke, Joseph F
In general, comparing two continuous densities is difficult because they can differ on a set of measure 0 (i.e., at a single point) and yet have the same distribution function. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Chang Jia-Ming Sent: Friday,

Re: [R] Random Forest weighting

2008-12-05 Thread Raghu Naik
Andy, Thanks for your email. I understand that by default, the sampsize variable will use the behavior variable that we are classifying as the strata variable. Then, I could set sampsize=c(no=89, yes=11). I implemented that but I got 99% classification error rate on the yes value. When I

Re: [R] alternative way to replicate()

2008-12-05 Thread Johannes Hüsing
Am 03.12.2008 um 09:06 schrieb Liviu Andronic: Dear all, I'm looking for an alternative way to replicate the 2, string for an x number of times, and end up with one string containing 2, x times. I can partly achieve this using replicate(). y - rep(2,, times=3) y JFTR: replicate() is a

[R] lme4, error in mer_finalize(ans)

2008-12-05 Thread B. Meijering
Using lmer() on my data results in an error. The problem, I think, is my model specification. However, lm() works ok. I recreated this error with a more simple dataset. (See code below.) # word and letter recognition data # two within factors: # word length: 4, 5, 6 letters # letter position:

Re: [R] adding rows as arithmatic calculation on original rows

2008-12-05 Thread jim holtman
This should get you close: x - read.table(textConnection(myID myType myNum1 myNum2 myNum3 + a Single 10 11 12 + b Single 15 25 35 + c Double 22 33 44 + d Double4 6 8),

Re: [R] lme4, error in mer_finalize(ans)

2008-12-05 Thread Douglas Bates
On Fri, Dec 5, 2008 at 3:44 PM, B. Meijering [EMAIL PROTECTED] wrote: Using lmer() on my data results in an error. The problem, I think, is my model specification. However, lm() works ok. I recreated this error with a more simple dataset. (See code below.) # word and letter recognition data

Re: [R] adding rows as arithmatic calculation on original rows

2008-12-05 Thread Ferry
Thanks much Jim. On Fri, Dec 5, 2008 at 2:05 PM, jim holtman [EMAIL PROTECTED] wrote: This should get you close: x - read.table(textConnection(myID myType myNum1 myNum2 myNum3 + a Single 10 11 12 + b Single 15 25 35 + c

Re: [R] Cartesian Product Of Character Vectors

2008-12-05 Thread Ben Bolker
Rory.WINSTON at rbs.com writes: Sorry, I spoke too soon... interaction() only works for sequences of equal length. Anyone know a method that works with unequal-length vectors? Something like c(outer(vec1,vec2,paste,sep=)) ? (totally untested) Ben Bolker

Re: [R] Question about lrandom effects specification in lme4

2008-12-05 Thread Douglas Bates
On Thu, Dec 4, 2008 at 6:21 PM, Bert Gunter [EMAIL PROTECTED] wrote: Folks: Suppose I have 3 random effects, A,B, and C. Using the older lme() function (in nlme) it was possible (using the pdMat classes) to specify that they are uncorrelated with identical variances. Is it possible to do

Re: [R] adding rows as arithmatic calculation on original rows

2008-12-05 Thread Gabor Grothendieck
Here is a solution using sqldf library(sqldf) DF2 - structure(list(myID = structure(1:4, .Label = c(a, b, c, d), class = factor), myType = structure(c(2L, 2L, 1L, 1L), .Label = c(Double, Single), class = factor), myNum1 = c(10, 15, 22, 4), myNum2 = c(11, 25, 33, 6), myNum3 = c(12, 35, 44, 8)),

Re: [R] How to get Greenhouse-Geisser epsilons from anova?

2008-12-05 Thread Peter Dalgaard
Skotara wrote: Dear Mr. Daalgard. thank you very much for your reply, it helped me to progress a bit. The following works fine: dd - expand.grid(C = 1:7, B= c(r, l), A= c(c, f)) myma - as.matrix(myma) #myma is a 12 by 28 list mlmfit - lm(myma~1) mlmfit0 - update(mlmfit, ~0) anova(mlmfit,

Re: [R] adding rows as arithmatic calculation on original rows

2008-12-05 Thread rmailbox
Here is a solution using doBy and Gabor's DF2 created below: library( doBy ) newrows - summaryBy ( myNum1 + myNum2 + myNum3 ~ myType , DF2, keep.names = TRUE ) newrows[,myID] - + rbind ( DF2, newrows) - Original message - From: Gabor Grothendieck [EMAIL PROTECTED] To: Ferry

Re: [R] adding rows as arithmatic calculation on original rows

2008-12-05 Thread Ferry
thanks Gabor, and rmailbox. On Fri, Dec 5, 2008 at 3:32 PM, [EMAIL PROTECTED] wrote: Here is a solution using doBy and Gabor's DF2 created below: library( doBy ) newrows - summaryBy ( myNum1 + myNum2 + myNum3 ~ myType , DF2, keep.names = TRUE ) newrows[,myID] - + rbind ( DF2, newrows)

[R] Kaplan-Meier function from survfit

2008-12-05 Thread Ritwik Sinha
Hi All, Please pardon me if I am missing something obvious here. How do I get the Kaplan-Meier estimate function that is created by survfit and plotted by the code. fit - survfit(Surv(time, status) , data=aml) plot(fit) That is, I need a function that will give me the survival estimate at a

Re: [R] Kaplan-Meier function from survfit

2008-12-05 Thread Marc Schwartz
on 12/05/2008 09:10 PM Ritwik Sinha wrote: Hi All, Please pardon me if I am missing something obvious here. How do I get the Kaplan-Meier estimate function that is created by survfit and plotted by the code. fit - survfit(Surv(time, status) , data=aml) plot(fit) That is, I need a

Re: [R] Spectral Analysis of Time Series in R

2008-12-05 Thread David Stoffer
You can do (1) and (2) [with some additional coding] using mvspec.R, which you can download from http://www.stat.pitt.edu/stoffer/tsa2/chap7.htm ... scroll down to the Spectral Envelope section and you'll find it there. You can look at the top part of the examples to get an idea of how to use

  1   2   >