I am trying to get the maximum of 3 numbers along with its respective name assigned. But I get the maximum of the 3 numbers but the name assigned is not retrieved the last column as default. Please help.
maximum=function(a,b,c)
{
max=a
max1 = "aaa";
if(b>max)
max=b
max1 = "bbb";
if(c>max)
max=c
max1 = "ccc";
print(paste(max1,max));
}
I get my error output as below:
> maximum(3,2,1)
[1] "ccc 3"
Expected output:
"aaa 3"