Compare data content of 2 rows to get the content for a third row

I want to create a column whose contents depend on the matching of two other column contents.

In my special case i have the colums response (= respone of the person) and correctResponse (= what is actually the right respone). Coded with yes (=1) and No (0=).
If there is a match between the contents of the row e.g. 0 and 0 or. 1 and 1 i want the third column to say "correct" (or a 1)
If there is a between the contents of the row e.g. 0 and 1 i want the third column to say (or a 1)

I have no idea how to handle this and did not found anything like this.

Thanks for your help!

This is a way to get the result you want (there are many ways)

library(dplyr)

# Made up data just to exemplify, you can replace this with your own data frame
sample_data <- data.frame(
    response = c(0, 1, 0, 1),
    correctResponse = c(1, 0, 0, 1)
)

# Relevant code
sample_data %>% 
    mutate(test = as.numeric(response == correctResponse))
#>   response correctResponse test
#> 1        0               1    0
#> 2        1               0    0
#> 3        0               0    1
#> 4        1               1    1

Created on 2022-05-29 by the reprex package (v2.0.1)

Note: Next time please provide a proper REPRoducible EXample (reprex) illustrating your issue.

1 Like

Thank you very much!
Next time i will!
My data frame is actually really long (more than 1000 rows). Therfore this solution takes much time.
Is there a possibiliy for much longer data frames? The 3 colums are also part of a data frame out of 7 colums.

That is actually a rather small data set and execution shouldn't take more than a few seconds, maybe you are confused about how I defined sample data on the example I gave, I did that just for reproducibility purposes, there is no need for you to do the same, you can simply use your own data frame.

To be crystal clear, you are not supposed to do this part.

If you read the reprex guide you would understand why I did this but you are not supposed to do the same.

2 Likes

I have another similar question.
I want to create a new column whose content also depends on another column.
The independent column contains one of the following:
EGb1, EGb4, EGb6, EGb13, EGb14; EGr1, EGr4, EGr6, EGr13, EGr14;
EGg1, EGg4, EGg6, EGg13, EGg14
CLb0, CLb5, CLb5; CLr0, CLr5, CLr5; CLr0, CLr5, CLr5;
So, as you can see, every possible column content contains a number.
In the new dependent column, only the number of the content should appear depending on the corresponding row value of the independent column.
I hope that was understandable?
Is there any possibility for this?

Thank you so much!

Translated with DeepL Translate: The world's most accurate translator (free version)

Your question is not very clear and once again you are not providing a proper reproducible example for your question, which makes helping you harder than it should be. This is the best I can do for you with the information you have provided

library(dplyr)
library(stringr)

# Sample data on a copy/paste friendly format
sample_data <- data.frame(
    old_column = c("EGb1", "EGb4", "EGb6", "EGb13", "EGb14", "EGr1", "EGr4", "EGr6", "EGr13", "EGr14",
                   "EGg1", "EGg4", "EGg6", "EGg13", "EGg14", "CLb0", "CLb5", "CLb5", "CLr0", "CLr5",
                   "CLr5", "CLr0", "CLr5", "CLr5"))

# Relevant code
sample_data %>% 
    mutate(new_column = as.numeric(str_extract(old_column, "\\d+$")))
#>    old_column new_column
#> 1        EGb1          1
#> 2        EGb4          4
#> 3        EGb6          6
#> 4       EGb13         13
#> 5       EGb14         14
#> 6        EGr1          1
#> 7        EGr4          4
#> 8        EGr6          6
#> 9       EGr13         13
#> 10      EGr14         14
#> 11       EGg1          1
#> 12       EGg4          4
#> 13       EGg6          6
#> 14      EGg13         13
#> 15      EGg14         14
#> 16       CLb0          0
#> 17       CLb5          5
#> 18       CLb5          5
#> 19       CLr0          0
#> 20       CLr5          5
#> 21       CLr5          5
#> 22       CLr0          0
#> 23       CLr5          5
#> 24       CLr5          5

Created on 2022-05-31 by the reprex package (v2.0.1)

Also, if you have a different question, please ask it on a new topic with a well-defined title, doing so helps to keep the forum tidy and makes your question useful not only for you but for others facing similar issues.

2 Likes

I am sorry!
Maybe it is easier for you to see the df:

Details

