Anderson was born in Washington County, Pennsylvania, on June 26, 1834. He was educated at Miami University in Oxford, Ohio, and graduated in 1853. Benjamin Harrison, who was afterward president of the United States, was his roommate while in college.
He began work as a pastor of a church in Stockton, California, in 1857 and preached the first Union sermon on the Pacific Coast. He was elected as the trustee of the California State Insane Asylum in 1860. Two years later, he was appointed chaplain of the Third California Infantry. In this capacity, he accompanied General Patrick Connor’s expedition to Salt Lake City, Utah. Anderson’s desire to always investigate something led to his appointment to the United States Sanitary Commission as California correspondent and agent. His first duty was to act as a relief agent of the Twelfth Army Corps.
He was next transferred to the central office in New York. In 1864, when General Ulysses S. Grant began moving toward Richmond, Virginia, Anderson was made superintendent of transportation and had charge of six steamboats. At the close of the campaign, he served as assistant superintendent of the canvas and supply department at Philadelphia, Pennsylvania, and edited a paper called the Sanitary Commission Bulletin.
When the war closed, he was transferred to the History Bureau of the commission at Washington D.C., remaining there for one year collecting data and writing a portion of the commission’s history. In 1866 he was appointed statistician of the Citizens’ Association of Pennsylvania, an organization to mitigate the suffering resulting from pauperism, vagrancy, and crime in the large cities.
In February 1868, Anderson accepted a call from the Presbyterian Church of Junction City, Kansas. During his years in this town, he developed power as an orator and took an active part in politics. He was on the school board most of the time he was in Junction City.
In 1870, the morning after his mother was buried out on the open prairie, where all the dead had been laid, he remarked to some of his friends, “This town must have a cemetery,” and as a result of his efforts, the Highland Cemetery was established.
In 1870-71, there was much interest throughout the country in narrow gauge railroads, it being argued that there was economy in them. Anderson concluded that the idea was not practicable and determined to oppose the bonds asked for in Clay County. His ideas prevailed, and the track was re-laid with a standard gauge. In the summer of 1872, Benjamin Harrison secured him a call from a church in Indianapolis, Indiana but his wife and family persuaded him to remain in Kansas.
In the fall of 1873, Anderson was elected President of the Kansas State Agricultural College at Manhattan. There, he made radical policy changes that placed the college near the head of the list of such institutions in the United States. Anderson remained president of the college until 1878 when he was elected to Congress and served as a representative from the First and Fifth districts until 1891. In March of that year, he was appointed Consul General to Cairo, Egypt, and sailed for his new post on April 6, but his constitution was already impaired, and he was unable to stand the change of climate.
The following spring, he determined to return but died on his way home at Liverpool, England, on May 18, 1892. He was laid at rest on the hilltop he had chosen years before, near the town where he said the happiest days of his life had passed and seven of his family are also interred.