Please do provide data when submitting a question so we don't have to try to
recreate it from a brief description.

> pot <- data.frame(count=LETTERS[1:10], '1998'=runif(10), '1999'=runif(10),
+     '2000'=runif(10), '2001'=runif(10), check.names=FALSE,
stringsAsFactors=FALSE)
> pot
   count       1998      1999       2000       2001
1      A 0.98631159 0.9894998 0.48614910 0.10910096
2      B 0.29360555 0.1764520 0.06380247 0.33327798
3      C 0.39935111 0.5421304 0.78454623 0.83741657
4      D 0.81213152 0.3843039 0.41832164 0.27684984
5      E 0.07715167 0.6761641 0.98101808 0.58703514
6      F 0.36369681 0.2692938 0.28288396 0.83673227
7      G 0.44259247 0.4692509 0.84788215 0.07115402
8      H 0.15671413 0.1718001 0.08223923 0.70277874
9      I 0.58220527 0.3691895 0.88645875 0.69882454
10     J 0.97016218 0.7254053 0.47193073 0.46396238
> max.col <- apply(pot[, -1L], 1, which.max)
> data.frame(count=pot$count, year=names(pot[, -1L])[max.col])
   count year
1      A 1999
2      B 2001
3      C 2001
4      D 1998
5      E 2000
6      F 2001
7      G 2000
8      H 2001
9      I 2000
10     J 1998


On Sun, Apr 18, 2010 at 10:40 AM, AuriDUL <auridul@yahoo.com> wrote:

>
> Hello.
>
> I have data of potatoes production in EU during 1998-2009 from EuroStat
> where the first column consists of the names of EU countries, the following
> columns consists of appropriate data in each year.
>
> Let's say, I investigate Lithuania. For example, I have a row containing
> potatoes production in 1998, 1999, ..., 2009 in Lithuania. I can easily
> find
> the maximum value in this row but...
>
> ...but
>
> How could I print the year (the name of the column) where that maximum
> value
> of potaoes production in Lithuania exists? [if it's even possible.]
>
> I only have a code which can print a number of the column where that
> maximum
> value of Lithuania's potatoes production during 1998-2009 is.
>
> Thanks in advance.
> --
> View this message in context:
> http://n4.nabble.com/getting-column-s-main-tp2014892p2014892.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

	[[alternative HTML version deleted]]

