Questions tagged [replicate]
280 questions
4
votes
1 answer
Is there a way to access the iteration number in replicate()?
Is there some way to access the current replication number in the replicate function so I can use it as a variable in the repeated evaluation? For example in this trivial example I'd like to use the current replication number to generate a list of…

Simon O'Hanlon
- 58,647
- 14
- 142
- 184
3
votes
1 answer
Haskell ReplicateM IO
I'm trying to create a function which allows the user to input a list of strings. The function takes the length and allows the user to input length-1 more lines. Then each line is checked to ensure it is the same length as the original line.…

gdrules
- 329
- 1
- 6
- 12
3
votes
2 answers
Sample, replicate and histogram in R
I want to choose 100 houses randomly from my dataset, and find the mean value of their total price. Then repeat this action 100 times, and for each time I repeat the action, calculate the mean price. And then plot all the mean values in a histogram.…

Anna
- 55
- 5
3
votes
0 answers
Cog vs Triton Inference Server
I'm considering Cog and Triton Inference Server for inference in production.
Does someone know what is the difference in capabilities as well as in run times between the two, especially on AWS?

Dolev Shapira
- 133
- 8
3
votes
1 answer
Split rows and assign values pandas
I have four a data frame as follows:
Proxyid
A
B
C
D
123
1
0
0
0
456
1
1
1
1
789
0
0
0
0
This is the idea of the data frame. now I want to duplicate the rows where there are more than one 1. and assign values as…

Yesha Shah
- 31
- 1
3
votes
1 answer
Is rep really a generic?
When I type the function name of a generic in to my console, I expect to see a call to UseMethod. For example, the documentation for determinant calls it a generic and I get the following output when I type it in to my console:
>…

J. Mini
- 1,868
- 1
- 9
- 38
3
votes
2 answers
How to replicate strings from a vector differently in R?
I have this vector:
Photoperiod <- c("Day","Sunset","Night","Sunrise")
I would like to create a vector in which Day is repeated 12 times, Sunset 2 twice, Night 8 times and Sunrise twice until I get a vector of length equal to 168.
How could I do…

Dekike
- 1,264
- 6
- 17
3
votes
2 answers
How to replicate and/or reassign array elements in a multi-dimensional array?
The code is getting messy somewhere in the loop! Please help me to solve it.
Details
Replicate and/or reassign most of the array elements in the multi-dimensional array, using reference elements.
File-1: List of array indices & the elements that…

perlbeginner
- 59
- 7
3
votes
1 answer
Replicate elements in pandas list
I need some help as a I am a bit lost.
Lets suppose I have a column from a dataframe I need to be filled with certain elements from previous rows.
To simplify things i ve made a pd.series:
lista = ['hola','salut','hello','xixie']
index1 = (0,…

Borja_042
- 1,071
- 1
- 14
- 26
3
votes
1 answer
function to sample variable number of substrings given string length
I'm trying to write an R function that will sample a variable number of 5-element substrings, based on the length of the original string in each row of a data frame. I first calculated the number of times I'd like each draw to repeat, and would like…

user8173816
- 55
- 4
3
votes
4 answers
Replicate certain values in vector determined by other vector
I have a vector of values (say 1:10), and want to repeat certain values in it 2 or more times, determined by another vector (say c(3,4,6,8)). In this example, the result would be c(1,2,3,3,4,4,5,6,6,7,8,8,9,10) when repeating 2 times.
This should…

sds
- 65
- 1
- 1
- 10
3
votes
1 answer
R: When using the rep(..,..) to replicate 1020 a character variables, the result contains just 1019 replicates?
When programming within the R environment I used rep("[35,40)",1020). This should give me a list with 1020 times "[35,40)". However, the result contains only 1019 of these elements.
The programming was first done within a replicated for two vectors,…

user404309
- 211
- 1
- 6
3
votes
2 answers
Using replicate for user define function containing mapply and list of output
I can use following MyFun (user defined) function to simulate observations. But could not figure out how to repeat this function with replicate function when the function returns a list of output.
MyFun <- function(nSim, Size, Prob) {
M1 <-…

MYaseen208
- 22,666
- 37
- 165
- 309
3
votes
1 answer
Replicate Stratified Random Sampling without Replacement in R
I'm struggling to create a vectorized functional solution that will allow me to replicate stratified random sampling without replacement over many iterations. I'm able to sample without replacement once, then remove those rows from the dataset and…

Brian
- 195
- 8
3
votes
1 answer
replicate() class xts into a list
I have an xts object frame
frame <- structure(c("a", "a", "a"), .Dim = c(3L, 1L), index = structure(c(946702800,
946749600, 946796400), tzone = "", tclass = c("POSIXct", "POSIXt"
)), class = c("xts", "zoo"), .indexCLASS = c("POSIXct", "POSIXt"
),…

user1320502
- 2,510
- 5
- 28
- 46