similar to: cut a vector in equal parts

Displaying 20 results from an estimated 20000 matches similar to: "cut a vector in equal parts"

2013 Feb 28
2
Fortune?
I think the rule is that you can do anything as long as you don't complain. If you want to complain, you must follow the instructions. -- Jari Oksanen in Re: [Rd] Keeping up to date with R-devel -- Patrick Burns pburns at pburns.seanet.com twitter: @burnsstat @portfolioprobe http://www.portfolioprobe.com/blog http://www.burns-stat.com (home of: 'Impatient R' 'The R
2014 Jan 03
1
wishlist: decreasing argument to is.unsorted
I've just realized that it could be handy to have a 'decreasing' argument in 'is.unsorted'. And I'm cheekily hoping someone else will implement it. It is easy enough to work around (with 'rev'), but would be less hassle with an argument. The case I have in mind uses 'is.unsorted' in 'stopifnot'. Pat -- Patrick Burns pburns at pburns.seanet.com
2013 Apr 06
1
Value at Risk using a volatility model?
Hi, I want to calculate the Value at Risk with using some distirbutions and a volatility model. I use the following data(http://uploadeasy.net/upload/cdm3n.rar) which are losses (negative returns) of a company of approx. the last 10 years. So I want to calculated the Value at Risk, this is nothing else than the quantile. Since I have losses I consider the right tail of the distribution. Consider
2013 Mar 02
3
if value is in vector, perform this function
Hi, I'm trying to set up R to run a simulation of two populations in which every 3.5 days, the initial value of one of the populations is reset to 1.5. I'm simulation an experiment we did in which we fed Daphnia populations twice a week with algae, so I want the initial value of the algal population to reset to 1.5 twice a week to simulate that feeding. I've use for loops and if/else
2013 Mar 28
2
E-learning environment for R
Hello, Does an e-learning environment for R (in English) exist? I would like to point out to students a way to learn R if they have missed the course on R. Pekka Pere University Lecturer University of Helsinki
2012 Dec 25
5
aggregate / collapse big data frame efficiently
Hi, I need to aggregate rows of a data.frame by computing the mean for rows with the same factor-level on one factor-variable; here is the sample code: x <- data.frame(rep(letters,2), rnorm(52), rnorm(52), rnorm(52)) aggregate(x, list(x[,1]), mean) Now my problem is, that the actual data-set is much bigger (120 rows and approximately 100.000 columns) ? and it takes very very long
2013 Mar 18
4
!0 + !0 == !0 - !0
Hi all, The subject line is TRUE. Today I accidentally typed rnorm(!0). My old eyes took a minute to focus clearly enough to see what I really typed and why I got '!0' random numbers instead of '10' random normal numbers. If the subject line is disturbing, be assured that this is TRUE: !0^2 == !0 * !0 # ;-) Anyway, I hope the hands who have been around long enough to know
2013 Mar 25
3
nested 'while' loops
Hi everyone, I'm using the following code to go over every element of a data frame (row wise). The problem I am facing is that the outer 'x' variable is not incrementing itself, thus, only one row of values is obtained, and the program does not proceed to the next row. This is the code: while(x<=coln) { while(y<=rown) { n<-as.numeric(df[[y]][x]);
2013 Mar 08
2
Unexpected behaviour of apply()
Hello everyone, Considering the following code sample : ---- indexes <- function(vec) { vec <- which(vec==TRUE) return(vec) } mat <- matrix(FALSE, nrow=10, ncol=10) mat[1,3] <- mat[3,1] <- TRUE ---- Issuing apply(mat, 1, indexes) returns a 10-cell list, as expected. Now if I do: ---- mat[1,3] <- mat[3,1] <- FALSE apply(mat, 1, indexes) ---- I would expect a
2013 Mar 12
1
rugarch: GARCH with Johnson Su innovations
Hey, I'm trying to implement a GARCH model with Johnson-Su innovations in order to simulate returns of financial asset. The model should look like this: r_t = alpha + lambda*sqrt(h_t) + sqrt(h_t)*epsilon_t h_t = alpha0 + alpha1*epsilon_(t-1)^2 + beta1 * h_(t-1). Alpha refers to a risk-free return, lambda to the risk-premium. I've implemented it like this: #specification of the model
2013 Feb 27
2
temp seems ineffective in SANN (optim)
I am trying to control the behavior of the SANN method in optim (R 2.14.1) via control$temp. In my toy tests it works; in my real use, it doesn't. As far as I can tell my code with different temp values is loaded; I even traced into the function that calls optim and verified temp had the value I had set. Could the fact that I have NaN's coming back from the objective function be a
2013 Mar 25
2
ifelse can't return a list? Please explain (R-2.15.3)
I hope you are doing well. For me, this was an unexpected problem. I've hoped for quite a few wrong things today, but I'm only asking you about this one. Why does ifelse(1, list(a, b, c), list(x, y, z)) return a list with only a, not list(a, b, c) as I hoped. I wish it would either cause an error or return the whole list, not just the first thing. Working example: > x <- 1 >
2013 Jan 17
3
how to use "..."
Dear users, I'm trying to learn how to use the "...". I have written a function (simplified here) that uses doBy::summaryBy(): # 'dat' is a data.frame from which the aggregation is computed # 'vec_cat' is a integer vector defining which columns of the data.frame should be use on the right side of the formula # 'stat_fun' is the function that will be run to
2018 Aug 05
2
Is this a bug in `[`?
Thanks. This is exactly the doubt I had. Rui Barradas ?s 05:26 de 05/08/2018, Kenny Bell escreveu: > This should more clearly illustrate the issue: > > c(1, 2, 3, 4)[-seq_len(4)] > #> numeric(0) > c(1, 2, 3, 4)[-seq_len(3)] > #> [1] 4 > c(1, 2, 3, 4)[-seq_len(2)] > #> [1] 3 4 > c(1, 2, 3, 4)[-seq_len(1)] > #> [1] 2 3 4 > c(1, 2, 3, 4)[-seq_len(0)]
2011 Sep 12
3
Solve your R problems
R-help is all about solving R problems. So here ya go: http://www.portfolioprobe.com/2011/09/12/solve-your-r-problems/ -- Patrick Burns pburns at pburns.seanet.com twitter: @portfolioprobe http://www.portfolioprobe.com/blog http://www.burns-stat.com (home of 'Some hints for the R beginner' and 'The R Inferno')
2011 Aug 29
3
Basic question about re-writing for loop as a function
Hello- Sorry to ask a basic question, but I've spent many hours on this now and seem to be missing something. I have a loop that looks like this: mainmat=data.frame(matrix(data=0, ncol=92, nrow=length(predata$Words_MH))) for(i in 1:length(predata$Words_MH)){ for(j in 1:92){ mainmat[i,j]=ifelse(j %in% as.numeric(unlist(strsplit(predata$Words_MH[i], split=","))),
2012 Jul 17
3
complexity of operations in R
Hello! I am optimizing my code in R and for this I need to know a bit more about the internals. It would help tremendously if someone could link me to a page with O()-complexities of all the operations. In this particular case, I need something like a linked list with O(1) insertLast/First ability. I can't preallocate a vector since I do not know the final size of the list ahead of time. The
2011 Sep 18
2
troubles with a for loop
Dear all, I am a stata user and I am moving my first steps in R. I am dealing with a silly issue concerning looping over variables. I read previous posts on similar topics in the R help archive, but I did not find a solution. Here is my case: I run a simple bivariate linear regression saving the output in objects called: pd.memb.0, pd.memb.1, pd.memb.2, pd.memb.3 pd.memb.0 <- lm(E.fs.memb ~
2011 Jan 06
1
Calcuting returns
Dear R forum helpers,I have following datatrans <- data.frame(currency_transacted = c("EURO", "USD", "USD", "GBP", "USD", "AUD"), position_amt = c(10000, 25000, 20000, 15000, 22000, 30000))date <- c("12/31/2010", "12/30/2010", "12/29/2010", "12/28/2010", "12/27/2010",
2012 Sep 05
1
run EGARCH package on REXCEl
Hi, I have limited experience on R and recently started using REXcel. Although I have been able to run both simple functions (like mean etc) and some complex ones (like Principal Component analysis, PCA) using RExcel, I am facing some problems while running EGARCH model. For this I have downloaded the 'betategarch' package for R to run EGARCH with student t dist. Although the package has