The poem "O Captain! My Captain!" was written as an elegy to mourn the life of President Abraham Lincoln. The poem was written in 1865, after Lincoln was assassinated. In the opening stanza of the poem, Whitman says that "our fearful trip is done." This refers ostensibly to the American Civil War, which ended just days before Lincoln's death, but it also refers implicitly to Lincoln's life. Whitman then metaphorically refers to the Civil War, and at the same time Lincoln's life, as a ship that has "weather'd every rack." The implication here is that both the nation and Lincoln himself have endured difficult times.
In the second half of the opening stanza, continuing the ship metaphor, Whitman compares Lincoln to a "steady keel." The keel is the wooden structure running along the length of the base of the ship, and is structurally integral to the ship. The word "keel" might also be used as a synonym for the word "ship" itself. By referring to Lincoln as a "steady keel," Whitman is implying that Lincoln was a stable, dependable and strong leader. He led America through the Civil War and kept to his course despite fierce opposition. In this way, we might infer that Lincoln was like the captain of a ship, steering a straight, steady course for that ship through fierce storms and over choppy waters.
At the end of the opening stanza, Whitman laments the fact that the effort and moral steadfastness that Lincoln demonstrated to lead America through the Civil War ultimately ended with him being assassinated. In this way Lincoln is like the captain of the metaphorical ship who, having steered the ship through a storm and over choppy waters, is left "dead and cold" upon the deck of that ship.