sender correct correctResponse response Kategorie subjects Assoziationstärke
1      CLr15   FALSE               1        0         2        1                 5
2       CLg0    TRUE               1        1         1        1                 4
3       CLb5   FALSE               1        0         3        1                 4
4       CLr0   FALSE               1        0         2        1                 4
5       CLg5    TRUE               1        1         1        1                 4
6      CLr15   FALSE               1        0         2        1                 5
7      CLg15    TRUE               1        1         1        1                 5
8       EGg6    TRUE               1        1         1        1                 4
9       EGb4   FALSE               1        1         3        1                 4
10     EGb13   FALSE               1        0         3        1                 5
11      CLg5   FALSE               1        0         1        1                 4
12      EGr1   FALSE               1        0         2        1                 4
13      EGg1    TRUE               1        1         1        1                 4
14      EGg4    TRUE               1        1         1        1                 4
15      EGg4    TRUE               1        1         1        1                 4
16     EGr13   FALSE               1        0         2        1                 5
17      CLr0   FALSE               1        0         2        1                 4
18      CLr0   FALSE               1        0         2        1                 4
19      CLr5   FALSE               1        0         2        1                 4
20      EGg1    TRUE               1        1         1        1                 4
21       FWb    TRUE               1        1         0        1                 3
22     CLb15   FALSE               1        0         3        1                 5
23     EGr14    TRUE               1        1         2        1                 5
24      EGg6    TRUE               1        1         1        1                 4
25      EGg1    TRUE               1        1         1        1                 4
26     EGg13    TRUE               1        1         1        1                 5
27     EGg14    TRUE               1        1         1        1                 5
28      CLb0    TRUE               1        1         3        1                 4
29       FWr   FALSE               1        0         0        1                 3
30      EGr4   FALSE               1        0         2        1                 4
31      EGb4   FALSE               1        0         3        1                 4
32     EGg14   FALSE               1        1         1        1                 5
33      CLg5   FALSE               1        0         1        1                 4
34      EGb1   FALSE               1        0         3        1                 4
35     EGg13    TRUE               1        1         1        1                 5
36     EGr13   FALSE               1        0         2        1                 5
37      EGg4    TRUE               1        1         1        1                 4
38       suW    TRUE               0        0         0        1                 3
39      EGb1   FALSE               1        1         3        1                 4
40      EGb6   FALSE               1        1         3        1                 4
41       suW   FALSE               0        1         0        1                 3
42       suW    TRUE               0        0         0        1                 3
43      EGg4    TRUE               1        1         1        1                 4
44     EGg13    TRUE               1        1         1        1                 5
45     CLb15   FALSE               1        1         3        1                 5
46       FWg   FALSE               1        0         0        1                 3
47     EGr14   FALSE               1        0         2        1                 5
48      EGr1   FALSE               1        0         2        1                 4
49     CLg15   FALSE               1        1         1        1                 5
50     EGr14   FALSE               1        1         2        1                 5
51     CLb15   FALSE               1        0         3        1                 5
52     EGr14   FALSE               1        0         2        1                 5
53       suW   FALSE               0        1         0        1                 3
54      EGg4    TRUE               1        1         1        1                 4
55     EGg14    TRUE               1        1         1        1                 5
56      CLb0   FALSE               1        1         3        1                 4
57      EGr6   FALSE               1        1         2        1                 4
58     CLg15    TRUE               1        1         1        1                 5
59      EGb1   FALSE               1        1         3        1                 4
60      EGg6    TRUE               1        1         1        1                 4
61       suW    TRUE               0        0         0        1                 3
62      EGr6   FALSE               1        0         2        1                 4
63       FWg   FALSE               1        0         0        1                 3
64      EGr4   FALSE               1        1         2        1                 4
65     EGb14    TRUE               1        1         3        1                 5
66       suW    TRUE               0        0         0        1                 3
67      EGr6   FALSE               1        0         2        1                 4
68      CLg0    TRUE               1        1         1        1                 4
69     EGg14   FALSE               1        1         1        1                 5
70      CLb5   FALSE               1        0         3        1                 4
71     CLb15    TRUE               1        1         3        1                 5
72       suW    TRUE               0        0         0        1                 3
73     CLg15    TRUE               1        1         1        1                 5
74     CLr15   FALSE               1        0         2        1                 5
75     EGr14    TRUE               1        1         2        1                 5
76     EGb14   FALSE               1        0         3        1                 5
77      EGr4   FALSE               1        1         2        1                 4
78      CLb0   FALSE               1        1         3        1                 4
79      EGb4    TRUE               1        1         3        1                 4
80     EGg14    TRUE               1        1         1        1                 5
81      EGb4    TRUE               1        1         3        1                 4
82     EGb14    TRUE               1        1         3        1                 5
83       suW    TRUE               0        0         0        1                 3
84      EGb6   FALSE               1        0         3        1                 4
85      CLg0    TRUE               1        1         1        1                 4
86      CLr0   FALSE               1        1         2        1                 4
87      EGg1    TRUE               1        1         1        1                 4
88      CLb0   FALSE               1        1         3        1                 4
89      CLb0   FALSE               1        1         3        1                 4
90     EGr13   FALSE               1        1         2        1                 5
91      EGr4   FALSE               1        0         2        1                 4
92     EGg13    TRUE               1        1         1        1                 5
93     EGg13    TRUE               1        1         1        1                 5
94      EGr1   FALSE               1        1         2        1                 4
95       suW    TRUE               0        0         0        1                 3
96      EGb6    TRUE               1        1         3        1                 4
97       FWg   FALSE               1        1         0        1                 3
98     EGb13   FALSE               1        1         3        1                 5
99     CLr15   FALSE               1        0         2        1                 5
100     CLr5   FALSE               1        0         2        1                 4
101    EGb13    TRUE               1        1         3        1                 5
102     CLb5   FALSE               1        0         3        1                 4
103      FWr    TRUE               1        1         0        1                 3
104     EGb1    TRUE               1        1         3        1                 4
105    EGr13   FALSE               1        0         2        1                 5
106      FWb   FALSE               1        0         0        1                 3
107     EGb1   FALSE               1        1         3        1                 4
108      suW   FALSE               0        1         0        1                 3
109     EGb6   FALSE               1        1         3        1                 4
110     CLb5   FALSE               1        0         3        1                 4
111     CLr5   FALSE               1        0         2        1                 4
112     EGg6    TRUE               1        1         1        1                 4
113      suW    TRUE               0        0         0        1                 3
114     CLg5   FALSE               1        0         1        1                 4
115    EGb13    TRUE               1        1         3        1                 5
116    CLr15    TRUE               1        1         2        1                 5
117     EGr1   FALSE               1        1         2        1                 4
118    EGb14   FALSE               1        0         3        1                 5
119      suW    TRUE               0        0         0        1                 3
120     CLg5   FALSE               1        0         1        1                 4
121     CLg0    TRUE               1        1         1        1                 4
122    CLb15   FALSE               1        1         3        1                 5
123    CLg15   FALSE               1        0         1        1                 5
124     EGr4   FALSE               1        0         2        1                 4
125     EGg1   FALSE               1        1         1        1                 4
126     EGb4   FALSE               1        0         3        1                 4
127     EGr6   FALSE               1        0         2        1                 4
128    EGb13   FALSE               1        1         3        1                 5
129    EGb14   FALSE               1        1         3        1                 5
130     EGb6   FALSE               1        0         3        1                 4
131     CLb5    TRUE               1        1         3        1                 4
132     EGr6   FALSE               1        0         2        1                 4
133     CLr0   FALSE               1        1         2        1                 4
134     CLr5   FALSE               1        0         2        1                 4
135     EGr1   FALSE               1        0         2        1                 4
136      FWb   FALSE               1        0         0        1                 3
137     CLg0    TRUE               1        1         1        1                 4
138     EGg6    TRUE               1        1         1        1                 4
139    EGr13    TRUE               1        1         2        1                 5
140     CLr5   FALSE               1        0         2        1                 4
141      FWr   FALSE               1        1         0        1                 3
142 Sequence      NA            <NA>     <NA>        NA        1                 8

the first column contains the addressed word codes. I have tried to apply your command once. The results are in the column Association Strength (right). So it's not really as it should be yet. Maybe now you understand a little better what I mean.
Thanks again!

Yes, it would be easier, but you are not posting the data frame in a copy/paste friendly format, it takes extra effort to parse the content from unformatted text and it is not very likely people are going to do this every time you ask for help. Please read the reprex guide I gave you and try to provide a proper reprex next time.

As I understand your problem, you are trying to extract the last digits from the content of the sender column and add save them on the Assoziationstärke column, if so, the code that I gave you works as expected, take a look at this example

library(dplyr)
library(stringr)

