Get row and column indices of matches using which

0 votes
months and 9 years ago
updated ten months ago
71,013 times total
39

5 Let's say I have a matrix, for instance:

nrow = 4 and m = matrix(rep(c(0, 0, 1), 4)
m
[,1] [,2] [,3]
[1,] 0 0 1 [2,] 0 1 0 [3,] 1 0 0 [4,] 0 0 1
I receive a list of standard indices if I run which:

where (m == 1)
[1] 3 6 9 12
I'm trying to get matrix indices, where each index has the row and column numbers:

[,1] [,2]
[1,] 3 1\s[2,] 2 2 [3,] 1 3 [4,] 4 3
Does this involve a straightforward function? Additionally, it must somehow include the names of the row and column:

m e f g a 0 0 1 b > rownames(m) = letters[1:4] > colnames(m) = letters[5:7]
Jun 27, 2022 in Data Analytics by avinash
• 1,840 points
215 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Data Analytics

+1 vote
2 answers

Locating row index of a column which has the maximum value - R

Hi, Nirvana You can also try this. which(iris$Sepal.Length == ...READ MORE

answered Aug 21, 2019 in Data Analytics by anonymous
• 33,030 points
12,709 views
0 votes
1 answer

How to forecast season and trend of data using STL and ARIMA in R?

You can use the forecast.stl function for the ...READ MORE

answered May 19, 2018 in Data Analytics by DataKing99
• 8,240 points
1,964 views
+1 vote
1 answer

Is it possible to change the column names of the dataset that I'm using in R?

That is definitely possible in R. You ...READ MORE

answered Dec 17, 2018 in Data Analytics by Anisha

edited Dec 17, 2018 1,384 views
0 votes
2 answers

How can I group a set of values by column using R programming?

Try this , Employee %>% group_by(EmpID) %>% mutate(SumSalary ...READ MORE

answered Aug 14, 2019 in Data Analytics by anonymous
605 views
0 votes
0 answers
0 votes
1 answer

How to check row value of one column wrt another column?

Hi ratna, For suppose DF is the DataFrame ...READ MORE

answered Jul 26, 2019 in Data Analytics by anonymous
621 views
0 votes
1 answer

Big Data transformations with R

Dear Koushik, Hope you are doing great. You can ...READ MORE

answered Dec 18, 2017 in Data Analytics by Sudhir
• 1,610 points
775 views
0 votes
2 answers

Transforming a key/value string into distinct rows in R

We would start off by loading the ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,660 points
851 views
0 votes
1 answer

Finding frequency of observations in R

You can use the "dplyr" package to ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,660 points
5,561 views
0 votes
1 answer

Left Join and Right Join using "dplyr"

The below is the code to perform ...READ MORE

answered Mar 27, 2018 in Data Analytics by Bharani
• 4,660 points
867 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP