All Questions
8,747
questions
1
vote
4
answers
55
views
Find row in Matrix A which is closest two Matrix B
Lets say I have two matrices A and B given by
set.seed(123)
m1 = matrix(runif(10*5), nrow = 10, ncol = 5)
m2 = matrix(runif(10*5), nrow = 10, ncol = 5)
I want to find for each row in matrix A the row ...
0
votes
1
answer
36
views
Using dplyr to keep values above certain threshold in correlation matrix [closed]
I am trying to keep all correlations in my correlation matrix that are above 0.7 or below -0.7. When I try using the filter_all function within dyplr, I'm always left with a data frame with 0 obs. ...
1
vote
3
answers
52
views
Apply command for complex functions and calculations on a dataset in R
I'm a reasonably experienced R user who has often struggled to use the apply family. I have very slow-moving iterative code whose performance I'm hoping to improve through the use of this family, but ...
0
votes
2
answers
30
views
How to remove specific rows in a matrix dependent on row conditions
I have a function (from the package asnipe) that has taken my raw data and put it into four massive matrices. Right now I'm only focused on reducing the redundant data in the first one. And here is ...
2
votes
1
answer
55
views
Matrix linear interpolation
I have a matrix with individuals as rows and time points as columns. The value in the matrix is the probability of an event occurring for a subject at each time point.
set.seed(123)
prob_mat <- ...
1
vote
1
answer
51
views
Expression causes error "requires numeric/complex matrix/vector arguments" with GMM library
I am trying to estimate a model with the GMM library from R. However, when I run my code I am getting the error "requires numeric/complex matrix/vector arguments". I converted my Data Frame ...
5
votes
1
answer
94
views
LU decomposition on a sparse rectangular matrix in R
MATLAB is able to perform LU decomposition on a sparse rectangular matrix using [L, U, P, Q] = lu(A) but there is no R package to do so yet.
Trying to use Matrix::lu() on a sparse matrix in R returns ...
1
vote
3
answers
100
views
Can we retrieve entries from a tibble using index matrix?
I have a matrix where the row and column indices are stored that I want to retrieve from a dataset. With a data.frame this works fine:
set.seed(1)
df <- data.frame(a= letters[1:10], b= LETTERS[1:10]...
1
vote
1
answer
70
views
Define a matrix in R in a similar fashon as with Numpy
I love the fact that using numpy in Python it is very easy to define a matrix/array in a way that is very close to the mathematical definition.
Does R have a similar way of achieving this result?
...
-2
votes
3
answers
114
views
Flatten a large array into a matrix
I've looked through a number of posts with similar titles but none seem to help me out with this code.
I have a very large array (1200 rows, 48 columns, 6 slices). I'd like to flatten it into a matrix....
2
votes
2
answers
73
views
Generating a column of probabilities in r for a dataframe
I have a dataframe dfof football matches and corresponding mean scoring rates for each team. The first 2 columns are Home and Away teams, the 3rd and 4th columns are mean scoring rates for Home and ...
0
votes
0
answers
23
views
Mismatch in Row Length and Column Count in Sparse Matrix for TSP Model in Gurobi with R
I'm working on solving a Traveling Salesman Problem (TSP) with time windows using Gurobi in R. My model includes decision variables, subtour elimination constraints, and penalties for early and late ...
0
votes
1
answer
47
views
How to calculate the mutual information for continous data (as matrix) in R
Suppose I have the following data:
structure(c(4.72457077562954, 7.32894135282556, 6.95011739471982,
10.8300240696743, 6.39856613705841, 0.172228289296637, 0.844120336629789,
0.562443278169962, 1....
0
votes
0
answers
26
views
leverage of new predicted value
I would like to find the leverage of the new predicted values in my regression. Below is an example code
how would I be able to find the leverage for the 2 new predicted values ?
data("mtcars&...
1
vote
3
answers
82
views
How to convert an incidence matrix, of a bipartite network, to an unipartite projection
I would like to convert an incidence matrix of a bipartite procjection into a matrix of an unipartite projection.
For example:
I have this matrix, in which the columns are interacting with the ...