First, read the Introduction to R to understand what dataframes are and how
to access data within them.  Then  correct you code so it does not have
error:  'x' has a trailing comma and 'y' was not call the 'c' function.
 Once you have done that, you might get the following:


> x<-c(5,9,8,3,4,5,6,7)
> y <-c("a", "b","c", "d","e","f", "g","h")
>
> D <- data.frame(x,y)
>
> str(D)
'data.frame':   8 obs. of  2 variables:
 $ x: num  5 9 8 3 4 5 6 7
 $ y: Factor w/ 8 levels "a","b","c","d",..: 1 2 3 4 5 6 7 8
> D$y[which.max(D$x)]
[1] b
Levels: a b c d e f g h
>



Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.


On Thu, Mar 27, 2014 at 10:57 AM, Prabhakar Ghorpade <
dr.prabhakar08@gmail.com> wrote:

> Hello,
>  If I have x<-c(5,9,8,3,4,5,6,7,)
> and y <-("a", "b","c", "d","e","f", "g","h")
>
> and D <- data.frame(x,y)
>
>
>
> I did this max(x)
>
> and My expectede anwer is b.
> How do I select element in y which correspond to maximum number in x?
>
> thanks.
>
> regards,
> Prabhakar
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]


