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

0 votes

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,060 points
90 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,550 points
0 votes
Hi, Nirvana

You can also try this.

which(iris$Sepal.Length == max(iris$Sepal.Length))
answered Aug 21 by anonymous
• 25,940 points

Related Questions In Data Analytics

0 votes
1 answer

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

Yes, we can find the index of ...READ MORE

answered Apr 13, 2018 in Data Analytics by zombie
• 3,690 points
367 views
0 votes
1 answer
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,680 points
140 views
0 votes
2 answers
0 votes
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,700 points
79 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 4, 2018 in Data Analytics by Kalgi
• 40,480 points
48 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,700 points
118 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,550 points
53 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,550 points
2,696 views