0

I'm trying to do a couple of composite indexes for my thesis. I followed this video indication (https://www.youtube.com/watch?v=vdmYv0YnWEE&ab_channel=DavidCaughlin)

My composite index works

ECEMD$indice3 <- rowMeans(ECEMD[, c("PROFSKILL_WRITESTD2", "PROFSKILL_WRITEGRANT", "PROFSKILL_PUBLISH", "PROFSKILL_HUMANETHIC", "PROFSKILL_ANIMETHIC", "PROFSKILL_IP", "PROFSKILL_PROFETHIC", "RESEXP_WRITEGRANT", "PRESPUBNUM_FUNDMEET", "PRESPUBNUM_NATLMEET", "PRESPUBNUM_PRESMEET", "PRESPUB_SEMINAR", "PRESPUBNUM_COAUTH", "PRESPUBNUM_AUTHOR", "PROFSKILL_CAREERACAD", "PROFSKILL_RESPOS")], na.rm = TRUE)

But as soon as I try to figure out the mean of this composite index for the total of my database or by year, it says NaN (not a number). I am 100% certain that my database contains only numbers.

indice3_mean <- mean(ECEMD$indice3)

There is alot of NA's although. What should I do?

FALA
  • 11
  • 3
  • 1
    Please provide sample data with `dput()`, e.g. `dput(mydata[1:15, ])` for the first 15 rows of the dataframe `mydata`. – Pax Jan 18 '22 at 18:39
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Jan 18 '22 at 18:53
  • Do any of your rows have missing values for all variables? That would trigger division by zero with na.rm=TRUE. – dcarlson Jan 18 '22 at 20:15
  • Yes, some observations have only NA's. How would I remove / change that? – FALA Jan 19 '22 at 00:23
  • How would something like !is.nan() work? – FALA Jan 19 '22 at 01:27

0 Answers0