Questions tagged [replicate]
280 questions
2
votes
1 answer
Create new column based on replicate observation
I have a question how to create a new column based on another.
Here is my part of data:
Category Brand Time1 value Time2 number
2 HTC 2015-01-01 1724 NA 1
6 APPLE 2015-10-10 …

Peter Chen
- 1,464
- 3
- 21
- 48
2
votes
2 answers
R Replicating until length is met
Say we have the following:
a=c( 1, 9, 5, 7, 8, 11)
length(a) ## 6
and I want to obtain:
a_desired=c( 1, 1, 9, 9, 5, 5, 7, 7, 8, 11)
length(a_desired) ## 10
Basically it stops replicating when it reaches the desired length, in this case 10.
If the…

mathnoob
- 73
- 1
- 1
- 9
2
votes
1 answer
sas variable difference with same id
I appreciate a lot you guys, especially when i got problems about modulating with SAS.
I have a data set like a follows.
ID key score
10002817 200207826243 0
10002817 200207826271 0
10002817 200208532180 0
10002976 200301583978 0…

j.yj
- 31
- 5
2
votes
3 answers
R: replicate a row and update by next date per row
The input and its intended output show that I want to replicate the row of the input and update the date entry. How can I do this?
Input
> aa<- data.frame(a=c(1,11,111),b=c(2,22,222),length=c(3,5,1),date=c(as.Date("28.12.2016",format="%d.%m.%Y"),…

Regan Alpha
- 67
- 5
2
votes
2 answers
Teradata REPLICATE function?
I'm converting MS SQL Server codes to Teradata.
I found out that Teradata has no replicate function.
Below is the sample code
REPLICATE('0',2-LEN(CAST(COLUMN_NAME AS NVARCHAR)))
Is there an alternative function for replicate in Teradata?
Thanks

Xotigu
- 55
- 2
- 9
2
votes
0 answers
Replication MongoDB & SQLServer
I need to create a connection between ##MongoDB## and ##SQL Server## where I want to replicate a subset of my Database from SQL Server into MongoDB. Can anyone suggest for feasibility of the same and how ?
Is there any open source tool for the real…

Abhishek Pansotra
- 947
- 2
- 13
- 17
2
votes
1 answer
Replicating elements in numpy array
I have a numpy array say
a = array([[1, 2, 3],
[4, 5, 6],
[7, 8, 9]])
I have an array 'replication' of the same size where replication[i,j](>=0) denotes how many times a[i][j] should be repeated along the row. Obiviously,…
user6889577
2
votes
0 answers
PHP current request translation to CURL
I have a PHP (Laravel framework) application and when a request is being made on my site, i want to do the exact same request with CURL but only change the URL. That includes:
headers
POST data (if present)
uploaded files (if present)
anything else…

Alexandru Contes
- 99
- 2
- 9
2
votes
1 answer
Replicate a column VectorXd in order to construct a MatrixXd in Eigen, C++
Let's assume that we have a 10x20 real matrix:
Eigen::MatrixXd A(10,20);
A.setRandom();
We would like to construct a 10x10 matrix of the form
B = [v v ... v v]
where v is a column vector of length 10. For this vector, v, each element is the…

nullgeppetto
- 539
- 1
- 8
- 25
2
votes
3 answers
Haskell: recursive Replicate function
I'm just getting started with Haskell. I'm trying to create a function that imitates the standard replicate function in Haskell, but using recursion. For example,
Prelude> replicate 3 "Ha!"
["Ha!","Ha!","Ha!"]
It should be of type Int -> a -> [a].…

Jul
- 21
- 1
- 3
2
votes
2 answers
Using function "cat" with "replicate" in R
Is there a way how to combine function "cat" with function "replicate" in R?
I want to see number of "loops" R has already made at a particular moment. However, instead of using "for" loop, I prefer to use "replicate". See the simple example below:
…

user36478
- 346
- 6
- 14
2
votes
1 answer
Retrieving the object from a replicated row with Laravel/Eloquent
I'm replicating a database row and want to return the new row as an object.
$new_foo = Foo::find($id)->replicate()->save();
print_r($new_foo);
This returns 1 instead of the new object I just created. Thoughts?

americanknight
- 689
- 3
- 18
- 37
2
votes
2 answers
Perl Hash Slice, Replication x Operator, and sub params
Ok, I understand perl hash slices, and the "x" operator in Perl, but can someone explain the following code example from here (slightly simplified)?
sub test{
my %hash;
@hash{@_} = (undef) x @_;
}
Example Call to sub:
test('one', 'two',…

user210757
- 6,996
- 17
- 66
- 115
2
votes
0 answers
How to replicate only the structure (DDL) of Postgres (without data)?
I have installed 3 Postgres databases.
The first database is the development, the second homologation and the third is production.
I need to replicate the DDL of development with homologation and production, because I need to create columns and…

Luciano Andress Martini
- 186
- 1
- 12
2
votes
3 answers
R How to replicate nulls in a list
list(list(NULL,NULL),list(NULL,NULL))
The result is:
[[1]]
[[1]][[1]]
NULL
[[1]][[2]]
NULL
[[2]]
[[2]][[1]]
NULL
[[2]][[2]]
NULL
Supposing I want to do this for larger numbers than 2, is there a way to get the same list structure with…

Logister
- 1,852
- 23
- 26