Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
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 ...
MGP's user avatar
  • 2,511
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. ...
Sarah's user avatar
  • 463
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 ...
St4096's user avatar
  • 87
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 ...
Addi Lusk's user avatar
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 <- ...
user18894435's user avatar
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 ...
user280809's user avatar
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 ...
kmf's user avatar
  • 97
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]...
LulY's user avatar
  • 1,070
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? ...
larry77's user avatar
  • 1,461
-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....
JDK's user avatar
  • 21
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 ...
Alex's user avatar
  • 165
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 ...
Max's user avatar
  • 1
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....
Dr. Statistics's user avatar
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&...
AshleyCrasto's user avatar
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 ...
Pam's user avatar
  • 67

15 30 50 per page
1
2 3 4 5
584