user2806363
user2806363

Reputation: 2593

How to find the maximum element of list?

I have a big list and I want to find the maximum element of it, but it seems that doesn't work. Would someone help me?

A part of my list:

>X
    [[722]]
    [1] 3489

    [[723]]
    [1] 3100

    [[724]]
    [1] 3520

    [[725]]
    [1] 3544

    [[726]]
    [1] 3476

    [[727]]
    [1] 3625

    [[728]]
    [1] 3305

and here is my effort:

lapply(X, FUN=max )

But it does not give me the single number, which is the largest entry of this list, for example. Here I would expect to get 3625 as output.

Upvotes: 7

Views: 15244

Answers (1)

agstudy
agstudy

Reputation: 121608

You should unlist before applying max:

max(unlist(X))

Upvotes: 25

Related Questions