# Sample data on a copy/paste friendly format
sample_data <- data.frame(
   stringsAsFactors = FALSE,
             sender = c("CLr15","CLg0","CLb5",
                        "CLr0","CLg5","CLr15","CLg15","EGg6","EGb4","EGb13",
                        "CLg5","EGr1","EGg1","EGg4","EGg4","EGr13","CLr0",
                        "CLr0","CLr5","EGg1","FWb","CLb15","EGr14","EGg6",
                        "EGg1","EGg13","EGg14","CLb0","FWr","EGr4","EGb4",
                        "EGg14","CLg5","EGb1","EGg13","EGr13","EGg4",
                        "suW","EGb1","EGb6","suW","suW","EGg4","EGg13",
                        "CLb15","FWg","EGr14","EGr1","CLg15","EGr14","CLb15",
                        "EGr14","suW","EGg4","EGg14","CLb0","EGr6","CLg15",
                        "EGb1","EGg6","suW","EGr6","FWg","EGr4","EGb14",
                        "suW","EGr6","CLg0","EGg14","CLb5","CLb15","suW",
                        "CLg15","CLr15","EGr14","EGb14","EGr4","CLb0",
                        "EGb4","EGg14","EGb4","EGb14","suW","EGb6","CLg0",
                        "CLr0","EGg1","CLb0","CLb0","EGr13","EGr4","EGg13",
                        "EGg13","EGr1","suW","EGb6","FWg","EGb13","CLr15",
                        "CLr5","EGb13","CLb5","FWr","EGb1","EGr13","FWb",
                        "EGb1","suW","EGb6","CLb5","CLr5","EGg6","suW",
                        "CLg5","EGb13","CLr15","EGr1","EGb14","suW","CLg5",
                        "CLg0","CLb15","CLg15","EGr4","EGg1","EGb4","EGr6",
                        "EGb13","EGb14","EGb6","CLb5","EGr6","CLr0",
                        "CLr5","EGr1","FWb","CLg0","EGg6","EGr13","CLr5",
                        "FWr"),
            correct = c(FALSE,TRUE,FALSE,FALSE,
                        TRUE,FALSE,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,TRUE,
                        TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE,
                        FALSE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,FALSE,FALSE,
                        FALSE,FALSE,FALSE,FALSE,TRUE,FALSE,TRUE,TRUE,FALSE,
                        FALSE,FALSE,TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,
                        FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE,
                        FALSE,FALSE,TRUE,FALSE,TRUE,TRUE,FALSE,FALSE,FALSE,
                        TRUE,TRUE,FALSE,TRUE,FALSE,FALSE,TRUE,TRUE,TRUE,
                        FALSE,TRUE,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE,
                        TRUE,TRUE,FALSE,TRUE,FALSE,TRUE,FALSE,FALSE,FALSE,
                        FALSE,TRUE,TRUE,FALSE,TRUE,TRUE,FALSE,FALSE,
                        FALSE,FALSE,TRUE,FALSE,TRUE,TRUE,FALSE,FALSE,FALSE,
                        FALSE,FALSE,FALSE,FALSE,TRUE,TRUE,FALSE,TRUE,
                        TRUE,FALSE,FALSE,TRUE,FALSE,TRUE,FALSE,FALSE,FALSE,
                        FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,TRUE,FALSE,
                        FALSE,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE,FALSE,
                        FALSE),
    correctResponse = c(1,1,1,1,1,1,1,1,1,1,
                        1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
                        1,1,1,1,1,1,1,1,0,1,1,0,0,1,1,1,1,1,
                        1,1,1,1,1,0,1,1,1,1,1,1,1,0,1,1,1,1,0,
                        1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,0,1,1,
                        1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,
                        1,1,1,1,0,1,1,1,1,0,1,1,1,1,1,0,1,1,1,
                        1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),
           response = c(0,1,0,0,1,0,1,1,1,0,
                        0,0,1,1,1,0,0,0,0,1,1,0,1,1,1,1,1,1,0,
                        0,0,1,0,0,1,0,1,0,1,1,1,0,1,1,1,0,0,
                        0,1,1,0,0,1,1,1,1,1,1,1,1,0,0,0,1,1,0,
                        0,1,1,0,1,0,1,0,1,0,1,1,1,1,1,1,0,0,1,
                        1,1,1,1,1,0,1,1,1,0,1,1,1,0,0,1,0,1,
                        1,0,0,1,1,1,0,0,1,0,0,1,1,1,0,0,0,1,1,
                        0,0,1,0,0,1,1,0,1,0,1,0,0,0,1,1,1,0,1),
          Kategorie = c(2,1,3,2,1,2,1,1,3,3,
                        1,2,1,1,1,2,2,2,2,1,0,3,2,1,1,1,1,3,0,
                        2,3,1,1,3,1,2,1,0,3,3,0,0,1,1,3,0,2,
                        2,1,2,3,2,0,1,1,3,2,1,3,1,0,2,0,2,3,0,
                        2,1,1,3,3,0,1,2,2,3,2,3,3,1,3,3,0,3,1,
                        2,1,3,3,2,2,1,1,2,0,3,0,3,2,2,3,3,0,
                        3,2,0,3,0,3,3,2,1,0,1,3,2,2,3,0,1,1,3,
                        1,2,1,3,2,3,3,3,3,2,2,2,2,0,1,1,2,2,0),
           subjects = c(1,1,1,1,1,1,1,1,1,1,
                        1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
                        1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
                        1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
                        1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
                        1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
                        1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
                        1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),
  Assoziationstärke = c(5,4,4,4,4,5,5,4,4,5,
                        4,4,4,4,4,5,4,4,4,4,3,5,5,4,4,5,5,4,3,
                        4,4,5,4,4,5,5,4,3,4,4,3,3,4,5,5,3,5,
                        4,5,5,5,5,3,4,5,4,4,5,4,4,3,4,3,4,5,3,
                        4,4,5,4,5,3,5,5,5,5,4,4,4,5,4,5,3,4,4,
                        4,4,4,4,5,4,5,5,4,3,4,3,5,5,4,5,4,3,
                        4,5,3,4,3,4,4,4,4,3,4,5,5,4,5,3,4,4,5,
                        5,4,4,4,4,5,5,4,4,4,4,4,4,3,4,4,5,4,3)
)

# Relevant code
sample_data %>%
    mutate(Assoziationstärke = as.numeric(str_extract(sender, "\\d+$")))
