0

I'd like to create a data.frame with the descriptives of my 107 items in the columns. When I do the order like that, it only gives me the descriptives for my first item. Maybe somebody can help me out and knows what is wrong in the function.

variables <- names(srsi)
names.items <- c(grep("SRSI_", variables, value = TRUE))

item.diff <- data.frame(matrix(NA, ncol=8, nrow=length(names.items)))
names(item.diff) <- c("Item", "n", "mean", "sd", "min", "max", "range", "se")
length(names.items)

for(i in 1:length(names.items)){

  item <- names.items[i]

  par <- describe(srsi[,-1], skew = F)

  item.diff[i, c("n", "mean", "sd", "min", "max", "range", "se")] 

}
SternK
  • 11,649
  • 22
  • 32
  • 46
natash
  • 127
  • 5
  • 2
    What is `srsi`. Can you show a small reproducible example. In the looop, the `describe(srsi[,-1]` is repeated – akrun May 31 '20 at 19:57
  • Seems to be a duplicate of [R - describe() output to a data frame](https://stackoverflow.com/questions/37908545/r-describe-output-to-a-data-frame) but there are `describe` functions in `Hmisc` and `psych` and possibly other packages. It would be simpler to use `numSummary` in `RcmdrMisc`. – dcarlson May 31 '20 at 22:30

0 Answers0