dynamycally change the name of variables in dataframe

I have a summary below 6*5

	   AA	AB	AC	AD	AE
WA  	66	40	68	64	22
CA	    27	31	34	64	33
NY	    41	52	32	43	69
LA	    49	30	48	62	28
Total	183	153	182	233	152

if i want to dynamically change the "Total" to "sum" for every summary, because my symmary will always give Total
how can i change it dynamically

is it a data.frame or a matrix? I ask because WA, CA,NY,LA, Total don't appear to be under a column with any name

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

Is there a name for the column, will this be consistent? Or is the best approach to assume the first column contains it?

yes i converted to a dataframe

tab1 <- cro_cpct(dat1[[1]],dat1[[2]])
tab1 <- as.data.frame(tab1)

I assume you mean that assuming its the first column works..

tab1 <- cro_cpct(dat1[[1]],dat1[[2]])
tab1 <- as.data.frame(tab1)
tab1[which(tab1[,1]=="Total"),1] <- "Sum"

yes this will always give "Total" by default to create summary

awsome, that worked thanks