Re: [R] Transformations in Tidyverse (renaming and ordering columns)

2018-10-22 Thread John Laing
I don't know much about the Tidyverse, but more generally the way to represent ordered categorical data is with a factor. This seems to work: > testset$Observation <- factor(testset$Observation, levels=c("One", "Two", "Three")) > testset$Label <- factor(testset$Label, levels=c("Western", "Northern

Re: [R] Rbbg usurped ?

2016-12-28 Thread John Laing
I've cleaned up the findata repository, you should now be able to install Rbbg as expected. But that said, the package is no longer being actively developed. Recent efforts have been taking place in the Rblpapi package. The interface is similar, though not strictly compatible. If you're doing much

Re: [R] Getting rid of unwanted csv files

2015-11-18 Thread John Laing
?file.info On Wed, Nov 18, 2015 at 6:12 AM, WRAY NICHOLAS wrote: > Hi I have got a large folder with hundreds of csv files in it The > problem is > that some of them are junk, and I know which ones are junk because they > were > created on certain days, that is before I had honed the programme

Re: [R] Transfer a 3-dimensional array to a matrix in R

2015-10-20 Thread John Laing
> x <- array(1:18, dim=c(3, 2, 3)) > x , , 1 [,1] [,2] [1,]14 [2,]25 [3,]36 , , 2 [,1] [,2] [1,]7 10 [2,]8 11 [3,]9 12 , , 3 [,1] [,2] [1,] 13 16 [2,] 14 17 [3,] 15 18 > apply(x, 3, t) [,1] [,2] [,3] [1,]17 13

Re: [R] A problem with string handling to make a time duration

2015-05-04 Thread John Laing
Regular expressions are the tool for this problem. This pattern matches your input data: t <- c("10H20M33S", "1H1M", "1M", "21M9S", "2H55S") patt <- "^(([0-9]+)H)?(([0-9]+)M)?(([0-9]+)S)?$" all(grepl(patt, t)) # TRUE We can use the pattern to extract hour/minute/second components hms <- lapply(c

Re: [R] duplicated function

2014-11-18 Thread John Laing
That seems straightforward enough: > x <- c(7, 7, 7, 2, 3, 2) > match(x, x) [1] 1 1 1 4 5 4 > ifelse(duplicated(x), match(x, x), 0) [1] 0 1 1 0 0 4 On Tue, Nov 18, 2014 at 10:40 AM, Duncan Murdoch wrote: > On 18/11/2014 10:23 AM, Dennis Fisher wrote: >> >> R 3.1.1 >> OS X >> >> Colleagues >> >> W

Re: [R] xts Annual series

2014-04-08 Thread John Laing
At first pass it would seem that 'integer' would make a perfectly fine year class. But for some reason it's disallowed: > xts(rnorm(8), 2000L:2007) Error in xts(rnorm(8), 2000L:2007) : order.by requires an appropriate time-based object Which is a bit unexpected, since xts descends from zoo and

Re: [R] failure to connect to Bloomber using Rbbg from batch script on Windows

2013-02-05 Thread John Laing
Andre, Does the batch script always fail, or is it sometimes successful? You've probably tried running in batch and interactively one after the other, but if not please do that to make sure it isn't a timing issue with the Bloomberg connection. Also, you can turn up the logging in Rbbg: conn <- b

Re: [R] Rbbg for 2.15.2

2013-01-15 Thread John Laing
Tolga, The Rbbg binary for 2.15 works for the .0, .1, and .2 minor versions. The issue here is probably a change to the install.packages function that was introduced in R 2.15.2. You can get around this by first calling R> options(install.packages.check.source = "no") and then following with the

Re: [R] littler and rJava

2012-08-27 Thread John Laing
Hi Dirk, Thanks for the quick reply. Setting LD_LIBRARY_PATH does the trick, so I can get by with that in my environment. I would be happy to look into potential improvements. The ./configure may work, but I installed littler through the debian package and thus bypassed manual configuration. I'll

[R] littler and rJava

2012-08-27 Thread John Laing
Hello list, I'm having some difficulty getting rJava to load in littler. Even after a R CMD javareconf and a reinstall of littler, I get this: jlaing@xenon:~$ r -e "require(rJava)" Loading required package: rJava Loading required package: methods Error : .onLoad failed in loadNamespace() for 'rJav

Re: [R] Problem to establish Bloomberg connection / Package RBloomberg / function blpConnect()

2012-07-09 Thread John Laing
7.0_05-b05) > Java HotSpot(TM) Client VM (build 23.1-b03, mixed mode, sharing) > > Thanks, > Alex > > -Ursprüngliche Nachricht- > Von: John Laing [mailto:john.la...@gmail.com] > Gesendet: Montag, 9. Juli 2012 13:14 > An: Alexander Erbse > Cc: r-help@r-project.org

Re: [R] Problem to establish Bloomberg connection / Package RBloomberg / function blpConnect()

2012-07-09 Thread John Laing
Alexander, I agree, this feels like a java version issue. You could start by telling us what version of Java you're running: open a command prompt and type java -verision, and reply with the output. I think any version 1.5 and up should work, but let's see what you have. -John On Mon, Jul 9, 201

Re: [R] What is the most cost effective hardware for R?

2012-05-09 Thread John Laing
For 200,000 analyses at 1.5 seconds each, you're looking at ~83 hours of computing time. You can buy time from Amazon at roughly $0.08 / core / hour, so it would cost about $7 to run your analyses in the cloud. Assuming complete parallelization you could fire up as many machines as you need to get

Re: [R] API Baddperiods in RBloomberg

2012-04-05 Thread John Laing
The binaries for RBloomberg are hosted on findata.org. The package is only useful in combination with a Bloomberg terminal, but users who have access to one should not be deterred by its absence from CRAN. John On Thu, Apr 5, 2012 at 12:18 PM, Prof Brian Ripley wrote: > On 05/04/2012 08:54, arva

Re: [R] Bloomberg API functions BAddPeriods Binterpol Bcountperiods in RBloomberg

2012-04-05 Thread John Laing
Hello, These functions are not available in RBloomberg. As far as I can tell, Bloomberg does not expose these functions in the general API; they are specific to the Excel version. R has other mechanisms for performing date arithmetic, both in the Date class and the POSIXct/POSIXlt classes. This w