Hi everybody,
I'm trying to implement a variable exponential moving average on a time series of intraday data (i.e 10 seconds). By variable, I mean that the size of the window included in the moving average depends on another factor (i.e. volatility). I was thinking of the following:
MA(t)=alpha(t)*price(t) + (1-alpha(t))MA(t-1),
whe...
Suppose you have a list of values
x <- list(a=c(1,2,3), b = c(2,3,4), c=c(4,5,6))
I would like to find unique values from all list elements combined. So far, the following code did the trick
unique(unlist(x))
Does anyone know a more efficient way? I have a hefty list with a lot of values and would appreciate any speed-up.
...
Is there a way to produce a PDF of a table from R in the same way you produce a plot (ie with pdf() or ggsave())? I realize there are ways with other programs (using sweave etc.), but I would like to produce it just from R.
...
I recently investigate a integration between ruby and R on Windows 7. So far, rinruby hangs (on my Windows7 machine) when I run a script. Now I learn from this post that rsruby does not work on Windows at all. Does anybody know a library that would work?
...
I have question about ddply and subset.
I have dataframe df like this :
df <- read.table(textConnection(
" id v_idn v_seed v_time v_pop v_rank v_perco
1 15 125648 0 150 1 15
2 17 125648 0 120 2 5
3 18 125648 0 100 3 6
4 52 125648 0 25 4 ...
I'm trying to find the maximum diagonal product of 2 digit numbers in a 20x20 matrix.
This gives an error message :
i <- 17:1
z <- for (j in 1:(18-i))
{b <- max ((x[i,j]*x[i+1,j+1]*x[i+2,j+2]*x[i+3,j+3]))}}
But this doesn't:
z <- for (i <- 17:1)
{for (j in 1:(18-i))
{b <- max ((x[i,j]*x[i+1,j+1]*x[i+2,j+2]*x[i+3,j+3...
hello,
here is my question:
i have these data
summary(data)
Date
1990/01: 1
1990/02: 1
1990/03: 1
1990/04: 1
1990/05: 1
1990/06: 1
(Other):242
attribute
Min. :164.9
1st Qu.:201.5
Medi...
I have a simple R beginner's question:
How do I express the sum below most concisely in R?
sum_{i=1}^n a / (a+i)
I tried the following, but there must be a better way, without actually calling for:
r<-0
for(i in 1:n){ r <- r + (a / (a+i)) }
Thanks!
...
I think this is very easy but my R kung-fu is weak. I'm trying to create a vector of itself in a cumulative way. This code works but I'd like something much more elegant and automated. I have millions of rows that need to be cumulated.
a <- c(4,4,5,1,9)
a <- a[order(-a[])]
k <- a[1:length(a)]/sum(a)
w <- c(k[1],k[1]+k[2],k[1]+k[2]+k[3],...
I haven't quite got my head around R and how to rearrange data. I have an old SPSS data file that needs rearranging so I can conduct an ANOVA in R.
My current data file has this format:
ONE <- matrix(c(1, 2, 777.75, 609.30, 700.50, 623.45, 701.50, 629.95, 820.06, 651.95,"nofear","nofear"), nr=2,dimnames=list(c("1", "2"), c("SUBJECT","A...
Hello
Why this works:
ncota <- 1
nslope <- 29
resul <- matrix(rep(0,ncota*nslope*4),ncota*nslope,4)
But this doesn't?
ncota <- 1
sini <- 0.1; sfin <- 1.5; spaso <- 0.05; nslope <- 1+((sfin-sini)/spaso)
resul <- matrix(rep(0,ncota*nslope*4),ncota*nslope,4)
I guess the problem is that the division gives a noninteger number.
How can ...
I've been using R in Ubuntu to make system calls using system() for things like spinning up Amazon EC2 instances, managing files on S3, etc. If I start R from the command line everything works fine. But if I start R from a script using Rscript, or from ESS, I have issues with environment variables not being set.
I think this is an issu...
Hi everyone!
How to create an "empty object" in R? [edit: I don't know how to rightly call this "thing" so I am calling it "empty object", others: "empty symbol", "zero length symbol", "missing object" might also be used]
[edit2: finally I tend to settle down on the "missing symbol object" for the name of the "thing". It also appears t...
I have data that looks like this:
model aspect cover contour
1 flowering ~ 1 2 52 2400
2 flowering ~ 1 + temp + precip:temp 1 52 2390
3 flowering ~ 1 + temp + precip 1 52 2390
4 flowering ~ 1 + temp + precip 1 52 2390
5 f...
Hi, I am looking for the ggplot way to plot a probability density function (or any function). I used to use the old plot() function in R to do this. For example, to plot a beta distribution with alpha=1 and beta=1 (uniform):
x <- seq(0,1,length=100)
db <- dbeta(x, 1, 1)
plot(x, db, type='l')
How can I do it in ggplot? Thank you!
...
I have millions of Keywords in a column labeled Keyword.text. Each factor or Keyword can contains multiple words (or shall we say token). Here is an example with 4 keywords
Keyword.text
The quick brown fox the
.8 .crazy lazy dog
dog
jumps over+the 9
I'd like to count the number of tokens in each Keyword, so as to obtain:
Keyword.lengt...
Also, would it be illadvised to use RExcel for corporate work? Also, what are some advantages / disadvantages of using it? How small do files need to be for Rexcel?
...
I like using textmate to edit scripts for my analysis using R, Stata and SQL. Recently, I've had to use our grid server environment because the datasets are too large for my computer, and the ram allocations on the grid using R and STATA are much larger than what my computer has too offer.
My current workflow is to open up these progra...
I created several hundred plots using ggplot and saved them all to a list. I saved the list to disk using:
save(list_of_plots,file="list_of_plots.rdata")
Now I want to display those plots and save some using ggsave. However, calling a list item just shows me components of the plot.
> names(plots00_t2[[1]])
[1] "data" "layers"...
Hi guys
I want to ask, if there is anybody who is succesfully working with JRI and rJava? I want to put some graphs, plots made in R into my Java application, but without success. Can anybody provide working example. Here is what I found, but its not working. Thank you
import org.rosuda.JRI.REXP;
import org.rosuda.JRI.Rengine;
/**
* @a...