0

I'd like to generate a descriptive Table using arsenal. Unfortunately some of the data is a factor.

Here is the df

df<-data.frame(group=rep(c("A","B","c"),3), value1=c(1:9), value2=as.character(floor(runif(9,2000,2010))), dummy=rep(c("Yes","No","No")))

Value2 is as.character intentionally, to show the later problem and for later analysis I'd like to keep it as is.

The standard table would be generated like this:

desTab<-tableby(~value1 +as.numeric(value2) + dummy, data= df)
summary(desTab, labelTranslations = labs1, digits= 0)

Leading to an output as follows in Markdown: enter image description here

I'd like to change the labels so the table does not show the "as.numeric()" anymore.

labs1<-list(
  value1 = "Value",
  as.numeric(value2) = "Year",
  dummy = "Dummy"
)

However, this does not solve the labs for "as.numeric".

I'd like the labeling to be like so: enter image description here

Thanks for any help and advice!

Juan
  • 171
  • 1
  • 12
  • What is labs1, please read into https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example and the reprex package – Bruno Jan 05 '20 at 15:46
  • 1
    In `labs1` you would need backticks or quotes around `as.numeric(value2)` – Ben Jan 05 '20 at 15:48
  • Well, this was way too easy... Thanks – Juan Jan 05 '20 at 16:01

0 Answers0