Skip to main content

All Questions

Tagged with
1 vote
3 answers
51 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
29 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
54 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
50 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
91 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,058
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
111 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
71 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
22 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
2 votes
2 answers
90 views

Reducing computational time in R code due to accessing elements

I am trying to reduce the computational time of an R code. I figured out that a part of it was coming from accessing a small number of rows of a large matrix. So I am creating a mwe to explain. I have ...
slowowl's user avatar
  • 694
2 votes
1 answer
63 views

create an average distance matrix based on matching prefix column and row names in R

I want to create a new distance matrix from an array of hundreds of distance matrices. This new matrix will be the average distances given a set of pairwise distances. The values to be averaged is ...
KNN's user avatar
  • 511

15 30 50 per page
1
2 3 4 5
583