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

+1 vote

I'm working with the iris data-set:

        Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1          5.1         3.5          1.4         0.2       setosa
2          4.9         3.0          1.4         0.2       setosa
3          4.7         3.2          1.3         0.2       setosa
4          4.6         3.1          1.5         0.2       setosa

I need to find out that row index which has the maximum value of 'Sepal.Length'

May 16, 2018 in Data Analytics by nirvana
• 3,130 points
12,642 views

2 answers to this question.

0 votes
which.max(iris$Sepal.Length)

This command will give you the desired row location.

answered May 16, 2018 by Bharani
• 4,660 points
0 votes
Hi, Nirvana

You can also try this.

which(iris$Sepal.Length == max(iris$Sepal.Length))
answered Aug 21, 2019 by anonymous
• 33,030 points
use whic.max(df) for same

Related Questions In Data Analytics

0 votes
2 answers

R function for finding the index of an element in a vector?

The function match works on vectors : x <- sample(1:10) x # ...READ MORE

answered Dec 12, 2020 in Data Analytics by Rajiv
• 8,910 points
55,987 views
0 votes
1 answer

R language has several packages for solving a problem. How do you make a decision on which one is the best to use?

CRAN package ecosystem has more than 6000 ...READ MORE

answered Jun 5, 2018 in Data Analytics by zombie
• 3,790 points
952 views
0 votes
1 answer

How to write a custom function which will replace all the missing values in a vector with the mean of values in R?

Consider this vector: a<-c(1,2,3,NA,4,5,NA,NA) Write the function to impute ...READ MORE

answered Jul 4, 2018 in Data Analytics by CodingByHeart77
• 3,740 points
4,208 views
+1 vote
3 answers

How to change the value of a variable using R programming in a data frame?

Try this: df$symbol <- as.character(df$symbol) df$symbol[df$sym ...READ MORE

answered Jan 11, 2019 in Data Analytics by Tyrion anex
• 8,700 points
35,163 views
+1 vote
1 answer

How to convert a list of vectors with various length into a Data.Frame?

We can easily use this command as.data.frame(lapply(d1, "length< ...READ MORE

answered Apr 4, 2018 in Data Analytics by DeepCoder786
• 1,720 points
1,241 views
0 votes
2 answers

In data frame how to spilt strings into values?

You can do this using dplyr and ...READ MORE

answered Dec 5, 2018 in Data Analytics by Kalgi
• 52,360 points
753 views
0 votes
1 answer
0 votes
1 answer

How to convert a text mining termDocumentMatrix into excel or csv in R?

By assuming that all the values are ...READ MORE

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,720 points
1,604 views
0 votes
1 answer

Applying the same function to every row of a data.frame - R

You can use the 'appply()' function for ...READ MORE

answered May 22, 2018 in Data Analytics by Bharani
• 4,660 points
1,430 views
0 votes
1 answer

Changing the order of bars in a bar-plot - ggplot2 - R

You can use the scale_x_discrete() function with ...READ MORE

answered May 28, 2018 in Data Analytics by Bharani
• 4,660 points
9,489 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