#>     sender correct correctResponse response Kategorie subjects
#> 1    CLr15   FALSE               1        0         2        1
#> 2     CLg0    TRUE               1        1         1        1
#> 3     CLb5   FALSE               1        0         3        1
#> 4     CLr0   FALSE               1        0         2        1
#> 5     CLg5    TRUE               1        1         1        1
#> 6    CLr15   FALSE               1        0         2        1
#> 7    CLg15    TRUE               1        1         1        1
#> 8     EGg6    TRUE               1        1         1        1
#> 9     EGb4   FALSE               1        1         3        1
#> 10   EGb13   FALSE               1        0         3        1
#> 11    CLg5   FALSE               1        0         1        1
#> 12    EGr1   FALSE               1        0         2        1
#> 13    EGg1    TRUE               1        1         1        1
#> 14    EGg4    TRUE               1        1         1        1
#> 15    EGg4    TRUE               1        1         1        1
#> 16   EGr13   FALSE               1        0         2        1
#> 17    CLr0   FALSE               1        0         2        1
#> 18    CLr0   FALSE               1        0         2        1
#> 19    CLr5   FALSE               1        0         2        1
#> 20    EGg1    TRUE               1        1         1        1
#> 21     FWb    TRUE               1        1         0        1
#> 22   CLb15   FALSE               1        0         3        1
#> 23   EGr14    TRUE               1        1         2        1
#> 24    EGg6    TRUE               1        1         1        1
#> 25    EGg1    TRUE               1        1         1        1
#> 26   EGg13    TRUE               1        1         1        1
#> 27   EGg14    TRUE               1        1         1        1
#> 28    CLb0    TRUE               1        1         3        1
#> 29     FWr   FALSE               1        0         0        1
#> 30    EGr4   FALSE               1        0         2        1
#> 31    EGb4   FALSE               1        0         3        1
#> 32   EGg14   FALSE               1        1         1        1
#> 33    CLg5   FALSE               1        0         1        1
#> 34    EGb1   FALSE               1        0         3        1
#> 35   EGg13    TRUE               1        1         1        1
#> 36   EGr13   FALSE               1        0         2        1
#> 37    EGg4    TRUE               1        1         1        1
#> 38     suW    TRUE               0        0         0        1
#> 39    EGb1   FALSE               1        1         3        1
#> 40    EGb6   FALSE               1        1         3        1
#> 41     suW   FALSE               0        1         0        1
#> 42     suW    TRUE               0        0         0        1
#> 43    EGg4    TRUE               1        1         1        1
#> 44   EGg13    TRUE               1        1         1        1
#> 45   CLb15   FALSE               1        1         3        1
#> 46     FWg   FALSE               1        0         0        1
#> 47   EGr14   FALSE               1        0         2        1
#> 48    EGr1   FALSE               1        0         2        1
#> 49   CLg15   FALSE               1        1         1        1
#> 50   EGr14   FALSE               1        1         2        1
#> 51   CLb15   FALSE               1        0         3        1
#> 52   EGr14   FALSE               1        0         2        1
#> 53     suW   FALSE               0        1         0        1
#> 54    EGg4    TRUE               1        1         1        1
#> 55   EGg14    TRUE               1        1         1        1
#> 56    CLb0   FALSE               1        1         3        1
#> 57    EGr6   FALSE               1        1         2        1
#> 58   CLg15    TRUE               1        1         1        1
#> 59    EGb1   FALSE               1        1         3        1
#> 60    EGg6    TRUE               1        1         1        1
#> 61     suW    TRUE               0        0         0        1
#> 62    EGr6   FALSE               1        0         2        1
#> 63     FWg   FALSE               1        0         0        1
#> 64    EGr4   FALSE               1        1         2        1
#> 65   EGb14    TRUE               1        1         3        1
#> 66     suW    TRUE               0        0         0        1
#> 67    EGr6   FALSE               1        0         2        1
#> 68    CLg0    TRUE               1        1         1        1
#> 69   EGg14   FALSE               1        1         1        1
#> 70    CLb5   FALSE               1        0         3        1
#> 71   CLb15    TRUE               1        1         3        1
#> 72     suW    TRUE               0        0         0        1
#> 73   CLg15    TRUE               1        1         1        1
#> 74   CLr15   FALSE               1        0         2        1
#> 75   EGr14    TRUE               1        1         2        1
#> 76   EGb14   FALSE               1        0         3        1
#> 77    EGr4   FALSE               1        1         2        1
#> 78    CLb0   FALSE               1        1         3        1
#> 79    EGb4    TRUE               1        1         3        1
#> 80   EGg14    TRUE               1        1         1        1
#> 81    EGb4    TRUE               1        1         3        1
#> 82   EGb14    TRUE               1        1         3        1
#> 83     suW    TRUE               0        0         0        1
#> 84    EGb6   FALSE               1        0         3        1
#> 85    CLg0    TRUE               1        1         1        1
#> 86    CLr0   FALSE               1        1         2        1
#> 87    EGg1    TRUE               1        1         1        1
#> 88    CLb0   FALSE               1        1         3        1
#> 89    CLb0   FALSE               1        1         3        1
#> 90   EGr13   FALSE               1        1         2        1
#> 91    EGr4   FALSE               1        0         2        1
#> 92   EGg13    TRUE               1        1         1        1
#> 93   EGg13    TRUE               1        1         1        1
#> 94    EGr1   FALSE               1        1         2        1
#> 95     suW    TRUE               0        0         0        1
#> 96    EGb6    TRUE               1        1         3        1
#> 97     FWg   FALSE               1        1         0        1
#> 98   EGb13   FALSE               1        1         3        1
#> 99   CLr15   FALSE               1        0         2        1
#> 100   CLr5   FALSE               1        0         2        1
#> 101  EGb13    TRUE               1        1         3        1
#> 102   CLb5   FALSE               1        0         3        1
#> 103    FWr    TRUE               1        1         0        1
#> 104   EGb1    TRUE               1        1         3        1
#> 105  EGr13   FALSE               1        0         2        1
#> 106    FWb   FALSE               1        0         0        1
#> 107   EGb1   FALSE               1        1         3        1
#> 108    suW   FALSE               0        1         0        1
#> 109   EGb6   FALSE               1        1         3        1
#> 110   CLb5   FALSE               1        0         3        1
#> 111   CLr5   FALSE               1        0         2        1
#> 112   EGg6    TRUE               1        1         1        1
#> 113    suW    TRUE               0        0         0        1
#> 114   CLg5   FALSE               1        0         1        1
#> 115  EGb13    TRUE               1        1         3        1
#> 116  CLr15    TRUE               1        1         2        1
#> 117   EGr1   FALSE               1        1         2        1
#> 118  EGb14   FALSE               1        0         3        1
#> 119    suW    TRUE               0        0         0        1
#> 120   CLg5   FALSE               1        0         1        1
#> 121   CLg0    TRUE               1        1         1        1
#> 122  CLb15   FALSE               1        1         3        1
#> 123  CLg15   FALSE               1        0         1        1
#> 124   EGr4   FALSE               1        0         2        1
#> 125   EGg1   FALSE               1        1         1        1
#> 126   EGb4   FALSE               1        0         3        1
#> 127   EGr6   FALSE               1        0         2        1
#> 128  EGb13   FALSE               1        1         3        1
#> 129  EGb14   FALSE               1        1         3        1
#> 130   EGb6   FALSE               1        0         3        1
#> 131   CLb5    TRUE               1        1         3        1
#> 132   EGr6   FALSE               1        0         2        1
#> 133   CLr0   FALSE               1        1         2        1
#> 134   CLr5   FALSE               1        0         2        1
#> 135   EGr1   FALSE               1        0         2        1
#> 136    FWb   FALSE               1        0         0        1
#> 137   CLg0    TRUE               1        1         1        1
#> 138   EGg6    TRUE               1        1         1        1
#> 139  EGr13    TRUE               1        1         2        1
#> 140   CLr5   FALSE               1        0         2        1
#> 141    FWr   FALSE               1        1         0        1
#>     Assoziationstärke
#> 1                  15
#> 2                   0
#> 3                   5
#> 4                   0
#> 5                   5
#> 6                  15
#> 7                  15
#> 8                   6
#> 9                   4
#> 10                 13
#> 11                  5
#> 12                  1
#> 13                  1
#> 14                  4
#> 15                  4
#> 16                 13
#> 17                  0
#> 18                  0
#> 19                  5
#> 20                  1
#> 21                 NA
#> 22                 15
#> 23                 14
#> 24                  6
#> 25                  1
#> 26                 13
#> 27                 14
#> 28                  0
#> 29                 NA
#> 30                  4
#> 31                  4
#> 32                 14
#> 33                  5
#> 34                  1
#> 35                 13
#> 36                 13
#> 37                  4
#> 38                 NA
#> 39                  1
#> 40                  6
#> 41                 NA
#> 42                 NA
#> 43                  4
#> 44                 13
#> 45                 15
#> 46                 NA
#> 47                 14
#> 48                  1
#> 49                 15
#> 50                 14
#> 51                 15
#> 52                 14
#> 53                 NA
#> 54                  4
#> 55                 14
#> 56                  0
#> 57                  6
#> 58                 15
#> 59                  1
#> 60                  6
#> 61                 NA
#> 62                  6
#> 63                 NA
#> 64                  4
#> 65                 14
#> 66                 NA
#> 67                  6
#> 68                  0
#> 69                 14
#> 70                  5
#> 71                 15
#> 72                 NA
#> 73                 15
#> 74                 15
#> 75                 14
#> 76                 14
#> 77                  4
#> 78                  0
#> 79                  4
#> 80                 14
#> 81                  4
#> 82                 14
#> 83                 NA
#> 84                  6
#> 85                  0
#> 86                  0
#> 87                  1
#> 88                  0
#> 89                  0
#> 90                 13
#> 91                  4
#> 92                 13
#> 93                 13
#> 94                  1
#> 95                 NA
#> 96                  6
#> 97                 NA
#> 98                 13
#> 99                 15
#> 100                 5
#> 101                13
#> 102                 5
#> 103                NA
#> 104                 1
#> 105                13
#> 106                NA
#> 107                 1
#> 108                NA
#> 109                 6
#> 110                 5
#> 111                 5
#> 112                 6
#> 113                NA
#> 114                 5
#> 115                13
#> 116                15
#> 117                 1
#> 118                14
#> 119                NA
#> 120                 5
#> 121                 0
#> 122                15
#> 123                15
#> 124                 4
#> 125                 1
#> 126                 4
#> 127                 6
#> 128                13
#> 129                14
#> 130                 6
#> 131                 5
#> 132                 6
#> 133                 0
#> 134                 5
#> 135                 1
#> 136                NA
#> 137                 0
#> 138                 6
#> 139                13
#> 140                 5
#> 141                NA

