Displaying 20 results from an estimated 500 matches similar to: "Any function to calculate returns"
2008 Sep 11
5
How to obtain a sequence of dates consisting of only weekdays
Dear R-users,
How do I obtain a sequence of dates consisting of only weekdays without the weekends in R?
In S, I can do the following:
timeSeq(from="12/17/2007", to="8/25/2008", by="weekdays")
I tried using looking at timeSequence (fSeries package) and seq.Date (base package) but I do not know if I can specify "weekdays" rather than "day".
2008 Sep 04
1
text file imported incorrectly
Dear R-users,
When I tried to import a text file (tab delimited) which has 2000+ rows with the following command (With the importData in S, it works though),
x <- read.table(textfile, sep= "\t", skip=5, stringAsFactors=F)
I received the following warning message: Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,: number of items read is not a multiple of
2007 Nov 08
1
Bug (?) in read.fwf
Hi,
I'm trying to use read.fwf
temp = read.fwf ("Raw data.txt", widths = c (11, 21, 10, rep
(16, 6)) ,skip = 2, n = 2, stringsAsFactors = FALSE, strip.white = TRUE)
but no matter what I do the strings are turned into factors. I believe
it's the "n=2" parameter that causes the problem as it seems to work
without this. Am I missing something?
Thanks in advance,
2007 Feb 05
2
Rconsole - setting the size and location of Windows help files (Rgui)
Hi,
Using the Rconsole file I can specify the size and location of the Rgui
windows on NT.
e.g.
# Dimensions (in characters) of the console.
rows = 51
columns = 100
How can I specify the size of the help windows that popups
when I ask for help? e.g. '?help'
I would like the popup window to have say rows = 51 and columns = 100,
just like the main window but a different location on the
2008 Aug 11
1
A zoo question / problem
Hi
I'm having a problem using the zoo library and I can't see what I'm
doing wrong. For example setting up the data
> t1 = zoo (matrix (1:12, nrow = 3), order.by = as.Date
(c("2008-08-01","2008-08-02","2008-08-03")))
> colnames (t1) = c ("A", "B", "C", "D")
> t2 = zoo (matrix (1:12, nrow = 3), order.by =
2010 Oct 28
1
Key combination that removes all R objects
Dear readers,
There is a combination of keys that I have (on several occasions now)
typed by accident into R (2.10.0) which removes all the objects in the
environment, and clears the console, as though I had typed
rm(list=ls()).
Unfortunately I don't know what the combination of keys are, so I am
struggling to find out more about this behaviour on my own and I was
hoping that someone has
2010 Oct 27
2
Which version control system to learn for managing Rprojects?
Gabor
As someone trying to the rest of my team using Subversion (which I have used for a while, but more as a backup / record of changes), have you a neat / automated way of building a package from a subversion repository?
Thanks
David Jessop
--------------------------
David Jessop
Global Head of Quantitative Research
UBS Investment Research
+44 20 7567 9882
----- Original Message -----
2006 Sep 28
2
calling R from within Java, using jri
Hi,
I want to call R from within Java, using jri as per
http://www.rosuda.org/software/jri/
So I am following the instructions in the README file for JRI 0.2-4.
I have run 'sh configure.win' and 'make' and they seemed to be
successful.
(See below for the output from make, for example.)
But when I try 'run.bat rtest' (with and without R command line
arguments)
the output
2016 Apr 22
0
non-numeric argument to binary operator problem in stock analysis
I use these codes to get the returns of my simulated portfolio
but, I can not get returns as the non-numeric argument to binary operator problem in stoc
thank you guys first.
library(quantmod)library(quadprog)library(stockPortfolio)library(fPortfolio)library(tseries)source("efficientFrontierFunction.r")
myenv <- new.env()##Calculate the mean and sd of the monthly returns of each
2007 Jul 31
0
R Programmer - finance - London based
Hi,
UBS Investment Bank are looking for a skilled R programmer,
seeking a career that combines computer science, applied statistics and
finance.
This position requires a person with a strong background in
- R programming and R package maintenance.
- Software development.
- Design and implementation of efficient algorithms.
especially for handling large datasets.
- Data visualisation and
2015 Jun 25
3
[Bug 2418] New: sftp-server connection closed upon openssh6.8P1 upgrade
https://bugzilla.mindrot.org/show_bug.cgi?id=2418
Bug ID: 2418
Summary: sftp-server connection closed upon openssh6.8P1
upgrade
Product: Portable OpenSSH
Version: 6.8p1
Hardware: Sparc
OS: Solaris
Status: NEW
Severity: enhancement
Priority: P5
Component: sftp-server
2011 Feb 17
1
How to speed up a for() loop
Dear all,
Does anyone have any idea on how to speed up the for() loop below.
Currently it takes approximately 2 minutes and 30 seconds.
Because of the size of Nsim and N, simulating a multivariate normal
(instead of simulating Nsim times a vector of N normal distributions)
would require too much memory space.
Many thanks for your kind help,
Simona
N=3000
PD=runif(N,0,1)
cutoff.=qnorm(PD)
2008 Dec 05
1
Cartesian Product Of Character Vectors
Hi all
(I'm sure this question has been asked before, but I cant find it).
If I have two character vectors:
> x <- c("aaa","bbb","ccc")
> y <- c("1","2","3")
How can I get the cartesian product of the string values?
> expand.grid(x,y)
Gives me a data frame with separate columns...however, I cant seem to get *apply
2008 Apr 09
11
Number of words in a string
Hi R,
A quick question: How do we find the number of words in a string?
Example:
C="Have a nice day"
And the number of words should be 4. any built in function or?...
Thanks, Shubha
Shubha Karanth | Amba Research
Ph +91 80 3980 8031 | Mob +91 94 4886 4510
Bangalore * Colombo * London * New York * San José * Singapore * www.ambaresearch.com
This e-mail may contain
2004 Sep 29
2
defining a template for functions via do.call and substitute.
Hi,
Given a function
fun <- function(a, b) a + b
how do I generate the function 'function(x, y) x + y'?
Working from the help files and Bill Venables' R-news article (June 2002),
I have tried various permutations with substitute without success.
e.g.
do.call("substitute", list(fun, list(a = as.name("x"), b = as.name("y"))))
Regards,
John.
2006 Jun 19
1
lattice xyplot - aligning date labels so that they align with the grid lines in panel.grid
Hi,
I have a basic question about aligning date labels for the x-axis
in an xyplot so that they align with the grid lines
from the panel.grid argument.
For example, with
x <- data.frame(
date = seq(as.Date("2005/01/01"), as.Date("2006/06/01"),
length.out = 20), value = runif(20))
xyplot(value ~ date, data = x,
panel = function(x, y, subscripts, ...)
{
2008 Nov 25
3
Line color based on data values?
Hi all
Does anyone know if it is possible when plotting a line or scatter plot, to selectively color the data points based on the data value? i.e. if plotting say the percentage change in stock price movements, to color +ve points in green and -ve points in red? And extending this to a user-defined range of colors based on the quartile of the data points?
Thanks
Rory
Rory Winston
RBS Global
2008 Dec 05
1
Lexical Permutation Algorithm in R
Hi all
Here is a rather naive implementation of the SEPA algorithm for generating lexical permutations:
lexperm3 <- function(x, n=length(x)) {
perms <- list()
k <- 1
perms[[k]] <- x
k <- k + 1
for (y in 1:(factorial(n)-1)) {
i <- n-1
while (x[i] > x[i+1] && i > 0) {
i <- i - 1
}
# i is largest index st x[i] > x[i+1]
j <- n
#
2004 Oct 06
3
lapply with argument "X"
Hi,
I am probably making a simple mistake but I can't see it
> X
Error: Object "X" not found
> exists("X")
[1] FALSE
> lapply("X", exists)
[[1]]
[1] TRUE
Why is lapply producing true?
Is it something to do with the first
argument of lapply also being called 'X'?
> version
_
platform i386-pc-mingw32
arch i386
2004 Sep 29
2
defining a template for functions via do.call and substit ute.
Here's one not-so-straightforward way:
> f <- function(a, b) a + b
> flist <- as.list(f)
> names(flist)[1:2] <- c("x", "y")
> flist[[3]] <- do.call("substitute", list(body(f), list(a=as.name("x"),
b=as.name("y"))))
> g <- as.function(flist)
> g
function (x, y)
x + y
HTH,
Andy
> From: john.gavin at ubs.com