Re: [R] What is the best way to lag a time series?

2010-12-26 Thread Liviu Andronic
On Sun, Dec 26, 2010 at 8:49 AM, Christian Schoder schoc...@newschool.edu wrote: Dear R-users, I've been using R for a while and I am very satisfied! Unfortunately, I still have not figured out an efficient and general way to construct and use lags of time series, especially when I need to

[R] object names from character strings

2010-12-26 Thread Jim Bouldin
I realize this is probably pretty basic but I can't figure it out. I'm looping through an array, doing various calculations and producing a resulting data frame in each loop iteration. I need to give each data frame a different name. Although I can easily create a new character string for

Re: [R] What is the best way to lag a time series?

2010-12-26 Thread Patrick Burns
First off, there are data manipulation techniques that will beat doing it in a spreadsheet. For example: head(x, -1) is lagged 1 relative to tail(x, -1) But I think you are really looking for 'Lag' in the 'quantmod' package. On 26/12/2010 07:49, Christian Schoder wrote: Dear R-users, I've

Re: [R] How to specify ff object filepaths when reading a CSV file into a ff data frame.

2010-12-26 Thread Xiaobo Gu
Hi, I have done another simple test, I test the two syntext against a CSV file with only one column, both success, fdf - read.csv.ffdf(file=D:/rtemp/fftest2.csv,asffdf_args = list( col_args = list(filename=c(F:/a.f fdf ffdf (all open) dim=c(2,1), dimorder=c(1,2) row.names=NULL ffdf

[R] R2WinBugs data import error

2010-12-26 Thread unsown
For some purpose, I need to transfer a NAs array to WinBugs through R2WinBugs, But I constantly got an error message:'type' must be real for this format. Here is my data to transfer: x = matrix(data=NA,nrow=3,ncol=3) x = as.array(x) data - list (x) if I add a line to above setting, then I can

[R] Fitting mixtures with non-linear parameters constraints

2010-12-26 Thread Jonathan Rosenblatt
Dear R users Does anyone happen to know a function to fit a Gaussian mixture using *non-linear* constraints between the parameters? (An EM the allows that will do the job obviously). Thank you in advance -- Jonathan Rosenblatt www.john-ros.com __

[R] lattice splom: how to adjust space between tick marks and tick labels?

2010-12-26 Thread Marius Hofert
Dear expeRts, how can I decrease the space between the tick marks and the corresponding labels in an splom? See here: library(lattice) U - matrix(runif(4000), ncol = 8) splom(U, axis.text.cex = 0.2) # = space between the [small] tick labels and tick marks is/seems to be too large I checked

[R] Doing a mixed-ANOVA after accounting for a covariate

2010-12-26 Thread Dror D Lev
Dear r helpers, I would like to look at the interaction between two two-level factors, one between and one within participants, after accounting for any variance due to practice (31 trials in each of two blocks) in the task. It seems to require treating practice as a covariate. All the examples

[R] how to replace my double for loop which is little efficient!

2010-12-26 Thread bbslover
Dear all, My double for loop as follows, but it is little efficient, I hope all friends can give me a vectorized program to replace my code. thanks x: is a matrix 202*263, that is 202 samples, and 263 independent variables num.compd-nrow(x); # number of compounds diss.all-0 for( i in

Re: [R] R2WinBugs data import error

2010-12-26 Thread David Winsemius
On Dec 26, 2010, at 12:44 AM, unsown wrote: For some purpose, I need to transfer a NAs array to WinBugs through R2WinBugs, But I constantly got an error message:'type' must be real for this format. Here is my data to transfer: x = matrix(data=NA,nrow=3,ncol=3) str(x) It is of mode

Re: [R] object names from character strings

2010-12-26 Thread David Winsemius
On Dec 26, 2010, at 4:04 AM, Jim Bouldin wrote: I realize this is probably pretty basic but I can't figure it out. I'm looping through an array, doing various calculations and producing a resulting data frame in each loop iteration. I need to give each data frame a different name.

Re: [R] object names from character strings

2010-12-26 Thread jim holtman
Consider storing the dataframes in a list so that you do not have to create unique names and it will also give you better control by keeping all the data together in one object. On Sun, Dec 26, 2010 at 4:04 AM, Jim Bouldin bouldi...@gmail.com wrote: I realize this is probably pretty basic but I

Re: [R] lattice splom: how to adjust space between tick marks and tick labels?

2010-12-26 Thread David Winsemius
On Dec 26, 2010, at 5:41 AM, Marius Hofert wrote: Dear expeRts, how can I decrease the space between the tick marks and the corresponding labels in an splom? See here: library(lattice) U - matrix(runif(4000), ncol = 8) splom(U, axis.text.cex = 0.2) # = space between the [small] tick

[R] T2 hoteling

2010-12-26 Thread leyla khodakarim
Dear All It is very kind of you to guide me. When I want to run this line, I see this error stat.obs - apply(GS, 2, function(z) Hott2(t(DATA[which(z==1),]), cl)) Error in colSums(w * x) : 'x' must be an array of at least two dimensions cl - as.factor(y) GS: a matrix with 0 or 1 GS: gene

Re: [R] Doing a mixed-ANOVA after accounting for a covariate

2010-12-26 Thread David Winsemius
On Dec 26, 2010, at 7:42 AM, Dror D Lev wrote: Dear r helpers, I would like to look at the interaction between two two-level factors, one between and one within participants, after accounting for any variance due to practice (31 trials in each of two blocks) in the task. It seems to

Re: [R] how to replace my double for loop which is little efficient!

2010-12-26 Thread Berend Hasselman
bbslover wrote: x: is a matrix 202*263, that is 202 samples, and 263 independent variables num.compd-nrow(x); # number of compounds diss.all-0 for( i in 1:num.compd) for (j in 1:num.compd) if (i!=j) { S1-sum(x[i,]*x[j,]) S2-sum(x[i,]^2)

Re: [R] What is the best way to lag a time series?

2010-12-26 Thread Bert Gunter
The correct answer to How to lag..? is almost certainly, Don't. The functionality of numerous time series packages and functions take care of this automatically for you (using suitable data structures, probably). Rather than trying to reinvent wheels, it might be wiser to consult the Time Series

[R] Calculation of BIC done by leaps-package

2010-12-26 Thread Jan Henckens
Hi Folks, I've got a question concerning the calculation of the Schwarz-Criterion (BIC) done by summary.regsubsets() of the leaps-package: Using regsubsets() to perform subset-selection I receive an regsubsets object that can be summarized by summary.regsubsets(). After this operation the

Re: [R] Performing basic Multiple Sequence Alignment in R?

2010-12-26 Thread Mike Marchywka
From: marchy...@hotmail.com To: tal.gal...@gmail.com; r-help@r-project.org Subject: RE: [R] Performing basic Multiple Sequence Alignment in R? Date: Tue, 21 Dec 2010 17:03:17 -0500 From: tal.gal...@gmail.com Date: Tue, 21 Dec 2010 20:17:18 +0200 Subject: Re: [R] Performing basic

Re: [R] Doing a mixed-ANOVA after accounting for a covariate

2010-12-26 Thread Dror D Lev
Thank you David, for the reference to Dalgaard's paper in Rnews_2007-2. Unfortunately I don't seem to have the mathematical-statistical sophistication required to adapt the example in Dalgaard's paper for my case. I hope someone can suggest a less-mathematical direction for solution. Thanks

Re: [R] Doing a mixed-ANOVA after accounting for a covariate

2010-12-26 Thread David Winsemius
On Dec 26, 2010, at 9:55 AM, Dror D Lev wrote: Thank you David, for the reference to Dalgaard's paper in Rnews_2007-2. Unfortunately I don't seem to have the mathematical-statistical sophistication required to adapt the example in Dalgaard's paper for my case. I hope someone can

Re: [R] lattice splom: how to adjust space between tick marks and tick labels?

2010-12-26 Thread Marius Hofert
Dear David, thank you for your answer. As I wrote, I am looking for an option to control the *space* between the tick marks and the corresponding labels. I am happy with the *number* of tick marks and their default values. As far as I know, pscales can't control the space, so it is *not* what

[R] can't install R with *local* gcc

2010-12-26 Thread Oliver Kullmann
Hello, we re-distribute R with our open-source platform http://www.ok-sat-library.org/ where we use R mainly for evaluation of computational experiments. Due to the various platforms, we build everything from source, and that works fine. Until now, that is: there are circumstances (for example

Re: [R] package arules - 'transpose' of the transactions

2010-12-26 Thread Michael Hahsler
Hi Kohleth, Suppose this is my list of transactions: set.seed(200) tran=random.transactions(100,3) inspect(tran) itemstransactionID 1 {item80}trans1 2 {item8, item20}trans2 3 {item28}trans3 I want to get the 'transpose' of the data, i.e. transactionID

Re: [R] Lost in POSIX

2010-12-26 Thread Jeff Newmiller
Dimitri Shvorob wrote: df = structure(list(t = structure(c(1033963406.044, 1033974144.847, + 1033988418.836), class = c(POSIXt, POSIXct))), .Names = t, row.names = c(NA, + 3L), class = data.frame) df$min = trunc(df$t,units=mins) does not work, Jeff; you will see that my original post

Re: [R] Lost in POSIX

2010-12-26 Thread Jeff Newmiller
Dimitri Shvorob wrote: .. One issue with the solution proposed by Jeff is that the transformed column does not have the original's type: x = structure(list(time = structure(c(1020232904.818, 1020232904.818 ), class = c(POSIXt, POSIXct), tzone = ), price = c(321, 323.5), minute = c(1020232860,

Re: [R] Lost in POSIX

2010-12-26 Thread David Winsemius
On Dec 25, 2010, at 2:25 PM, Dimitri Shvorob wrote: df = structure(list(t = structure(c(1033963406.044, 1033974144.847, + 1033988418.836), class = c(POSIXt, POSIXct))), .Names = t, row.names = c(NA, + 3L), class = data.frame) df$min = trunc(df$t,units=mins) does not work, ??? seems to

[R] A question on Statistics

2010-12-26 Thread Maithula Chandrashekhar
I am not a pure Statistics background and therefore please forgive me if this question (which is not R related either) is too trivial. In many Statistics literature I find following statement: restrictions in different coefficients matrices have to be imposed to ensure uniqueness of the

Re: [R] Doing a mixed-ANOVA after accounting for a covariate

2010-12-26 Thread RICHARD M. HEIBERGER
Dror, Please look at the demo(MMC.apple) in the HH package install.packages(HH) ## if you don't already have it. library(HH) demo(MMC.apple) Please reply to the list if there are further queries. Rich On Sun, Dec 26, 2010 at 7:42 AM, Dror D Lev dror.te...@gmail.com wrote: Dear r helpers,

Re: [R] can't install R with *local* gcc

2010-12-26 Thread peter dalgaard
On Dec 26, 2010, at 17:50 , Oliver Kullmann wrote: Hello, we re-distribute R with our open-source platform http://www.ok-sat-library.org/ where we use R mainly for evaluation of computational experiments. Due to the various platforms, we build everything from source, and that works

Re: [R] A question on Statistics

2010-12-26 Thread Bert Gunter
Maithula: On Sun, Dec 26, 2010 at 11:09 AM, Maithula Chandrashekhar m.chandrashekhar1...@gmail.com wrote: I am not a pure Statistics background and therefore please forgive me if this question (which is not R related either) is too trivial. In many Statistics literature I find following

[R] Question about mars() -function

2010-12-26 Thread Tiina Hakanen
Hi! I have some questions about MARS model's coefficient of determination. I use the MARS method in my master's thesis and I have noticed some problems with the MARS model's R^2. You can see the following example that the MARS model's R^2 is too big when i have used mars() -function for

[R] read.data? without separator

2010-12-26 Thread Fror
Hello, I have a problem with read.data. For example I have a file # comment 1?0001010101 101010??1010 with comment on first line and data layout without separator. How I could read data that each character\sign was in another column. It is trivial probably, but I have no idea for it. Thank's,

Re: [R] T2 hoteling

2010-12-26 Thread Jim Lemon
On 12/27/2010 12:43 AM, leyla khodakarim wrote: Dear All It is very kind of you to guide me. When I want to run this line, I see this error stat.obs- apply(GS, 2, function(z) Hott2(t(DATA[which(z==1),]), cl)) Error in colSums(w * x) : 'x' must be an array of at least two dimensions cl-

[R] Parsing a Simple Chemical Formula

2010-12-26 Thread Bryan Hanson
Hello R Folks... I've been looking around the 'net and I see many complex solutions in various languages to this question, but I have a pretty simple need (and I'm not much good at regex). I want to use a chemical formula as a function argument. The formula would be in Hill order which

Re: [R] levelplot blocks size

2010-12-26 Thread jonathan
Thanks for your advice, but my data is not decimals, so I don't need to round the values. Instead, what I need to really do is group the values into larger blocks. My data looks sort of like this: xy z 00687 0164 0271 0355 0452 0551

[R] GLS with corAR(1) correlation structure residual/standard error calculation

2010-12-26 Thread Katharina Ley
I am using the gls function to fit a two-stage least squares model with first order autoregressive error terms. Since there is no automated adjustment for the use of two-stage least squares in this package, I am trying to manually replicate standard errors of the coefficient estimates in order to

Re: [R] Parsing a Simple Chemical Formula

2010-12-26 Thread jim holtman
try this: f.extract - function(formula) + { + # pattern to match the initial chemical + # assumes chemical starts with an upper case and optional lower case followed + # by zero or more digits. + first - ^([[:upper:]][[:lower:]]?)([0-9]*).* + # inverse of above to

Re: [R] Parsing a Simple Chemical Formula

2010-12-26 Thread David A. Johnston
There might be something simpler, but this is what I came up with: form = C5H11BrO ups = c(gregexpr([[:upper:]], form)[[1]], nchar(form) + 1) seperated = sapply(1:(length(ups)-1), function(x) substr(form, ups[x], ups[x+1] - 1)) elements = gsub([[:digit:]], , seperated) nums = gsub([[:alpha:]],

Re: [R] Parsing a Simple Chemical Formula

2010-12-26 Thread Gabor Grothendieck
On Sun, Dec 26, 2010 at 6:29 PM, Bryan Hanson han...@depauw.edu wrote: Hello R Folks... I've been looking around the 'net and I see many complex solutions in various languages to this question, but I have a pretty simple need (and I'm not much good at regex).  I want to use a chemical formula

Re: [R] read.data? without separator

2010-12-26 Thread jim holtman
I have a problem with 'read.data' also in that I don't see that as a function in the 'base'; I assume you meant read.table. Also you did not indicate is all the lines were the same length. Here is a solution to return a list is each character broken out separately. x -

Re: [R] Parsing a Simple Chemical Formula

2010-12-26 Thread David Winsemius
On Dec 26, 2010, at 6:29 PM, Bryan Hanson wrote: Hello R Folks... I've been looking around the 'net and I see many complex solutions in various languages to this question, but I have a pretty simple need (and I'm not much good at regex). I want to use a chemical formula as a function

Re: [R] Parsing a Simple Chemical Formula

2010-12-26 Thread Bryan Hanson
Well let me just say thanks and WOW! Four great ideas, each worthy of study and I'll learn several things from each. Interestingly, these solutions seem more general and more compact than the solutions I found on the 'net using python and perl. More evidence for the power of R! A big

Re: [R] Parsing a Simple Chemical Formula

2010-12-26 Thread Spencer Graves
Have you considered the 'CHNOSZ' package? makeup(C5H11BrO ) count C 5 H 11 Br 1 O 1 I found this using the 'sos' package as follows: library(sos) cf - ???'chemical formula' found 21 matches; retrieving 2 pages cf The print method for cf opened the

Re: [R] Parsing a Simple Chemical Formula

2010-12-26 Thread Spencer Graves
p.s. help(pac=CHNOSZ) reveals that this package has 3 vignettes. I have not looked at these vignettes, but most vignettes provide excellent introductions (though rarely with complete coverage) of important capabilities of the package. (The 'sos' package includes a vignette, which exposes

[R] Drop column from a data frame

2010-12-26 Thread John Sorkin
I am trying to drop a column of a data frame. The code below attempts to drop a numeric column (which does not work but gives no error or warning) and a factor column (which does not work but gives an error). I would appreciate someone telling me why my code does not work, and suggesting code

Re: [R] lattice splom: how to adjust space between tick marks and tick labels?

2010-12-26 Thread Peter Ehlers
On 2010-12-26 08:26, Marius Hofert wrote: Dear David, thank you for your answer. As I wrote, I am looking for an option to control the *space* between the tick marks and the corresponding labels. I am happy with the *number* of tick marks and their default values. As far as I know, pscales

Re: [R] Parsing a Simple Chemical Formula

2010-12-26 Thread Bryan Hanson
Thanks Spencer, I'll definitely have a look at this package and it's vignettes. I believe I have looked at it before, but didn't catch it on this particular search. Bryan On Dec 26, 2010, at 8:16 PM, Spencer Graves wrote: p.s. help(pac=CHNOSZ) reveals that this package has 3 vignettes.

Re: [R] Drop column from a data frame

2010-12-26 Thread jim holtman
assign NULL to the column: dfxyz - data.frame(x=1:10,y=11:20,z=factor(c(rep(0,5),rep(1,5 dfxyz x y z 1 1 11 0 2 2 12 0 3 3 13 0 4 4 14 0 5 5 15 0 6 6 16 1 7 7 17 1 8 8 18 1 9 9 19 1 10 10 20 1 dfxyz$y - NULL dfxyz x z 1 1 0 2 2 0 3 3 0 4 4 0 5 5 0 6

Re: [R] Parsing a Simple Chemical Formula

2010-12-26 Thread Mike Marchywka
I think the OP had a very limited need but there is something more sophisticated that may be of larger insterest called SMILES which attempts to capture some structural information about a molecule in a text sting. Reducing pictures to tractable text is an important step in many analysis efforts

Re: [R] Parsing a Simple Chemical Formula

2010-12-26 Thread David Winsemius
On Dec 26, 2010, at 8:28 PM, Bryan Hanson wrote: Thanks Spencer, I'll definitely have a look at this package and it's vignettes. I believe I have looked at it before, but didn't catch it on this particular search. Bryan Using the thermo list that the makeup function accesses to get its

[R] filled.contour colors

2010-12-26 Thread randhindi
Hi, I am trying to set the color scale in filled.contour based on a specific value instead of a relative position. Specifically, I want the values below 0 to be in a gradient of green, and those above 0 to be red. 0 would be white. I tried: posZero = abs(min(z)) / (abs(min(z)) + max(z));

Re: [R] Parsing a Simple Chemical Formula

2010-12-26 Thread Bryan Hanson
Hi David others... I did find the function you recommended, plus, it's even easier (but a little hidden in the doc): element(form, mass). But, this uses the atomic masses from the periodic table, which are weighted averages of the isotopes of each element. What I'm doing actually

Re: [R] Parsing a Simple Chemical Formula

2010-12-26 Thread Gabor Grothendieck
On Sun, Dec 26, 2010 at 7:26 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Sun, Dec 26, 2010 at 6:29 PM, Bryan Hanson han...@depauw.edu wrote: Hello R Folks... I've been looking around the 'net and I see many complex solutions in various languages to this question, but I have a

Re: [R] Parsing a Simple Chemical Formula

2010-12-26 Thread Spencer Graves
Mike Marchywka's post mentioned a CRAN package, rpubchem, missed by my search for chemical formula. A further search for chemical and chemistry still missed it. compound found it. Adding compounds and combining them with union produced a list of 564 links in 219 packages; 7 of the

[R] modifying user agent strings in http requests

2010-12-26 Thread Soumendra
Hi all. How does one change user agent strings in http requests made in R? And how do I figure out what my current user agent string looks like? Thanks in advance, Soumendra -- Don't worry about people stealing your ideas. If your ideas are any good, you'll have to ram them down people's

Re: [R] how to replace my double for loop which is little efficient!

2010-12-26 Thread Dennis Murphy
Hi: On Sun, Dec 26, 2010 at 4:18 AM, bbslover dlu...@yeah.net wrote: Dear all, My double for loop as follows, but it is little efficient, I hope all friends can give me a vectorized program to replace my code. thanks x: is a matrix 202*263, that is 202 samples, and 263 independent

Re: [R] Drop column from a data frame

2010-12-26 Thread Phil Spector
John - You can use a syntax similar to what you've tried with the select= argument of the subset function: subset(dfxyz,select=-y) x z 1 1 0 2 2 0 . . . subset(dfxyz,select=-z) x y 1 1 11 2 2 12 . . . - Phil Spector

Re: [R] R2WinBugs data import error

2010-12-26 Thread unsown
You solved my problem, thank you. As you said it's the type of the content in the matrix that caused the problem. I needed to put variable x along with other variables to the list, somehow it turned out that x must be used in form of character in the statement: dat - list(x,otherVariables)

[R] package update

2010-12-26 Thread eric
I'm running Linux Ubuntu and tried to update my packages using the update.package() command. It appeared to download the updates ok but I got the following message: The downloaded packages are in ‘/tmp/RtmpFM82Ry/downloaded_packages’ Warning in install.packages(update[instlib == l, Package], l,

Re: [R] how to replace my double for loop which is little efficient!

2010-12-26 Thread bbslover
thanks for your help, it is great. In addition, In the beginning, the format of x is dataframe, and i run my code, it is so slow, after your help, I change x for matirx, it is so quick. I am very grateful your kind help, and your code is so good! kevin -- View this message in context:

Re: [R] how to replace my double for loop which is little efficient!

2010-12-26 Thread bbslover
thanks for your help. I am sorry I do not full understand your code, so i can not correct using your code to my data. here is the attachment of my data, and what I want to compute is the equation in the word document of the attachment: the code form Berend can get the answer i want to get.

Re: [R] package update

2010-12-26 Thread Joshua Wiley
Either switch the library path to a writable directory or run it as a su or sudo so you have the necessary permissions. Cheers, Josh On Dec 26, 2010, at 20:45, eric ericst...@aol.com wrote: I'm running Linux Ubuntu and tried to update my packages using the update.package() command. It

Re: [R] lattice splom: how to adjust space between tick marks and tick labels?

2010-12-26 Thread Marius Hofert
Dear Peter, thank you very much, *precisely* what I was looking for! Cheers, Marius On 2010-12-27, at 02:27 , Peter Ehlers wrote: On 2010-12-26 08:26, Marius Hofert wrote: Dear David, thank you for your answer. As I wrote, I am looking for an option to control the *space* between the

Re: [R] how to replace my double for loop which is little efficient!

2010-12-26 Thread Berend Hasselman
djmuseR wrote: On Sun, Dec 26, 2010 at 4:18 AM, bbslover dlu...@yeah.net wrote: x: is a matrix 202*263, that is 202 samples, and 263 independent variables num.compd-nrow(x); # number of compounds diss.all-0 for( i in 1:num.compd) for (j in 1:num.compd) if (i!=j) {