Questions tagged [replicate]
280 questions
6
votes
2 answers
How are BRR weights used in the survey package for R?
Does anyone know how to use BRR weights in Lumley's survey package for estimating variance if your dataset already has BRR weights it in?
I am working with PISA data, and they already include 80 BRR replicates in their dataset. How can I get…

RickyB
- 607
- 1
- 8
- 20
6
votes
4 answers
In R, how to generate a dataset consisting of the means of all column of a dataframe?
I can generate 20 observations of a uniform distribution with the runif function : runif(n=20)
and 100 replicates of the same distribution as following.
df <- replicate( 100, runif(n=20))
This creates df a matrix of dimensions [20,100] which I can…

user1357062
- 83
- 2
- 5
5
votes
1 answer
Set up Mongo Cluster across 2 data centers with writing enabled on both
We're planning to expand our software to the South East Asia region. Our self-hosted Mongo Cluster is fully set up at China's AWS Data Center. How can we set up the MongoDB replicate set to AWS Singapore and allow writing on both regions and rely on…

angelokh
- 9,426
- 9
- 69
- 139
5
votes
1 answer
How are apply family functions scoped?
Consider:
x <- 5
replicate(10, x <- x + 1)
This has output c(6, 6, 6, 6, 6, 6, 6, 6, 6, 6). However:
x <- 5
replicate(10, x <<- x + 1)
has output c(6, 7, 8, 9, 10, 11, 12, 13, 14, 15).
What does this imply about the environment that x <- x + 1 is…

J. Mini
- 1,868
- 1
- 9
- 38
5
votes
2 answers
Common Lisp equivalent of Haskell's replicate?
replicate is a function that takes an integer and a sequence and returns the sequence repeated n times.
E.g. replicate 3 ["a"] returns ["a", "a", "a"]
Does Common Lisp have an equivalent function, or do I have to write one?

mcandre
- 22,868
- 20
- 88
- 147
5
votes
5 answers
Haskell - repeat elements of a list according to their list-index
I´m still a beginner in Haskell. I try to do some pattern matching. I want to repeat each element of a list n-times. N is determined by the index-place of every element in a list.
For example ['1', '2', '3'] should give me: ['1', '2', '2', '3',…

Pal
- 53
- 1
- 4
5
votes
2 answers
R - Copy values within a group
I have a dataframe where I have the total number of points someone scored in the past 3 years (2016, 2017, 2018), but also columns with their number of points per year.
My dataframe looks like this:
myDF <- data.frame(ID =c(1,1,1,2,2,3,4),
Dates=…

AllanLC
- 167
- 2
- 11
5
votes
2 answers
Adding progress bar to replicate function in R
I am using replicate to run my own analyse function multiple times (analyse returns a list):
results <- replicate(reps, analyse())
Is there a way to add progress bar, showing the percentage of replications finished at the moment? I have tried with…

Michal
- 151
- 1
- 7
4
votes
3 answers
Create new repeating index where range of each number is dependent on the index of another column as efficiently as possible
I have a vector of numbers.
initialindex= c(17, 23, 28, 34, 39, 45)
What I would like to get out of this looks like this:
finalindex=c(1,1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,5,5,5,5,5,5,5)
The number repeats based on the difference of…

Tracy
- 699
- 2
- 9
- 21
4
votes
1 answer
How to replicate a slice in Rust?
I have a slice that I want to replicate. For example, if xs = [1, 2, 3], and I need to replicate it 4 times, I would end up with ys = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3].
In Haskell, I would do something like this:
ys = take (4 * length xs) $ cycle…
user8370684
4
votes
0 answers
Angular Module Loaded But JavaScript Error Says It Is Unavailable
I have server logs that show a client is loading all of the modules required in my ng-app = M declaration attached to the element. Meaning, all of the dependencies seem to be loaded correctly before my app is declared and initialized.
My app…

Summer Developer
- 2,056
- 7
- 31
- 68
4
votes
1 answer
Monte Carlo Simulation, Bootstrap and Regression in R
I have been using SAS for a long time and now I would like to translate my codes in R. I need help to do the following:
Generate several bootstrap samples
Run a linear regression model on each of the samples
Store the parameters in a new dataset…

SimRock
- 229
- 3
- 10
4
votes
1 answer
Map Eigen replicate Matrix
I am trying to bring code from Matlab to C++. There is some information related to my case in the KDE Eigen Forums.
What I try to achieve is related to Matlab's meshgrid, for which the solution given over there is
X =…

AverageCoder
- 45
- 6
4
votes
1 answer
Simulating data in R with multiple probability distributions
I am trying to simulate data via bootstrapping to create confidence bands for my real data with a funnel plot. I am building on the strategy of the accepted answer to a previous question. Instead of using a single probability distribution for…

user964689
- 812
- 7
- 20
- 40
4
votes
3 answers
Easily replicate an element in Prolog :)
I am working on a longer problem that has me duplicate an element N times in list form, and I believe that using append is the right way to go for this. The tiny predicate should theoretically act like this:
?- repl(x,5,L).
L = [x, x, x, x, x]…

user3290526
- 139
- 3
- 11