Created on 2022-06-01 by the reprex package (v2.0.1)

If this is not what you want to do, can you explain your problem in the context of this example?

2 Likes

I found my mistake! I am sorry next time i will follow your community rules. Sorry for the extra work.

sample_data <- data(
sender = c(EGb13, EGr4, EGg14, EGr6),
correct = c(1, 0, 0, 1),
category = c(2,1,3,1),
subjects = c(1,1,2,2),
mp = c(1,1,2,2),
as = (1,4,6,13)
)

I hope this is ok. I tried it with the reprx, but the datapasta package didn't work for me somehow. So I did it manually now.

I am currently trying to calculate a hit rate:

Hitrate <- data[,.(hitRate= sum(1)/(15)),
by = .(participant, category,mp,as)]
or
Hitrate <- data[,.(hitRate = sum(correct)/15),
by = .(subjects, Ratings, AS)]

I need to calculate the hit rate for each participant depending on the category , the mode of presentation (mp) and the association strength (as). My idea was therefore to divide the sum of all hits from the correct column by the maximum correct number of hits (in this case 15) for each subject. Unfortunately, I don't quite know how to specify that the number of hits should be taken from the category column. Would that work then or do you have a better solution? Thank you very much!
My goal is to calculate an ANOVA with the between factor presentation mode (pm) and the within factors category and association strength (as). For this I first need the hitrates per subject

Do i have to post this in an extra topic?

You can use head(dput(dataset)) to create paste-able code to reproduce the first 6 rows of a dataset or more - probably more in this case as your senders have more than one row at times. Also your pseudo code has participant, and Ratings, but neither are in your sample data.

As it stands, unfortunately, it's pretty difficult to gleam what you are hoping to accomplish as there are variables in your .by = statement not in your sample data.

