[R] string split at xth position

2013-03-13 Thread Keith Weintraub
Here is another way require(stringr) aaa<-paste0("a", 1:20) bbb<-paste0("b", 101:120) ab<-paste0(aaa,bbb) ab ptrn<-"([ab][[:digit:]]*)" unlist(str_extract_all(ab, ptrn)) > Hi, > > I have a vector of strings like: > c("a1b1","a2b2","a1b2") which I want to spilt into two parts like: > c("a1"

Re: [R] What happened to "financial" package?

2013-02-27 Thread Keith Weintraub
is still a problem please let me know. Also I read the digests daily. What is the best way to reply to a message in the digest? Thanks for the help, KW > On 26/02/2013 14:45, Keith Weintraub wrote: >> Folks, >> I have been using the cf function from the "financial" pack

[R] What happened to "financial" package?

2013-02-26 Thread Keith Weintraub
Folks, I have been using the cf function from the "financial" package for a few years now. Upon updating my version of R to ... I found that the package no longer exists in the main collection of R packages. Has this package been renamed or merged with another package? If the functionality i

[R] Packages with functionality related to Oil/Gas exploration

2013-01-30 Thread Keith Weintraub
Folks, As the subject describes: I would like to know if there are packages that have functionality tailored for standard Oil/Gas exploration and monetization. Thanks, KW -- [[alternative HTML version deleted]] __ R-help@r-project.org maili

Re: [R] Query on package to use for investment quotes

2013-01-29 Thread Keith Weintraub
Bruce, Have you looked at the Edgar database here: http://www.sec.gov/edgar.shtml You should be able to get daily mutual fund quotes. KW -- [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mail

[R] How do I get Garamond font in R?

2013-01-17 Thread Keith Weintraub
Folks, I run R on a early 2009 MacBook Pro running Mountain Lion. I have a bunch of fonts in my user Library one of which is Garamond. I have tried the ttf_import function to no avail. I played with this for a couple of hours at least and I have gotten nowhere. Here is a bit of one of my sess

[R] Question about VAR (Vector Autoregression) in differences.

2012-11-21 Thread Keith Weintraub
Folks, I have been using the VAR {vars} program to find a fit for the following bi-variate time series (subset): bivariateTS<-structure(c(0.950415958293559, 0.96077848972081, 0.964348957109053, 0.967852884998915, 0.967773510751625, 0.970342843688257, 0.97613937178359, 0.980118627997436, 0.98

Re: [R] Creating yyyymm regexp strings on the fly for aggregation.

2012-11-09 Thread Keith Weintraub
names(res) <- as.integer(names(res)) + 1L >res > } > > fun(2010:2011, 1) > fun(2010:2011, 2) > fun(2010:2011, 4) > fun(2010:2011, 12) > > > Hope this helps, > > Rui Barradas > Em 09-11-2012 03:39, Keith Weintraub escreveu: >> Folks, >>

[R] Creating yyyymm regexp strings on the fly for aggregation.

2012-11-08 Thread Keith Weintraub
Folks, This question is somewhat related to a previous posting of mine. I just can't seem to create a generic solution. Here is a function that I found searching around the internet: splitIt <- function(x, n) {split(x, sort(rank(x) %% n))} I use it like so: > splitIt(1:12, 2) $`0` [1] 1 2 3 4

Re: [R] Aggregate data frame across columns

2012-11-07 Thread Keith Weintraub
Arun, Jeff, Bert, Thanks for your help. I have put a subset of my data below in mySubset. I would like to be able to sum the rows by year. In this case the results would be the result data.frame below. How can I automate something like this and how would I do it quarterly if necessary. The

[R] Aggregate data frame across columns

2012-11-07 Thread Keith Weintraub
Folks, I have a data frame with columns 200401, 200402, ..., 201207, 201208. These represent years/months. What would be the best way to sum these columns by year? What about by quarter? Thanks for your time, KW -- [[alternative HTML version deleted]] __

[R] Estimating credit card default probabilities.

2012-10-25 Thread Keith Weintraub
Folks, I am working on a credit card defaults and transition probabilities. For example a single credit card account could be in a number of states: up-to-date, 30, 60, 90 days in arrears or in default. * Are there packages in R that do estimation of the transition probabilities given historica

[R] mach_override.c

2012-08-29 Thread Keith Weintraub
Folks, I just upgraded my Mac to Mountain Lion and on running R.app I get the following message: mach_override: some instructions unknown! Need to update mach_override.c err = f801 /Volumes/Haxdisk/Projects/DefaultFolderX/DFCarbonPatch/../../Libraries/mach_star-1.2-intel-0.3/mach_override/m

Re: [R] Scaling a "density".

2012-06-19 Thread Keith Weintraub
X 77843-4352 > >> -Original Message- >> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- >> project.org] On Behalf Of Keith Weintraub >> Sent: Tuesday, June 19, 2012 11:00 AM >> To: Bert Gunter >> Cc: r-help@r-project.org >> Subject: Re: [R] Sc

Re: [R] Scaling a "density".

2012-06-19 Thread Keith Weintraub
you > actually have by employing complex (if possible) statistical methods. * > > -- Bert > > * A common practice in many scientific fields these days, I admit. One would > hope that practical arenas like yours would avoid this, however. > > > > On Tue, Jun 19, 2012

[R] Scaling a "density".

2012-06-19 Thread Keith Weintraub
Folks, I have a small dataset of counts of recoveries on defaulted loans: recoveries<-structure(c(0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 0, 0, 0, 0, 0, 4, 0, 1, 2, 2, 12), .Dim = c(11L, 2L), .Dimnames = list( NULL, c("pcts", "counts"))) Here is the data in columnar form:

Re: [R] Divide all rows of a data frame by the first row.

2012-06-15 Thread Keith Weintraub
##.#. Live Go... > Live: OO#.. Dead: OO#.. Playing > Research Engineer (Solar/BatteriesO.O#. #.O#. with > /Software/Embedded Controllers) .OO#. .OO#. rocks...1k > -

[R] Divide all rows of a data frame by the first row.

2012-06-14 Thread Keith Weintraub
Folks, I call the function calcAmorts like so: calcAmorts(prevAm, amort, myDates) Note that I use the package lubridate. The last line where do.call is called to first divide all the rows by the first row and then rbind gives the following error: Error in do.call("rbind", apply(amor

[R] GSL Random Number generation and Quasi-Random Sequences.

2012-06-05 Thread Keith Weintraub
Folks, Can you point me to any examples of using the GSL library to generate correlated uniform random variables? I want to generate correlated defaults among portfolios of loans. Currently I generate simulations by using rmvsnorm (and then inverting using the standard normal distribution func

[R] Scraping a web page.

2012-05-16 Thread Keith Weintraub
trings with substring() or gsub() or any wrapper of those functions. There are many benefits of parsing the HTML, including not falling foul of "as far as I can tell the the tag is always on it's own line" being not true. D. On 5/15/12 4:06 AM, Keith Weintraub wrote: > Than

[R] Getting reliable financial ratios

2012-05-16 Thread Keith Weintraub
Check out this site: http://www.gummy-stuff.org/Yahoo-data.htm It shows how to download a .csv file with the data you might want. Here is an example URL: http://finance.yahoo.com/d/quotes.csv?s=XOM+BBDb.TO+JNJ+MSFT&f=snd1l1yrr2 The "r2" in the above URL means P/E ratio. You should be able to

Re: [R] Scraping a web page.

2012-05-16 Thread Keith Weintraub
Thanks Gabor, Nifty regexp. I never used strapplyc before and I am sure this will become a nice addition to my toolkit. KW Message: 5 Date: Tue, 15 May 2012 07:55:33 -0400 From: Gabor Grothendieck To: Keith Weintraub Cc: r-help@r-project.org Subject: Re: [R] Scraping a web page. Message-ID

Re: [R] Scraping a web page.

2012-05-15 Thread Keith Weintraub
Thanks, That was very helpful. I am using readLines and grep. If grep isn't powerful enough I might end up using the XML package but I hope that won't be necessary. Thanks again, KW -- On May 14, 2012, at 7:18 PM, J Toll wrote: > On Mon, May 14, 2012 at 4:17 PM, Keith Wei

[R] Scraping a web page.

2012-05-14 Thread Keith Weintraub
Folks, I want to scrape a series of web-page sources for strings like the following: "/en/Ships/A-8605507.html" "/en/Ships/Aalborg-8122830.html" which appear in an href inside an tag inside a tag inside a table. In fact all I want is the (exactly) 7-digit number before ".html". The good new

Re: [R] Approximately how big is an installation of all packages.

2012-04-17 Thread Keith Weintraub
16:16, Keith Weintraub wrote: Can you tell me the size of those 3 packages separately? These are 5000 packages. If you want to kniow, why don't you try out? I have them in one library only. Uwe Ligges That is CRAN, BioC software, BioC data. If you can only give me CRAN vs the rest that&

Re: [R] Approximately how big is an installation of all packages.

2012-04-16 Thread Keith Weintraub
Can you tell me the size of those 3 packages separately? That is CRAN, BioC software, BioC data. If you can only give me CRAN vs the rest that's fine too. Whatever is easiest. Thanks, KW -- On Apr 16, 2012, at 9:12 AM, Uwe Ligges wrote: > > > On 16.04.2012 00:16, Keith W

[R] Approximately how big is an installation of all packages.

2012-04-15 Thread Keith Weintraub
Folks, If you know the answer great. If you can tell me which command to use to find out that information please let me know. If this is the wrong forum, my apologies. Thanks, KW -- [[alternative HTML version deleted]] __ R-help@r-project

[R] Plot method for ca.jo

2012-03-20 Thread Keith Weintraub
Folks, How would I find the code for a plot function that is in a package? I want to understand exactly what is being plotted. Thanks, KW -- [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mai

[R] Simulating a VECM process.

2012-03-12 Thread Keith Weintraub
Folks, I have been working on VAR and VECM models and trying to simulate the results. This is easy to do with a VAR model (in the "vars" package) as the covariance matrix is easily extracted. Unfortunately I can't figure out how to do this with a VECM fit. I have used vec2var and created the

[R] Time series and logs.

2012-03-09 Thread Keith Weintraub
Folks, This is more of a stat question than an R question. Apologies in advance! Suppose I fit an AR(1) to a time-series and also fit an AR(1) to the logs of the same time-series and then simulate future paths. In my case I see a big difference in the resulting paths. If I simulate thousands

[R] Simulate values from VAR

2012-02-29 Thread Keith Weintraub
Folks, What is the best way to simulate values from a fitted "VAR {vars}" model. Also I have tried to use SVAR for a cointegration fit of y~x (just two univariate time-series) but I can't figure out how to set up the "A" matrix so that x_t can be used as a contemporaneous predictor of y_t. Th

[R] Create a function "automatically" from lm formula and coefficients?

2012-02-29 Thread Keith Weintraub
I hope the subject says it all. I want to be able to use an lm object and the associated coefficients to create function that can produce "expected" "y" values given inputs. Thanks, KW -- [[alternative HTML version deleted]] __ R-help@r-pr

Re: [R] Problem building up ggplot graph in a loop.

2012-02-16 Thread Keith Weintraub
8833129 "3",0.17,0.00024891450838,0.00125478603676572 "4",0.18,8.62700534705944e-05,0.000575729980347196 "5",0.19,2.71841670884316e-05,0.000251684211328049 Here is the CSV file. I hope it's OK to send it to the mailing list. Thanks again, KW -- On Feb 16, 2012,

[R] Problem building up ggplot graph in a loop.

2012-02-16 Thread Keith Weintraub
Folks, I want to automate some graphing using ggplot. Here is my code graphChargeOffs2<-function(coffs) { ggplot(coffs, aes(levels)) dataNames<-names(coffs)[!names(coffs) == "levels"] for(i in dataNames) { thisData<-coffs[[i]] last_plot() + geom_line(aes(y = thisData, colour = i))

[R] Is it possible or has it been done?

2012-02-12 Thread Keith Weintraub
A port of R to iOS? Thanks for your time, KW -- [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htm

[R] Best way to remove all objects but leave the functions in a workspace.

2012-02-07 Thread Keith Weintraub
I think the subject says it all. Thanks in advance, KW -- [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting

[R] Can "prototype" and "initialize" coexist?

2012-01-10 Thread Keith Weintraub
Folks, My object oriented background is in Java and C++. I am a novice to using S4/object-oriented coding in R but not to R. Below is an example that I found that I have expanded on. I am not getting how "prototype" and "initialize" work together, if at all. Here is output from a short "sessi