1

I would like to know why I have a warning message.

My code was

 univ_quali<-function(dataset){ print(cbind((addmargins(prop.table(dataset))), t(t(dataset))))}
> univ_quali(table(sex))
       [,1] [,2]
1 0.5471698   58
2 0.4528302   48

It work but I have:

Warning message:
In cbind((addmargins(prop.table(dataset))), t(t(dataset))) :
  number of rows of result is not a multiple of vector length (arg 1)  
Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
E.bl
  • 27
  • 4

1 Answers1

0

The warning does not occur if you simply remove the addmargins() function:

univ_quali <- function(dataset){cbind(prop.table(dataset), t(t(dataset)))}
univ_quali(table(sex))
#            [,1] [,2]
#female 0.4245283   45
#male   0.5754717   61

data (similar to a previous post)

set.seed(24)
sex <- sample(c("male", "female"), 106, replace=TRUE)
Community
  • 1
  • 1
RHertel
  • 23,412
  • 5
  • 38
  • 64