Hi Joshua,
>
>
>
> rbind(data, c("Total",apply(data[,-1], 2, sum, na.rm=TRUE)))
>

Yes. This what exactly I want. Thanks for your time.


>
> If your State column is a factor, it will return a warning that NAs
> were introduced (but the totals will still be at the bottom).
>

Yes.

> is.factor(data$State)
[1] TRUE

 State column is a factor, it will return warning message like this .
Warning message:
In `[<-.factor`(`*tmp*`, ri, value = "Total") :
  invalid factor level, NAs generated

I know that this is common factor vs character problem in R. I think there
may be a safe way to handle this:

> data <- read.csv(file='ipsample.csv',sep=',' , header=TRUE)

> a <- rbind(data, c("Total",apply(data[,-1], 2, sum, na.rm=TRUE)))
Warning message:
In `[<-.factor`(`*tmp*`, ri, value = "Total") :
  invalid factor level, NAs generated

> a
  State  Jan  Feb  Mar  Apr  May Jun
1   AAA    1    1    0    2    2   0
2   BBB 1298 1195 1212 1244 1158 845
3  CCC     0    0    0    1    2   1
4   DDD    5   11   17   15   10   9
5   EEE   18   28   27   23   23  16
6   FFF   68  152  184  135  111  86
7  <NA> 1390 1387 1440 1420 1306 957

How to safely avoid this warning massage?
Now I have <NA> instead of "Total" in last row State column. How to I
replace it as "Total"?

Thanks & Rg
Mohan L

	[[alternative HTML version deleted]]