structure(list(sender = c("EGg6", "EGb4", "EGb13", "EGr1", "EGg1", 
"EGg4", "EGg4", "EGr13", "EGg1", "EGr14", "EGg6", "EGg1", "EGg13", 
"EGg14", "EGr4", "EGb4", "EGg14", "EGb1", "EGg13", "EGr13", "EGg4", 
"EGb1", "EGb6", "EGg4", "EGg13", "EGr14", "EGr1", "EGr14", "EGr14", 
"EGg4", "EGg14", "EGr6", "EGb1", "EGg6", "EGr6", "EGr4", "EGb14", 
"EGr6", "EGg14", "EGr14", "EGb14", "EGr4", "EGb4", "EGg14", "EGb4", 
"EGb14", "EGb6", "EGg1", "EGr13", "EGr4", "EGg13", "EGg13", "EGr1", 
"EGb6", "EGb13", "EGb13", "EGb1", "EGr13", "EGb1", "EGb6", "EGg6", 
"EGb13", "EGr1", "EGb14", "EGr4", "EGg1", "EGb4", "EGr6", "EGb13", 
"EGb14", "EGb6", "EGr6", "EGr1", "EGg6", "EGr13", "EGg14", "EGr4", 
"EGr6", "EGr13", "EGr1", "EGb4", "EGr13", "EGr4", "EGg4", "EGb1", 
"EGb4", "EGg6", "EGr14", "EGr4", "EGr6", "EGg14", "EGr6", "EGg13", 
"EGr1", "EGb13", "EGg4", "EGr14", "EGg1", "EGr14", "EGg6", "EGg13", 
"EGb14", "EGg14", "EGb6", "EGb13", "EGg14", "EGb1", "EGr14", 
"EGr4", "EGb6", "EGb6", "EGg4", "EGb4", "EGb13", "EGr13", "EGg6", 
"EGg6", "EGr1", "EGb4", "EGr1", "EGb14", "EGg6", "EGr13", "EGg1", 
"EGb4", "EGr14", "EGg4", "EGg14", "EGg1", "EGg1", "EGg13", "EGb14", 
"EGg1", "EGb6", "EGg13", "EGb13", "EGg13", "EGr6", "EGb6", "EGg4", 
"EGb1", "EGb14", "EGr4", "EGb14", "EGb13", "EGr6", "EGr13", "EGb1", 
"EGb1", "EGr1", "EGr13", "EGb14", "EGg14", "EGb6", "EGg6", "EGr13", 
"EGb1", "EGg6", "EGb13", "EGr4", "EGb14", "EGr14", "EGb1", "EGr1", 
"EGg1", "EGr14", "EGr1", "EGb6", "EGb13", "EGb13", "EGr6", "EGr4", 
"EGb4", "EGr14", "EGr13", "EGr6", "EGg4", "EGb1", "EGr14", "EGr6", 
"EGg4", "EGg1", "EGb6", "EGg14", "EGr4", "EGb4", "EGr6", "EGr13", 
"EGr6", "EGg4", "EGg4", "EGb13", "EGb14", "EGg6", "EGg13", "EGg14", 
"EGg13", "EGb6", "EGb14", "EGb1", "EGg13", "EGg6", "EGr1", "EGg1", 
"EGg13", "EGg1", "EGg1", "EGb4", "EGr14", "EGg14", "EGr13", "EGr4", 
"EGb14", "EGg14", "EGr1", "EGg6", "EGg4", "EGb13", "EGb4", "EGg13", 
"EGb4", "EGr1", "EGb1", "EGb6", "EGr4", "EGg13", "EGb1", "EGb6", 
"EGb4", "EGr4", "EGr14", "EGg1", "EGb14", "EGr13", "EGr4", "EGb6", 
"EGb6", "EGg13", "EGr13", "EGg6", "EGg14", "EGb1", "EGb4", "EGr1", 
"EGg4", "EGg14", "EGb14", "EGb14", "EGg13", "EGg4", "EGg14", 
"EGg13", "EGr1", "EGr14", "EGb4", "EGg1", "EGg1", "EGg14", "EGb1", 
"EGr6", "EGb13", "EGr4", "EGb1", "EGg13", "EGg14", "EGg1", "EGr14", 
"EGb13", "EGr4", "EGb4", "EGr1", "EGg6", "EGg6", "EGg4", "EGg1", 
"EGr13", "EGb13", "EGr6", "EGb1", "EGb14", "EGr14", "EGr1", "EGr14", 
"EGb4", "EGb14", "EGr6", "EGr1", "EGb13", "EGg6", "EGb13", "EGg4", 
"EGr6", "EGg4", "EGg6", "EGr4", "EGr6", "EGb6", "EGr13", "EGr13", 
"EGb6", "EGg13", "EGr4", "EGb4", "EGb1", "EGb13", "EGb6", "EGb6", 
"EGg6", "EGg14", "EGr14", "EGb4", "EGg13", "EGr4", "EGg13", "EGg14", 
"EGb6", "EGb6", "EGr14", "EGb13", "EGg4", "EGb14", "EGg1", "EGb14", 
"EGr1", "EGb1", "EGb13", "EGb4", "EGg1", "EGg6", "EGr4", "EGb1", 
"EGb14", "EGr13", "EGg4", "EGb4", "EGr6", "EGg4", "EGr6", "EGb1", 
"EGr13", "EGg13", "EGr1", "EGr13", "EGg6", "EGb4", "EGg13", "EGr1", 
"EGr4", "EGr14", "EGr4", "EGb14", "EGg1", "EGr1", "EGr6", "EGg6", 
"EGg6", "EGr14", "EGb1", "EGg1", "EGr13", "EGr6", "EGg14", "EGr6", 
"EGg4", "EGg14", "EGr13", "EGg4", "EGb13", "EGg1", "EGg14", "EGr1", 
"EGb14", "EGb6", "EGb13", "EGr14", "EGb4", "EGr14", "EGb13", 
"EGb4", "EGb13", "EGg6", "EGg4", "EGr4", "EGg1", "EGg4", "EGb4", 
"EGr14", "EGg14", "EGg4", "EGg14", "EGg4", "EGg13", "EGb1", "EGg13", 
"EGr13", "EGg14", "EGr4", "EGg1", "EGg1", "EGb4", "EGr1", "EGb13", 
"EGr13", "EGg6", "EGg14", "EGg13", "EGr6", "EGb1", "EGg13", "EGr14", 
"EGr6", "EGb1", "EGb14", "EGb6", "EGb1", "EGr1", "EGr1", "EGb14", 
"EGg4", "EGb4", "EGb1", "EGg1", "EGr4", "EGr4", "EGg14", "EGr13", 
"EGb13", "EGg6", "EGb14", "EGr6", "EGb14", "EGr14", "EGb6", "EGr1", 
"EGr14", "EGb6", "EGr6", "EGg6", "EGg6", "EGr1", "EGb6", "EGg13", 
"EGr13", "EGr4", "EGr6", "EGb6", "EGg1", "EGb14", "EGb13", "EGr13", 
"EGr1", "EGg4", "EGb13", "EGg14", "EGr14", "EGg6", "EGb1", "EGb14", 
"EGg1", "EGg13", "EGg1", "EGb6", "EGg4", "EGr14", "EGg4", "EGb6", 
"EGr4", "EGb13", "EGb13", "EGg4", "EGb4", "EGr1", "EGb14", "EGb6", 
"EGb13", "EGb1", "EGg1", "EGr14", "EGg4", "EGb4", "EGg6", "EGb14", 
"EGg14", "EGr1", "EGb14", "EGg14", "EGr1", "EGb1", "EGb14", "EGr6", 
"EGr13", "EGr1", "EGr14", "EGg13", "EGg1", "EGg13", "EGg1", "EGr13", 
"EGr6", "EGr6", "EGb1", "EGb13", "EGb1", "EGg6", "EGb6", "EGg6", 
"EGb4", "EGr6", "EGr4", "EGb4", "EGr4", "EGr4", "EGb4", "EGr14", 
"EGb6", "EGr4", "EGg13", "EGg6", "EGg13", "EGr6", "EGg14", "EGr13", 
"EGg14", "EGr13", "EGr13", "EGb13", "EGg6", "EGg1", "EGg13", 
"EGr1", "EGg4", "EGr1", "EGr6", "EGb1", "EGr14", "EGg1", "EGr14", 
"EGb6", "EGr1", "EGb14", "EGb1", "EGr6", "EGg6", "EGg4", "EGb1", 
"EGb13", "EGb14", "EGg14", "EGg14", "EGr13", "EGr14", "EGr6", 
"EGr4", "EGg4", "EGb14", "EGr4", "EGg13", "EGb4", "EGg13", "EGg13", 
"EGg14", "EGr13", "EGb1", "EGb13", "EGr4", "EGg6", "EGr6", "EGb6", 
"EGr13", "EGg1", "EGb4", "EGr14", "EGg14", "EGr6", "EGg1", "EGb6", 
"EGb13", "EGg4", "EGb4", "EGr4", "EGb14", "EGb4", "EGr14", "EGg13", 
"EGb13", "EGb4", "EGb6", "EGr4", "EGb14", "EGr13", "EGb1", "EGr1", 
"EGr13", "EGg6", "EGg4", "EGr1", "EGg14", "EGg6", "EGg1", "EGb6", 
"EGg14", "EGb14", "EGg6", "EGg1", "EGb1", "EGg1", "EGb4", "EGr14", 
"EGr6", "EGr14", "EGb1", "EGr1", "EGb14", "EGb14", "EGg4", "EGb6", 
"EGg13", "EGg6", "EGr14", "EGg6", "EGg4", "EGr14", "EGb13", "EGr13", 
"EGg6", "EGr1", "EGr6", "EGb1", "EGg4", "EGr6", "EGr1", "EGb14", 
"EGr14", "EGr6", "EGg14", "EGg14", "EGr13", "EGg14", "EGb13", 
"EGg13", "EGg1", "EGb13", "EGr4", "EGg14", "EGb6", "EGb13", "EGr4", 
"EGb6", "EGb1", "EGr1", "EGb6", "EGg1", "EGr4", "EGr4", "EGg13", 
"EGb4", "EGb1", "EGg6", "EGb4", "EGr1", "EGg13", "EGb4", "EGr13", 
"EGg4", "EGr6", "EGr13", "EGb13", "EGb4", "EGr4", "EGg13", "EGb6", 
"EGb14", "EGg4", "EGg1", "EGr13"), correct = structure(c(1L, 
2L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 
2L, 1L, 2L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 
1L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 
2L, 1L, 1L, 2L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 2L, 
1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 
2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 
1L, 1L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
1L, 1L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 1L, 2L, 1L, 
2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 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c(6, 4, 
13, 1, 1, 4, 4, 13, 1, 14, 6, 1, 13, 14, 4, 4, 14, 1, 13, 13, 
4, 1, 6, 4, 13, 14, 1, 14, 14, 4, 14, 6, 1, 6, 6, 4, 14, 6, 14, 
14, 14, 4, 4, 14, 4, 14, 6, 1, 13, 4, 13, 13, 1, 6, 13, 13, 1, 
13, 1, 6, 6, 13, 1, 14, 4, 1, 4, 6, 13, 14, 6, 6, 1, 6, 13, 14, 
4, 6, 13, 1, 4, 13, 4, 4, 1, 4, 6, 14, 4, 6, 14, 6, 13, 1, 13, 
4, 14, 1, 14, 6, 13, 14, 14, 6, 13, 14, 1, 14, 4, 6, 6, 4, 4, 
13, 13, 6, 6, 1, 4, 1, 14, 6, 13, 1, 4, 14, 4, 14, 1, 1, 13, 
14, 1, 6, 13, 13, 13, 6, 6, 4, 1, 14, 4, 14, 13, 6, 13, 1, 1, 
1, 13, 14, 14, 6, 6, 13, 1, 6, 13, 4, 14, 14, 1, 1, 1, 14, 1, 
6, 13, 13, 6, 4, 4, 14, 13, 6, 4, 1, 14, 6, 4, 1, 6, 14, 4, 4, 
6, 13, 6, 4, 4, 13, 14, 6, 13, 14, 13, 6, 14, 1, 13, 6, 1, 1, 
13, 1, 1, 4, 14, 14, 13, 4, 14, 14, 1, 6, 4, 13, 4, 13, 4, 1, 
1, 6, 4, 13, 1, 6, 4, 4, 14, 1, 14, 13, 4, 6, 6, 13, 13, 6, 14, 
1, 4, 1, 4, 14, 14, 14, 13, 4, 14, 13, 1, 14, 4, 1, 1, 14, 1, 
6, 13, 4, 1, 13, 14, 1, 14, 13, 4, 4, 1, 6, 6, 4, 1, 13, 13, 
6, 1, 14, 14, 1, 14, 4, 14, 6, 1, 13, 6, 13, 4, 6, 4, 6, 4, 6, 
6, 13, 13, 6, 13, 4, 4, 1, 13, 6, 6, 6, 14, 14, 4, 13, 4, 13, 
14, 6, 6, 14, 13, 4, 14, 1, 14, 1, 1, 13, 4, 1, 6, 4, 1, 14, 
13, 4, 4, 6, 4, 6, 1, 13, 13, 1, 13, 6, 4, 13, 1, 4, 14, 4, 14, 
1, 1, 6, 6, 6, 14, 1, 1, 13, 6, 14, 6, 4, 14, 13, 4, 13, 1, 14, 
1, 14, 6, 13, 14, 4, 14, 13, 4, 13, 6, 4, 4, 1, 4, 4, 14, 14, 
4, 14, 4, 13, 1, 13, 13, 14, 4, 1, 1, 4, 1, 13, 13, 6, 14, 13, 
6, 1, 13, 14, 6, 1, 14, 6, 1, 1, 1, 14, 4, 4, 1, 1, 4, 4, 14, 
13, 13, 6, 14, 6, 14, 14, 6, 1, 14, 6, 6, 6, 6, 1, 6, 13, 13, 
4, 6, 6, 1, 14, 13, 13, 1, 4, 13, 14, 14, 6, 1, 14, 1, 13, 1, 
6, 4, 14, 4, 6, 4, 13, 13, 4, 4, 1, 14, 6, 13, 1, 1, 14, 4, 4, 
6, 14, 14, 1, 14, 14, 1, 1, 14, 6, 13, 1, 14, 13, 1, 13, 1, 13, 
6, 6, 1, 13, 1, 6, 6, 6, 4, 6, 4, 4, 4, 4, 4, 14, 6, 4, 13, 6, 
13, 6, 14, 13, 14, 13, 13, 13, 6, 1, 13, 1, 4, 1, 6, 1, 14, 1, 
14, 6, 1, 14, 1, 6, 6, 4, 1, 13, 14, 14, 14, 13, 14, 6, 4, 4, 
14, 4, 13, 4, 13, 13, 14, 13, 1, 13, 4, 6, 6, 6, 13, 1, 4, 14, 
14, 6, 1, 6, 13, 4, 4, 4, 14, 4, 14, 13, 13, 4, 6, 4, 14, 13, 
1, 1, 13, 6, 4, 1, 14, 6, 1, 6, 14, 14, 6, 1, 1, 1, 4, 14, 6, 
14, 1, 1, 14, 14, 4, 6, 13, 6, 14, 6, 4, 14, 13, 13, 6, 1, 6, 
1, 4, 6, 1, 14, 14, 6, 14, 14, 13, 14, 13, 13, 1, 13, 4, 14, 
6, 13, 4, 6, 1, 1, 6, 1, 4, 4, 13, 4, 1, 6, 4, 1, 13, 4, 13, 
4, 6, 13, 13, 4, 4, 13,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8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 
    8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 
    8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 
    8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 9L, 9L, 
    9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 
    9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 
    9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 
    9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 
    9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L)), class = "data.frame", row.names = c(8L, 
9L, 10L, 12L, 13L, 14L, 15L, 16L, 20L, 23L, 24L, 25L, 26L, 27L, 
30L, 31L, 32L, 34L, 35L, 36L, 37L, 39L, 40L, 43L, 44L, 47L, 48L, 
50L, 52L, 54L, 55L, 57L, 59L, 60L, 62L, 64L, 65L, 67L, 69L, 75L, 
76L, 77L, 79L, 80L, 81L, 82L, 84L, 87L, 90L, 91L, 92L, 93L, 94L, 
96L, 98L, 101L, 104L, 105L, 107L, 109L, 112L, 115L, 117L, 118L, 
124L, 125L, 126L, 127L, 128L, 129L, 130L, 132L, 135L, 138L, 139L, 
145L, 147L, 150L, 151L, 153L, 154L, 155L, 156L, 157L, 158L, 161L, 
162L, 170L, 171L, 172L, 174L, 175L, 176L, 181L, 183L, 184L, 187L, 
188L, 189L, 190L, 191L, 194L, 197L, 198L, 200L, 201L, 204L, 206L, 
214L, 218L, 219L, 220L, 221L, 226L, 228L, 229L, 232L, 234L, 235L, 
236L, 239L, 240L, 241L, 243L, 244L, 245L, 248L, 249L, 250L, 251L, 
252L, 253L, 254L, 256L, 260L, 261L, 264L, 265L, 268L, 269L, 270L, 
271L, 272L, 273L, 274L, 276L, 277L, 281L, 283L, 284L, 287L, 288L, 
289L, 290L, 293L, 294L, 295L, 297L, 298L, 299L, 301L, 302L, 304L, 
306L, 309L, 313L, 314L, 318L, 320L, 321L, 322L, 329L, 330L, 334L, 
335L, 337L, 339L, 341L, 342L, 343L, 344L, 347L, 350L, 351L, 354L, 
355L, 358L, 360L, 361L, 362L, 365L, 366L, 370L, 372L, 374L, 375L, 
377L, 379L, 380L, 381L, 383L, 385L, 388L, 393L, 395L, 397L, 399L, 
401L, 402L, 405L, 406L, 408L, 409L, 410L, 411L, 412L, 413L, 417L, 
418L, 419L, 420L, 422L, 424L, 426L, 427L, 430L, 431L, 432L, 436L, 
437L, 440L, 441L, 442L, 444L, 448L, 449L, 450L, 451L, 454L, 455L, 
456L, 458L, 459L, 461L, 462L, 463L, 464L, 470L, 471L, 472L, 473L, 
474L, 475L, 476L, 480L, 481L, 482L, 484L, 485L, 486L, 488L, 491L, 
492L, 494L, 495L, 496L, 497L, 502L, 504L, 505L, 508L, 510L, 514L, 
515L, 517L, 522L, 525L, 526L, 527L, 529L, 532L, 533L, 536L, 538L, 
539L, 540L, 543L, 544L, 546L, 548L, 552L, 553L, 555L, 556L, 557L, 
563L, 564L, 565L, 566L, 569L, 576L, 578L, 579L, 580L, 581L, 583L, 
584L, 586L, 587L, 590L, 591L, 592L, 593L, 596L, 598L, 601L, 602L, 
604L, 606L, 610L, 611L, 612L, 613L, 614L, 616L, 619L, 620L, 621L, 
623L, 626L, 627L, 628L, 631L, 632L, 633L, 634L, 637L, 639L, 640L, 
643L, 644L, 645L, 646L, 647L, 649L, 652L, 654L, 658L, 660L, 661L, 
662L, 666L, 667L, 674L, 676L, 680L, 682L, 684L, 685L, 686L, 688L, 
689L, 690L, 694L, 695L, 697L, 698L, 699L, 700L, 704L, 705L, 707L, 
708L, 711L, 713L, 717L, 718L, 719L, 720L, 723L, 724L, 725L, 726L, 
730L, 732L, 733L, 735L, 738L, 740L, 743L, 744L, 745L, 747L, 748L, 
749L, 751L, 756L, 759L, 760L, 762L, 763L, 764L, 765L, 766L, 767L, 
768L, 770L, 774L, 776L, 778L, 780L, 785L, 787L, 789L, 793L, 795L, 
798L, 799L, 800L, 801L, 802L, 803L, 804L, 808L, 811L, 813L, 815L, 
816L, 817L, 819L, 822L, 824L, 825L, 826L, 827L, 829L, 832L, 833L, 
834L, 835L, 838L, 839L, 840L, 845L, 848L, 849L, 850L, 853L, 854L, 
855L, 860L, 862L, 867L, 868L, 869L, 871L, 873L, 874L, 875L, 876L, 
878L, 879L, 882L, 883L, 884L, 888L, 889L, 893L, 894L, 896L, 897L, 
898L, 900L, 901L, 904L, 905L, 906L, 907L, 908L, 909L, 912L, 913L, 
915L, 917L, 918L, 920L, 922L, 923L, 924L, 926L, 929L, 931L, 933L, 
937L, 940L, 944L, 946L, 947L, 949L, 954L, 955L, 956L, 957L, 959L, 
960L, 961L, 963L, 964L, 965L, 971L, 975L, 977L, 978L, 980L, 981L, 
982L, 983L, 985L, 987L, 990L, 991L, 992L, 995L, 996L, 999L, 1002L, 
1006L, 1007L, 1009L, 1013L, 1016L, 1017L, 1018L, 1021L, 1022L, 
1024L, 1025L, 1026L, 1027L, 1028L, 1030L, 1032L, 1033L, 1037L, 
1039L, 1040L, 1041L, 1042L, 1043L, 1044L, 1045L, 1048L, 1049L, 
1055L, 1056L, 1057L, 1067L, 1069L, 1070L, 1071L, 1072L, 1073L, 
1075L, 1076L, 1077L, 1078L, 1081L, 1082L, 1083L, 1084L, 1086L, 
1087L, 1089L, 1091L, 1092L, 1094L, 1095L, 1097L, 1098L, 1102L, 
1103L, 1104L, 1107L, 1108L, 1109L, 1110L, 1114L, 1115L, 1117L, 
1120L, 1121L, 1123L, 1126L, 1127L, 1128L, 1131L, 1133L, 1137L, 
1138L, 1142L, 1146L, 1147L, 1148L, 1151L, 1152L, 1154L, 1158L, 
1159L, 1161L, 1166L, 1167L, 1168L, 1169L, 1170L, 1174L, 1175L, 
1178L, 1179L, 1180L, 1184L, 1185L, 1187L, 1190L, 1194L, 1196L, 
1198L, 1201L, 1202L, 1203L, 1204L, 1207L, 1208L, 1210L, 1212L, 
1213L, 1214L, 1215L, 1217L, 1218L, 1220L, 1221L, 1222L, 1223L, 
1226L, 1229L, 1233L, 1238L, 1239L, 1242L, 1243L, 1244L, 1245L, 
1246L, 1248L, 1250L, 1251L, 1253L, 1254L, 1255L, 1257L, 1258L, 
1259L, 1263L, 1265L, 1267L, 1268L, 1273L, 1274L, 1275L, 1278L, 
1281L, 1282L, 1283L, 1284L, 1285L))

This is what I get when I use the code .

I am sorry for using the wrong wording (My data analysis is mostly in german so there a german words most of the time). I corrected my words in the code.
AS = association strength and Kategorie = category are my within-sibject factors. And grouped by these within

Hitrate <- data[,.(hitRate = sum(correct)/15),
by = .(subjects, Kategorie, AS)]

would like to calculate a hit rate that is calculated over these two within factors and per subject, in order to be able to calculate a mixed anova later.

Hi, it looks like your code was not formatted correctly to make it easy to read for people trying to help you.

I have gone through and made edits to this thread to correct this; but would be great if you can self-service on this in future :slight_smile:

Formatting code allows for people to more easily identify where issues may be occurring, and makes it easier to read, in general. I have edited you post to format the code properly.

In the future please put code that is inline (such as a function name, like mutate or filter) inside of backticks (`mutate`) and chunks of code (including error messages and code copied from the console) can be put between sets of three backticks:

```
example <- foo %>%
  filter(a == 1)
```

This process can be done automatically by highlighting your code, either inline or in a chunk, and clicking the </> button on the toolbar of the reply window!

This will help keep our community tidy and help you get the help you are looking for!

For more information, please take a look at the community's FAQ on formating code

1 Like

Listen to nirgrahamuk - he has good tips on making questions more understandable. You also didn't include any libraries that your code is using so I had to assume you are using data.table from your syntax

Anyway, looking at your data, one main thing I noticed is that your correct variable is actually a factor (even though it is a zero or one). This will stop any summing that you'd like to do from the start as factors can also be strings so R will not allow numeric operations on them.

If you convert using the guidance from this article you can do a sum with a group_by: r - How to convert a factor to integer\numeric without loss of information? - Stack Overflow

dplyr Approach

library(dplyr)
data2 <-
  data %>% 
 # rename(Cat =Kategorie, Assc_Str = AS) %>% for my american speaking self
  group_by(Kategorie, AS, subjects) %>% 
  summarize(hit_rate = sum(as.numeric(levels(correct))[correct])/15)

data.table Approach

library(data.table)

data1a <- data.table(data)

data2a <-
  data1a[,.(hit_rate = sum(as.numeric(levels(correct))[correct])/15)
    ,by = .(subjects, Kategorie, AS)]

Hope this helps!

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.