Re: [R] Aggregating the matrices

2010-09-06 Thread Sergey Goriatchev
Gabor, David, thank you. David, your last suggestion is what I need. Regards, Sergey On Mon, Sep 6, 2010 at 16:12, David Winsemius wrote: > > On Sep 6, 2010, at 9:56 AM, Sergey Goriatchev wrote: > >> Hello everyone. >> >> Say we have the following: >> >&

[R] Aggregating the matrices

2010-09-06 Thread Sergey Goriatchev
Hello everyone. Say we have the following: a <- matrix(c(-75, 3, 5, 9, 2, 3, 5), nrow=1, dim=list("06092010", c("ES", "PT", "Z ", "CF", "GX", "ST", "EO"))) b <- matrix(c(-5, 2, 4, 12, 5), nrow=1, dim=list("06092010", c("PT", "CF", "AT", "EM", "ST"))) d <- cbind(a, b) I want to calculate sums of

Re: [R] Extracting future and past workday dates

2010-08-06 Thread Sergey Goriatchev
Henrique, that is what I need! Big thanks! Regards, Sergey On Thu, Aug 5, 2010 at 14:56, Henrique Dallazuanna wrote: > n <- 3 > w <- as.numeric(format(Sys.Date(), '%w')) > fut <- c(Sys.Date() - 0:(n + ifelse(w - n > 6, (w - n) - 6, 0)), > Sys.Date() + 1:(n + 1 + ifelse(w + n > 6, (w + n

Re: [R] Extracting future and past workday dates

2010-08-05 Thread Sergey Goriatchev
Thank you David, will check it out, as I use chron and zoo! Regards, Sergey On Thu, Aug 5, 2010 at 14:29, David Winsemius wrote: > > On Aug 5, 2010, at 8:09 AM, Sergey Goriatchev wrote: > >> Hi, Henrique >> >> Thank you for trying, but that is not what I want.

Re: [R] Extracting future and past workday dates

2010-08-05 Thread Sergey Goriatchev
> or > > 0:3 %*% matrix(c(1, -1), ncol = 2) + Sys.Date() > > On Thu, Aug 5, 2010 at 8:36 AM, Sergey Goriatchev wrote: >> >> Hello everyone >> >> I need to extract a vector of (t-3) to (t+3) dates, only working days. >> How can I do that? >> >>

[R] Extracting future and past workday dates

2010-08-05 Thread Sergey Goriatchev
Hello everyone I need to extract a vector of (t-3) to (t+3) dates, only working days. How can I do that? For today I need a vector: 10.08.210 09.08.2010 06.08.2010 05.08.2010 04.08.2010 03.08.2010 02.08.2010 Regards, Sergey -- Kniven skärpes bara mot stenen. ___

Re: [R] F# vs. R

2010-07-07 Thread Sergey Goriatchev
at 10:31 AM, Sergey Goriatchev wrote: > >> Hello, everyone >> >> F# is now public. Compiled code should run  faster than R. >> >> Anyone has opinion on F# vs. R? Just curious >> >> Best, >> S > > > The key time critical parts of R are writte

[R] F# vs. R

2010-07-07 Thread Sergey Goriatchev
Hello, everyone F# is now public. Compiled code should run  faster than R. Anyone has opinion on F# vs. R? Just curious Best, S -- --- Kniven skärpes bara mot stenen. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-he

Re: [R] Parallel computing on Windows (foreach) (Sergey Goriatchev)

2010-06-16 Thread Sergey Goriatchev
John, Steve, thank you for answering my post! On Wed, Jun 16, 2010 at 20:55, Steve Lianoglou wrote: > Hi, > > I think I lost the reference email somewhere, but: > >> Not only is the sequential foreach much slower than the simple >> for-loop (as least in this particular instance), but I am not qui

Re: [R] Parallel computing on Windows (foreach)

2010-06-16 Thread Sergey Goriatchev
Thank you, Mario. On Wed, Jun 16, 2010 at 14:51, Mario Valle wrote: > > > On 15-Jun-10 17:07, Sergey Goriatchev wrote: >> >> Hello, >> >> I am reading "Using The foreach Package"

[R] Parallel computing on Windows (foreach)

2010-06-15 Thread Sergey Goriatchev
Hello, I am reading "Using The foreach Package" document and I have tried the following: - > sessionInfo() R version 2.10.1 (2009-12-14) i386-pc-mingw32 locale: [1] LC_COLLATE=German_Switzerland.1252 LC_CTYPE=German_Switzerland

Re: [R] How to see how a function is written

2010-06-15 Thread Sergey Goriatchev
> showMethods("apply") Function: apply (package base) X="ANY" X="missing" (inherited from: X="ANY") X="timeSeries" On Tue, Jun 15, 2010 at 15:10, Gavin Simpson wrote: > On Tue, 2010-06-15 at 14:56 +0200, Sergey Goriatchev wrote: >

Re: [R] How to see how a function is written

2010-06-15 Thread Sergey Goriatchev
s article discusses what to do at this point. > > HTH > > G > >> >> --- >> My machine: >> platform       i386-pc-mingw32 >> arch           i386 >> os             mingw32 >> system         i386, mingw32 >> status >> major          2

Re: [R] How to see how a function is written

2010-06-15 Thread Sergey Goriatchev
6 os mingw32 system i386, mingw32 status major 2 minor 10.1 year 2009 month 12 day14 svn rev50720 language R version.string R version 2.10.1 (2009-12-14) On Tue, Jun 15, 2010 at 14:26, Erik Iverson wrote: >

[R] How to see how a function is written

2010-06-15 Thread Sergey Goriatchev
Hello, If I want to see how, say, apply function is written, how would I be able to do that? Just typing "apply" at the prompt does not work. Thank you for help! Sergey __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help

Re: [R] Deleting a file on a drive from within R

2010-05-20 Thread Sergey Goriatchev
|  972-52-7275845 > Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | > www.r-statistics.com (English) > -- > > > > > On Thu, May 20, 2010 at 11:46 AM, Sergey Goriatchev &g

Re: [R] Deleting a file on a drive from within R

2010-05-20 Thread Sergey Goriatchev
Thank you, Dave! Regards, Sergey On Thu, May 20, 2010 at 10:55, Dave Deriso wrote: > file_to_delete = file.choose() > file.remove(file_to_delete) > > Best, > Dave Deriso > UCSD Psychology > > On Thu, May 20, 2010 at 1:46 AM, Sergey Goriatchev wrote: >> Hello, &

[R] Deleting a file on a drive from within R

2010-05-20 Thread Sergey Goriatchev
Hello, I have an Excel file on a drive and I extract data from it into R session. Once I have extracted the data, I want to delete that Excel file from the drive. Can I do that from within R, please? Thank you for help! Regards, Sergey __ R-help@r-pro

Re: [R] Extracting specific rows from irregular zoo object and merging with a regular zoo object

2010-04-08 Thread Sergey Goriatchev
2009-06-30 >         2          5          8          9 > > > On Thu, Apr 8, 2010 at 11:18 AM, Sergey Goriatchev wrote: >> Hello, everyone >> >> I have the following problem: >> Say I have an irregular zoo timeseries like this: >> >> a <- zoo(rep(1

[R] Extracting specific rows from irregular zoo object and merging with a regular zoo object

2010-04-08 Thread Sergey Goriatchev
Hello, everyone I have the following problem: Say I have an irregular zoo timeseries like this: a <- zoo(rep(1:9), as.Date(c("2009-03-20", "2009-03-27", "2009-04-24", "2009-04-25", "2009-04-30", "2009-05-15", "2009-05-22", "2009-05-29", "2009-06-26"))) and I have regular zoo timeseries like this

Re: [R] Simplifying particular piece of code

2010-03-31 Thread Sergey Goriatchev
Thanks for help, Gustaf! (Kan man säga "man tackar" oxa?) :-) On Wed, Mar 31, 2010 at 17:34, Gustaf Rydevik wrote: > On Wed, Mar 31, 2010 at 5:11 PM, Sergey Goriatchev wrote: >> but >> >> data <- merge(data,data.list) >> >> works. >> >>

[R] Simplifying particular piece of code

2010-03-31 Thread Sergey Goriatchev
Hello, everyone I have a piece of code that looks like this: mrets <- merge(mrets, BMM.SR=apply(mrets, 1, MyFunc, ret="BMM.AV120", stdev="BMM.SD120")) mrets <- merge(mrets, GM1.SR=apply(mrets, 1, MyFunc, ret="GM1.AV120", stdev="GM1.SD120")) mrets <- merge(mrets, IYC.SR=apply(mrets, 1, MyFunc, ret

[R] Help function "?" in R 2.10.1

2010-03-11 Thread Sergey Goriatchev
Hello everyone, I have versions 2.7.2 and 2.10.1 installed on a machine that has no access to internet. In 2.7.2 I can use ? to get help on functions, which in 2.10.1 that does not work, all I see is "starting httpd help server...done" and then nothing. Have I downloaded 2.10.1 incorrectly (=forg

Re: [R] Finding a date 6 months before

2010-03-03 Thread Sergey Goriatchev
t; "%d")) >> window(z, index = ago6mos) > 2009-09-03 >        94 > > If we are at the last day of the month and 6 months ago that month has > fewer days than today's month then what to do is not well defined but > we resolve that here by just moving ahead

[R] Finding a date 6 months before

2010-03-03 Thread Sergey Goriatchev
Hello everyone I use zoo objects and I need to find a date 6 months before today's date. Example, today we have 3rd March 2010, I need to find the date 3rd September 2009. How could I do that, please? Regards, Sergey -- Simplicity is the last step of art./Bruce Lee The more you know, the more

Re: [R] Physically open Excel file from R

2010-02-08 Thread Sergey Goriatchev
; > > On 08.02.2010 13:48, Sergey Goriatchev wrote: >> >> Hello, everyone >> >> I wonder if it is possible to PHYSICALLY open an Excel file from R. >> The reason I ask is, I produce regularly an Excel file in R, and then >> I want to make it look good, so

[R] Physically open Excel file from R

2010-02-08 Thread Sergey Goriatchev
Hello, everyone I wonder if it is possible to PHYSICALLY open an Excel file from R. The reason I ask is, I produce regularly an Excel file in R, and then I want to make it look good, so I have a VBA routine in another Excel file that works on the regular Excel file. This formatting file executes V

Re: [R] How to check if file is on a drive?

2009-12-03 Thread Sergey Goriatchev
Great! Thank you, Romain! On Thu, Dec 3, 2009 at 11:33, Romain Francois wrote: > ?file.exists > > On 12/03/2009 11:31 AM, Sergey Goriatchev wrote: >> >> Hello, everyone >> >> How would I check in R if a particular file (Excel file) is in a >> particula

[R] How to check if file is on a drive?

2009-12-03 Thread Sergey Goriatchev
Hello, everyone How would I check in R if a particular file (Excel file) is in a particular folder on a particular drive? I am writing a piece of code around that file, using xls.open() in xlsReadWritePro to open the file in memory and use it. But before I try to open the file I want to catch the

Re: [R] Taking specific/timed differences in a zoo timeseries

2009-10-14 Thread Sergey Goriatchev
gt; > temp - zoo(coredata(temp.m), dt.lag) > 2009-10-05 2009-10-06 2009-10-07 2009-10-08 2009-10-09 2009-10-13 > 2009-10-14 >-5 -6 3 2 -2 2 1 > > > On Wed, Oct 14, 2009 at 10:39 AM, Sergey Goriatchev > wrote: >

[R] Taking specific/timed differences in a zoo timeseries

2009-10-14 Thread Sergey Goriatchev
Hello everyone. I have a specific problem that I have difficulties to solve. Assume I have a zoo object: set.seed(12345) data <- round(runif(27)*10+runif(27)*5, 0) dates <- as.Date(c("09/03/09", "09/04/09", "09/07/09", "09/09/09", "09/10/09", "09/11/09", "09/14/09", "09/16/09", "09/17/09", "09/18

Re: [R] Function similar to cumsum/cumprod

2009-09-22 Thread Sergey Goriatchev
Henrique, thank you! On Tue, Sep 22, 2009 at 16:32, Henrique Dallazuanna wrote: > Try this; > > set.seed(123) > x <- rnorm(100) > sapply(30:length(x), function(i)mean(x[1:i])) > > On Tue, Sep 22, 2009 at 11:12 AM, Sergey Goriatchev wrote: >> Hello, everyone &

[R] Function similar to cumsum/cumprod

2009-09-22 Thread Sergey Goriatchev
Hello, everyone I wonder if there is in R somewhere a function similar to cumsum(). The function calculates a statistic (say mean or standard deviation) buy adding consequtively one more data point. So, say I have a timeseries of 100 observations. I start by calculating mean of first 30 observati

Re: [R] Putting a text box in a plot

2009-09-21 Thread Sergey Goriatchev
Hello, Jim Thank you a lot for suggestions, I will check that package out. It could be the one I used way back then! :-) Best, Sergey On Tue, Sep 22, 2009 at 01:55, Jim Lemon wrote: > On 09/21/2009 07:42 PM, Sergey Goriatchev wrote: >> >> Hello everyone, >> >> I have

Re: [R] Executing R scripts from another R script

2009-09-21 Thread Sergey Goriatchev
17:52, Sergey Goriatchev wrote: > Hello, everyone > > I run Eclipse Ganymede and R 2.7.2 at work. > I have one R script file where I open in memory a new xls file (using > xlsReadWritePro), call other R scripts, which are in the same folder > as the main R script, > which get

[R] Executing R scripts from another R script

2009-09-21 Thread Sergey Goriatchev
Hello, everyone I run Eclipse Ganymede and R 2.7.2 at work. I have one R script file where I open in memory a new xls file (using xlsReadWritePro), call other R scripts, which are in the same folder as the main R script, which get data from an existing xls file, process data, and output results in

Re: [R] Putting a text box in a plot

2009-09-21 Thread Sergey Goriatchev
out a reproducible example. > > > baptiste > > > > 2009/9/21 Sergey Goriatchev : >> Hi, Baptiste >> >> Yes, I've found textplot() function, but I doubt it is the one I need. >> What I have is a density plot, and I want to add to this density plot >&g

Re: [R] Putting a text box in a plot

2009-09-21 Thread Sergey Goriatchev
ckage? > > HTH, > > baptiste > > 2009/9/21 Sergey Goriatchev : >> Hello everyone, >> >> I have a plot and I want to but a (formatted) box containing text and >> numbers, say: >> Mean: 0.1 >> St.Deviation: 1.1 >> Skewness: 1.1 >> K

[R] Putting a text box in a plot

2009-09-21 Thread Sergey Goriatchev
Hello everyone, I have a plot and I want to but a (formatted) box containing text and numbers, say: Mean: 0.1 St.Deviation: 1.1 Skewness: 1.1 Kurtosis: 0.5 I know there is a way to do this, there is a function in some library, but it's been years since I used this function, and I do not remember

Re: [R] Question related to merging zoo objects and apply function

2009-07-15 Thread Sergey Goriatchev
ly not what you want. > It has the same effect as > > func <- function(x, j) x[72+j] + [144+j] > > On Wed, Jul 15, 2009 at 9:26 AM, Sergey Goriatchev wrote: >> Hello everyone, >> >> Say I have defined a convenience function in my code like this: >> >>

[R] Question related to merging zoo objects and apply function

2009-07-15 Thread Sergey Goriatchev
Hello everyone, Say I have defined a convenience function in my code like this: func <- function(x, j){ x[168+j] <- x[72+j]+x[144+j] } And now I apply it to some columns in a big zoo object like this: for (m in 1:24){ combined <- merge(combined, LA1sum=apply(combined, 1, func,

Re: [R] Ordering zoo-object by its index

2009-07-09 Thread Sergey Goriatchev
wrote: > One additional thought. If the reason you want to do that is > just so that you can see the last few rows more easily then > > tail(Data) > > will display the last few rows or tail(Data, 10) will display > the last 10 rows. > > On Thu, Jul 9, 2009 at 7:36 AM, Ser

Re: [R] Ordering zoo-object by its index

2009-07-09 Thread Sergey Goriatchev
Hi, Gabor Thank you! That is exactly what I did, even before your email. :-) Regards, Sergey On Thu, Jul 9, 2009 at 12:52, Gabor Grothendieck wrote: > To display that object in reverse time order try this: > > as.data.frame(Data)[nrow(Data):1, ] > > > On Thu, Jul 9, 2009

[R] Ordering zoo-object by its index

2009-07-09 Thread Sergey Goriatchev
Hello everyone, Say I have zoo object x.Date <- as.Date("2003-02-01") + c(1, 3, 7, 9, 14) - 1 x <- zoo(rnorm(5), x.Date) y <- zoo(rt(5, df=2), x.Date) z <- zoo(rt(5, df=5), x.Date) Data <- merge(x,y,z) What should I do to make the latest values appear at the top? Thank you for your help! Rega

Re: [R] Need help to optimize a piece of code involving zoo objects

2009-06-22 Thread Sergey Goriatchev
te: > check out 'filter' to see if it does what you want with the 'recursive' > option. > > On Fri, Jun 19, 2009 at 3:33 AM, Sergey Goriatchev > wrote: >> >> Hello, everyone >> >> I have a long script that uses zoo objects. In this script I used

Re: [R] Need help to optimize a piece of code involving zoo objects

2009-06-19 Thread Sergey Goriatchev
away). Do you think this is correct way to do this, or have I missed something? Regards, Sergey On Fri, Jun 19, 2009 at 15:23, jim holtman wrote: > check out 'filter' to see if it does what you want with the 'recursive' > option. > > On Fri, Jun 19, 2009 at 3:33 A

[R] (FULL) Need help to optimize a piece of code involving zoo objects

2009-06-19 Thread Sergey Goriatchev
(Sorry, sent the message before I finished it) Hello, everyone I have a long script that uses zoo objects. In this script I used simple moving averages and these I can very efficiently calculate with filter() functions. Now, I have to use special "exponential" moving averages, and the only way I c

[R] Need help to optimize a piece of code involving zoo objects

2009-06-19 Thread Sergey Goriatchev
Hello, everyone I have a long script that uses zoo objects. In this script I used simple moving averages and these I can very efficiently calculate with filter() functions. Now, I have to use special "exponential" moving averages, and the only way I could write the code was with a for-loop, which

Re: [R] [R-SIG-Finance] Problem with RBloomberg (not the usual one)

2009-03-13 Thread Sergey Goriatchev
http://about.bloomberg.com/contact_softwaresupport_upgr.html > > Good luck. > > Kent > > > -Original Message- > From: Sergey Goriatchev [mailto:serg...@gmail.com] > Sent: Friday, February 27, 2009 1:54 AM > To: r-sig-fina...@stat.math.ethz.ch; r-help@r-project.org > Subject: Re:

Re: [R] Taking diff of character vectors

2009-03-13 Thread Sergey Goriatchev
d(nm2, nm3) > temp<-as.data.frame(sapply(1:ncol(matr), function(.col) { > -1.0*c(0,as.numeric((head(matr[,.col],-1) != tail(matr[,.col],-1 > })) > cbind(matr,temp) > > > > On Fri, Mar 13, 2009 at  5:24 AM, Sergey Goriatchev wrote: >> Hello, everybody >> >&

[R] Taking diff of character vectors

2009-03-13 Thread Sergey Goriatchev
Hello, everybody Say I have nm1 <- c(rep(1,10), rep(0,10)) then I can do: diff(nm1) to see where I have shift in value but what if I have nm2 <- c(rep("SPZ8", 10), rep("SPX9", 10)) how can I produce the same ouput as diff(nm1) does, that is zeros everywhere except for one place where SPZ8 change

Re: [R] Question about multiple plots of zoo objects

2009-03-03 Thread Sergey Goriatchev
bline(v = > time(s)[s > 0], col = "green") } > plot(cbind(x, s), panel = p) > > There are further examples of panel functions in the examples section > of ?plot.zoo > in case what you want is a variation of the above. > > > On Tue, Mar 3, 2009 at 9:04 AM

Re: [R] Question about multiple plots of zoo objects

2009-03-03 Thread Sergey Goriatchev
14:44, Gabor Grothendieck wrote: > Do you mean you want to shade a portion of the plot? > > There are two examples of that in the examples section of ?plot.zoo > and a further example using xyplot.zoo in the examples section of > ?xyplot.zoo > > On Tue, Mar 3, 2009 at 8:37

Re: [R] Question about multiple plots of zoo objects

2009-03-03 Thread Sergey Goriatchev
), screen = c(1, 1, 2), type = c("p", "l", "l"), >  col = list(ifelse(s > 0, "green", "red"), 1, 1), pch = 20) > > > > On Tue, Mar 3, 2009 at 7:48 AM, Sergey Goriatchev wrote: >> Hello, everyone >> >> I have a z

[R] Question about multiple plots of zoo objects

2009-03-03 Thread Sergey Goriatchev
Hello, everyone I have a zoo object containing several time series of daily frequency. One of these timeseries is an indicator function with value (-1) at certain times, and (+1) at the other. I do a plot of several of the timeseries in one go (a multiple plot). I wonder if I can automatically in

Re: [R] Problem with RBloomberg (not the usual one)

2009-02-27 Thread Sergey Goriatchev
??? Best, Sergey On Fri, Feb 27, 2009 at 09:16, Sergey Goriatchev wrote: > Hello, everyone! > > I have a problem with RBloomberg and this is not the usual "no > administrator rights" problem. > > I have R 2.7.2, RBloomberg 0.1-10, RDCOMclient 0.92-0 > > RDCOMCli

[R] Problem with RBloomberg (not the usual one)

2009-02-27 Thread Sergey Goriatchev
Hello, everyone! I have a problem with RBloomberg and this is not the usual "no administrator rights" problem. I have R 2.7.2, RBloomberg 0.1-10, RDCOMclient 0.92-0 RDCOMClient, chron, zoo, stats: these packages load OK. Then, trying to connect, I get following error message: conn <- blpConn

Re: [R] Question about apply()

2009-02-11 Thread Sergey Goriatchev
y be used instead. > > If you did want to use embed then unzoo data first but > that will lose the time index so add it back in later: > > e <- embed(coredata(data),2) > dif <- zoo(e[, 1:4] / e[, 5:8] - 1, time(data)[-1]) > cbind(data, dif) > > On Wed, Feb 11, 2009 at

Re: [R] Question about apply()

2009-02-11 Thread Sergey Goriatchev
ecify a new variable (with suffix ."ret") within merge() function. Kind Regards, Sergey On Wed, Feb 11, 2009 at 13:47, Peter Dalgaard wrote: > Sergey Goriatchev wrote: >> Hello, everyone! >> >> Assume you have this data: >> data <- structure(c(66.609375,

Re: [R] Question about apply()

2009-02-11 Thread Sergey Goriatchev
13:34, Gabor Grothendieck wrote: > See ?diff.zoo > > dif <- diff(data, arithmetic = FALSE) - 1 > cbind(data, dif) > > On Wed, Feb 11, 2009 at 6:21 AM, Sergey Goriatchev wrote: >> Hello, everyone! >> >> Assume you have this data: >> data <- stru

[R] Question about apply()

2009-02-11 Thread Sergey Goriatchev
Hello, everyone! Assume you have this data: data <- structure(c(66.609375, 67.09375, 66.40625, 66.734375, 67.109375, 66.875, 66.09375, 65.921875, 66.546875, 66.140625, 66.140625, 65.65625, 65.875, 65.59375, 65.515625, 66.09375, 66.015625, 66.140625, 66.109375, 66.421875, 1702.7, 1647.7, 1649.4, 16

Re: [R] Replacing dot with empty space

2009-02-10 Thread Sergey Goriatchev
Thanks, Gabor. You are always very helpful. On Tue, Feb 10, 2009 at 12:42, Gabor Grothendieck wrote: > Also, try these alternatives: > > sub(".", " ", x, fixed = TRUE) > chartr(".", " ", x) > > > On Tue, Feb 10, 2009 at

Re: [R] Replacing dot with empty space

2009-02-10 Thread Sergey Goriatchev
OK, got it now: sub("[.]", " ", "ED4.Comdty") On Tue, Feb 10, 2009 at 10:01, Sergey Goriatchev wrote: > Hello, everyone > > How do I replace dot with empty space in "ED4.Comdty"? > I need to get "ED4 Comdty" > tried sub() in many

[R] Replacing dot with empty space

2009-02-10 Thread Sergey Goriatchev
Hello, everyone How do I replace dot with empty space in "ED4.Comdty"? I need to get "ED4 Comdty" tried sub() in many different ways, like sub({.}, " ", "ED4.Comdty") etc but could not do it. Thanks in advance, Sergey __ R-help@r-project.org mailing li

Re: [R] Automatic creation of columns in zoo object

2009-02-03 Thread Sergey Goriatchev
x(0, nrow(me.la), length(nms), dimnames = list(NULL, nms)) > cbind(me.la, zeromat) > > In this case zeromat and me.la have the same dimensions so we could > alternately reduce it to this slightly briefer code: > > zeromat <- 0 * me.la > colnames(zeromat) <- sub(".Comdty&quo

Re: [R] Automatic creation of columns in zoo object

2009-02-03 Thread Sergey Goriatchev
a have the same dimensions so we could > alternately reduce it to this slightly briefer code: > > zeromat <- 0 * me.la > colnames(zeromat) <- sub(".Comdty", "tr", me.la.tickers) > cbind(me.la, zeromat) > > > On Tue, Feb 3, 2009 at 8:44 AM,

[R] Automatic creation of columns in zoo object

2009-02-03 Thread Sergey Goriatchev
Hello, everyone I have a question. Assume I have the following zoo object: me.la <- structure(c(1524.75, 1554.5, 1532.25, 1587.5, 1575.25, 1535.5, 1550, 1493.5, 1492.5, 1472.25, 1457.5, 1442.75, 1399, 1535.75, 1565.25, 1543.5, 1598.5, 1586.5, 1547, 1561.5, 1504.75, 1503.75, 1483.75, 1468.75, 145

Re: [R] Two similar zoo objects with different structures, how to get same structure?

2009-01-21 Thread Sergey Goriatchev
1-14 > 1 2 3 > > On Wed, Jan 21, 2009 at 10:51 AM, Sergey Goriatchev wrote: >> Dear Dr. Grothendieck, >> >> First of all, I realized I did not load zoo package before I tried the >> first str(bldata). If I load zoo and then do str(bldata)

Re: [R] Two similar zoo objects with different structures, how to get same structure?

2009-01-21 Thread Sergey Goriatchev
t;01/08/09" "01/09/09" "01/12/09" "01/13/09" "01/14/09" "01/15/09" "01/16/09" "01/19/09" That is not the same structure, attributes disappeared. What am I doing wrong? Thank you in advance for your help. Reg

[R] Two similar zoo objects with different structures, how to get same structure?

2009-01-21 Thread Sergey Goriatchev
Dear all, I have a zoo object that has following structure: > str(bldata) zoo [1:5219, 1:12] 91.9 91.8 91.7 91.8 91.7 ... - attr(*, "index")=Classes 'dates', 'times' atomic [1:5219] 7305 7306 7307 7308 7309 ... .. ..- attr(*, "format")= chr "m/d/y" .. ..- attr(*, "origin")= Named num [1:3]

Re: [R] Looking for a special date function in R

2009-01-21 Thread Sergey Goriatchev
uot;2009-07-21" > > > On Wed, Jan 21, 2009 at 6:27 AM, Sergey Goriatchev wrote: >> Dear Gabor, >> >> Thanks for that! >> Still, it is not really similar to how EDATE works. >> With julian(Sys.Date(), Sys.Date() - 10) one moves 10 days back. >> The

Re: [R] Looking for a special date function in R

2009-01-21 Thread Sergey Goriatchev
Jan 2009, Sergey Goriatchev wrote: > >> Dear Gabor, >> >> Thanks for that! >> Still, it is not really similar to how EDATE works. >> With julian(Sys.Date(), Sys.Date() - 10) one moves 10 days back. >> The problem is that I need to move by months, not by days,

Re: [R] Looking for a special date function in R

2009-01-21 Thread Sergey Goriatchev
?julian > >> julian(Sys.Date(), Sys.Date() - 10) # 10 > [1] 10 > attr(,"origin") > [1] "2009-01-11" > > and R News 4/1. > > On Wed, Jan 21, 2009 at 4:37 AM, Sergey Goriatchev wrote: >> Hello, everyone >> >> I wonder if R has something s

[R] Looking for a special date function in R

2009-01-21 Thread Sergey Goriatchev
Hello, everyone I wonder if R has something similar to Excel function EDATE(start_date; months) which returns a serial number of the date that is the indicated number of months before of after the start date. Example (the second column EDATE(first_column; -6)): 01.01.1999 01.07.1998 02.02.199

Re: [R] Eclipse and R

2008-08-12 Thread Sergey Goriatchev
4:33 PM, Prof Brian Ripley <[EMAIL PROTECTED]> wrote: > Most internationalized programs (including R) respond to the LANGUAGE > environent variable: have you tried setting it to "en"? > > We would need to know your OS to help more (it looks like it might be > Windows

[R] Eclipse and R

2008-08-12 Thread Sergey Goriatchev
Hello, I am running R in Eclipse, and when I start Eclipse or when I get error messages, they are in German. (My computer's regional language settings are German.) Is there a way to switch to English in Eclipse without changing my global regional language settings? In basic R GUI this is possible

[R] Again question about filter()

2008-08-10 Thread Sergey Goriatchev
Hello, I thought I understood filter() with the help from Prof. Grothendieck, but I guess I did not. For example, how does this work: filter(1:10, c(0.1, 0.5, 1, 0.5), "recursive", init=c(1,2,3,4)) Time Series: Start = 1 End = 10 Frequency = 1 [1] 7.1 6.71000 9.22100 15.87710 21.458

[R] What is filter() function doing?

2008-08-10 Thread Sergey Goriatchev
Hello, I cannot understand what filter() function in package stat is doing. For example, what does filter(1:100, c(1,1,1)) mean? Could someone please explain? Help file is not enough for me. Thanks in advance. Sergey __ R-help@r-project.org mailing lis

[R] Vectorization Problem

2008-03-22 Thread Sergey Goriatchev
I have the code for the bivariate Gaussian copula. It is written with for-loops, it works, but I wonder if there is a way to vectorize the function. I don't see how outer() can be used in this case, but maybe one can use mapply() or Vectorize() in some way? Could anyone help me, please? ## Density

[R] How does do.call() work??

2008-01-25 Thread Sergey Goriatchev
Dear members of R forum, Say I have a list: L <- list(1:3, 1:3, 1:3) that I want to turn into a matrix. I wonder why if I do: do.call(cbind, L) I get the matrix I want, but if I do cbind(L) I get something different from what I want. Why is that? How does do.call() actually work? I've read

[R] Problem implementing adapt()

2007-11-04 Thread Sergey Goriatchev
that's the bvnpdf() code: bvnpdf <- function(xy, mu, Siginv, detSig){ f<-numeric() x <- xy[[1]] if(xy[[1]]>xy[[2]] & (1==2)) { f <- 0} else { v <- rbind(xy[1], xy[2]) e <- t(v-mu) %*% Siginv %*% (v-mu) f <- as.numeric(

[R] Problem implementing adapt()

2007-11-04 Thread Sergey Goriatchev
Hello, I am trying to compute rectangle probability of bivariate normal distribution with the following function: bvnrectangle <- function(mu, Sig, xmin, xmax, ymin, ymax){ library(adapt) Siginv <- solve(Sig) detSig <- det(Sig) areal <- adapt(ndim=2, lower=c(xmin,ymin), upper=c(xmax,ymax), minpts=

[R] Error optimizing Poisson log-likelihood with L-BFGS-B

2007-10-31 Thread Sergey Goriatchev
Dear R users, I have following code, estimating Poisson log-likelihood a number of times: poisson.loglik <- function(mu, y){ n <- NROW(y) logl <- sum(y)*log(mu)-n*mu return(-logl) } estimates <- numeric(1e5) for(i in seq_along(estimates)){ estimates[i] <- optim(par=1, poisson.lo

[R] R does not run my scripts!!!!!

2007-10-26 Thread Sergey Goriatchev
Hello, I have R2.6.0 installed on my laptop (Vista), and I create my scripts in WinEdt. Today I installed R on a stationary PC which runs Windows XP Professional, SP2. For some reason, the script I wrote on my laptop does not run on the stationary machine. I reinstalled R but to no avail. Problem

Re: [R] Strange dataframe behavior

2007-10-23 Thread Sergey Goriatchev
THanks, Chuck! I figured it out already, these were not row numbers at all! It just counted down along the columns. On 10/23/07, Charles C. Berry <[EMAIL PROTECTED]> wrote: > On Tue, 23 Oct 2007, Sergey Goriatchev wrote: > > > Hello, > > > > I have a question

[R] Strange dataframe behavior

2007-10-23 Thread Sergey Goriatchev
Hello, I have a question regarding the following output: > database <- read.delim(file=path.input.file, header=TRUE, dec=".", sep="\t", > na.strings = "#NV") > str(database) 'data.frame': 314 obs. of 13 variables: $ S : Factor w/ 314 levels "307073","400212",..: 147 72 299 137 162 62

[R] Help: Side-by-side named barplot bars

2007-10-18 Thread Sergey Goriatchev
Hello, Let me describe what I have and what I want to do: I have two (7x6) matrices (call them A and B) that have same row and column names (rows=species, columns=variables) but contain numerical values that differ (same experiment done twice and values calculated and put in different matrices).

[R] automaticly adjust coordinates for text() labels

2007-10-17 Thread Sergey Goriatchev
Hello, I have following problem. I produce a histogram of some values and in the plot area I create 2 text boxes - one with names of statistics and one with values of these statistics. Coded like that: ht <-hist(x, ) ... ameant <-ameant <- paste("Ar.Mean") ... amean <- round(mean(x), digits=

[R] Converting to mode numeric within a matrix

2007-09-28 Thread Sergey Goriatchev
Hello, I create a matrix: best <- matrix(0, ncol=2, nrow=num.selected, dimnames=list(the.best$.Name, c("Probability(%)", "Inside"))) best[,1] <- as.numeric(the.best$Total*100) best[,2] <- ifelse(the.best$Weight==0, "No", "Yes") What I want is the second column of mode numeric, but it is of mod

[R] Creating nice looking lists: how?

2007-09-28 Thread Sergey Goriatchev
Hello, For my functions I want to create output similar in appearance to that of what you get when you print a summary of lm model: Residuals: Min1Q Median3Q Max -0.209209 -0.043133 0.001793 0.044105 0.234750 Coefficients: Estimate Std

[R] Root finding problem

2007-09-24 Thread Sergey Goriatchev
Hello, I have a problem finding a root of a function, which I define like this: tuki <- function(u, x, a, lambda){ if((lambda%%1>0) & u<0) {u<-(u+0i)} f <- Re(x-(a*(u)^lambda-(1-(u))^lambda)/lambda) f } What I want to do is to find the root, but without specifying the interval within which to se

[R] Problem updating packages

2007-09-18 Thread Sergey Goriatchev
Hello, everybody I have R 2.5.1 now installed on a laptop with Windows Vista Home Premium. I have problems updating the packages. Here is what I get at the prompt when I try to update: > update.packages(ask='graphics') --- Please select a CRAN mirror for use in this session --- trying URL 'http:

[R] Integrate() error message, I am at a loss

2007-09-11 Thread Sergey Goriatchev
Hello! I have a problem with integrate() in my function nctspa(). Integrate produces an error message "evaluation of function gave a result of wrong length". I don't know what that means. Could anyone suggest me what is wrong with my function? These are the examples of function calls that work OK

[R] Problem with integrate()

2007-09-11 Thread Sergey Goriatchev
Hello! I have a problem with integrate() in my function nctspa(). Integrate produces an error message "evaluation of function gave a result of wrong length". I don't know what that means. Could anyone suggest me what is wrong with my function? These are the examples of function calls that work OK