0

I was trying to score multiple psychological tests for a research. When trying to create a sub scale with the data I cleaned I used the following function:

dat <- subset(data, select = c(CODE, GRUPPE, ZEITPUNKT, POS, NEG,
  SELBSTW, LZ, ERFOLG , MISSERFOLG , OPT , CES, RISK, CESPSYCH
  ,CESSOMAT, HERAUS, SHAME, SELF ))

All scales consist of numeric vectors apart from "CODE".

Fehler: Must subset columns with a valid subscript vector. x Can't convert from to due to loss of precision.

I'm really bad in R so I hope someone can help me how to solve that please

Edit:

Before I did following steps basically with all scales depending on their sub scales, need of recoding and way on scoring..:

POS <-  rowMeans(data[,c("PANAS1", "PANAS3", "PANAS4","PANAS6", "PANAS10", "PANAS11", "PANAS13","PANAS15", "PANAS17", "PANAS18")])

NEG <-  rowMeans(data[,c("PANAS2", "PANAS5", "PANAS7","PANAS8", "PANAS9", "PANAS12",  "PANAS14","PANAS16","PANAS19", "PANAS20")])

OPT <- rowSums(data[,c("OPT1","OPT2","OPT3")])
Ronak Shah
  • 377,200
  • 20
  • 156
  • 213
Janine
  • 1
  • 1
  • Can you add some data so we can help you? – Jhonathan Oct 27 '21 at 09:25
  • 2
    I can't reproduce your problem, likely because I don't have your data (and perhaps if you are using non-base packages). Please make this question *reproducible*. This includes sample code you've attempted (including listing non-base R packages, and any errors/warnings received), sample *unambiguous* data (e.g., `data.frame(x=...,y=...)` or the output from `dput(head(x))`), and intended output given that input. Refs: https://stackoverflow.com/q/5963269, [mcve], and https://stackoverflow.com/tags/r/info. – r2evans Oct 27 '21 at 09:26
  • 2 examples of my previous steps.. hope this helps: POS <- rowMeans(data[,c("PANAS1", "PANAS3", "PANAS4","PANAS6", "PANAS10", "PANAS11", "PANAS13","PANAS15", "PANAS17", "PANAS18")]) NEG <- rowMeans(data[,c("PANAS2", "PANAS5", "PANAS7","PANAS8", "PANAS9", "PANAS12", "PANAS14","PANAS16","PANAS19", "PANAS20")]) OPT <- rowSums(data[,c("OPT1","OPT2","OPT3")]) – Janine Oct 27 '21 at 10:11
  • [Code samples](https://stackoverflow.com/help/mcve) should be *minimal*, *complete* and representative. Information relevant to the question should be edited into the question, not left in comments. – outis Oct 27 '21 at 19:30

0 Answers0