HN user

agentq

59 karma

Trader

Posts0
Comments38
View on HN
No posts found.

I researched & prototyped (in R), and ultimately put into production (C++) a core set of spectral risk analysis analytics that replaced outdated VaR and vol forecasts for an extremely large asset management firm and left immediately afterwards. Technically speaking, guided risk mgmt/investment decisions at the trillion-dollar scale, ran as-is for 8-10 years before being recently re-implemented in some other language.

I actually find base R excellent for data munging and manipulation, even without using additional packages. Here is a reproducible example that very easily accomplishes what you were trying to do (first two lines just set up a sample data frame)

  set.seed(123)
  dfrm <- data.frame(height=runif(20),
                     name=paste(sample(LETTERS[1:5],20,replace=TRUE),letters[1:20]))
  subset(dfrm, grepl('^D',name), sel=height)
Basic R functions like subset, transform, with(in), reshape, aggregate, (a,ma,ta,sa,va}pply, match, grep(l), by, split, table, etc. allow you to accomplish just about any data frame munging you might want. Add on the plyr, reshape2, data.table, xts/zoo packages and you're ready to tackle just about anything.

I'm not a big fan of sqldf because imo R is not supposed to act like SQL. Using sqldf in practice would require a lot of query string manipulation and takes away from the nice functional features of R.

Nevertheless, it is very easy to write incomprehensible R code. The best way to avoid this is to take one of the existing style guides (Google, Hadley Wickham's) and adopt it seriously.

In financial practice, asset-level PCA isn't as common, especially in systems where covariance estimation is fraught with misspecification errors. Instead, individual securities first condensed to factors (e.g., for equity some examples are book/price, momentum, large vs. small cap, etc.).

To further goad the OP to immediately leave his current job: between junior and senior year of college, I made a bit more than the OP's yearly pay in a 12wk internship.

Please, for your wife and kid(s), get out of this horrible situation.

Why R Doesn't Suck 16 years ago

My programming background is fairly extensive in non-functional languages. I work in finance, and the company I joined uses R for a considerable amount of model prototyping.

I'd really like to switch to Python+numpy/scipy, but I haven't been able to find an equivalent of a data.frame, or some numeric+string data structure that allows for easy slicing on both.

Does anybody have any suggestions?

In the particular case of integer ids, however, can't you just make sure what's being passed is an integer? Similarly, for a 'simple' username, check against "^[a-zA-Z0-9]+$"?