At his best, President Reagan can send the spirits of Americans soaring and comfort them in times of trouble. At his worst, he displays an unfortunate preference for government by anecdote, responding to significant policy issues with ill-informed comments. Both the strengths and the shortcomings were on vivid display last week on the sad day that the space shuttle Challenger exploded.

Two hours before the tragedy, the president briefed congressional leaders on the State of the Union address, scheduled for delivery the same evening. For a time, he sailed along in fine fashion, consulting from the points outlined on his four-by-six cards. But once he departed from his script, Reagan was soon pooling his ignorance with his congressional audience.

Goaded by House Speaker Thomas P. (Tip) O'Neill Jr. (D-Mass.), Reagan dismissed unemployment statistics by saying the rate would be lower if members of the armed services were counted in the work force. Several of those in the meeting considered the point irrelevant or trivial and couldn't understand why Reagan made a point of it.

Then Reagan related one of those shopworn stories that used to make hearts go pit-a-pat on the conservative banquet circuit. This particular tale, drawn from his California days and offered as a true story, was about a welfare recipient who answered employment offers by telephone and hung up when someone told him he was hired.

The story triggered an outburst from O'Neill about Reagan's "rich friends" and "insensitivity." The speaker, arguing on behalf of those who want work and can't find it, accused the president of ignoring the plight of workers in shrinking basic industries who have been thrown on the jobless rolls through no fault of their own.

"I thought you would have grown in five years," O'Neill said.

Three hours later, the president held a prescheduled meeting with television network anchors to discuss his State of the Union address. Along with the rest of America, he was still in shock from the loss of the Challenger crew. But the president, speaking his own thoughts without cue cards, vowed that the manned space program must go forward despite the tragedy.

"We have accidents in every line of transportation, and we don't do away with those things," Reagan said. "They've probably got a better safety record in the space program than we have on the highways."

Later in the day, the president honored the "seven heroes" who had died aboard the shuttle and reaffirmed his commitment to the U.S. quest in space in a graceful speech drafted by White House speechwriter Peggy Noonan and nationally televised from the Oval Office. "Nothing ends here," Reagan said. "Our hopes and our journeys continue."

In this speech and his subsequent telephone calls to the families of the crew, Reagan served as the great comforter for a nation joined in sorrow by the unifying immediacy of television. It is a duty we have come to expect of our presidents and one in which Reagan invariably excels.

The president will be 75 years old Thursday. During his five years in the White House, he has faced and survived a would-be assassin's bullet and the dreaded ordeal of cancer surgery with a courage and insouciance that epitomizes the bravery of the Challenger crew and other American heroes he celebrates.

The affection that most Americans hold for Reagan, even when they question his policies, reflects an appreciation for his grace and courage. In times of crisis, it compensates for the anecdotes and the simplicities. Reagan made his living in Hollywood and is fond of cinematic analogies, but he is real, not celluloid. If he sometimes seems to be playing a role as president, it is a part for which he is exceptionally well-suited.

Tip O'Neill understands this, too. The day after he lost his temper at the president's welfare story, O'Neill talked with admiration about Reagan's response to the loss of Challenger.

"I watched the president of the United States give a masterful presentation to the nation," O'Neill said. "I had a tear in my eye and a lump in my throat. It was a trying day for America, and I think the president brought the best of all Americans out at that time."

Reaganism of the Week: In his speech after the shuttle explosion, the president said: "The future doesn't belong to the fainthearted. It belongs to the brave."