Trying to filter my data

Hello,
Im really struggling with my R at the moment. I have a dataset with some amount of questions, and Im investigating the extreme answers given. In a 1-5 scale, thats 1 and 5. For that I wrote a code (Question 1 is called Q1S5):

dat[dat$Condition =='1'$Q1S5 == 1 | dat$Q1S5== 5,]$Extreme1S5 = 1
dat[dat$Condition =='1'$Q1S5 == 2 | dat$Q1S5== 3 | dat$Q1S5== 4,]$Extreme1S5 = 0

Now I want to filter using my column 'Condition' which has value 1 or 2, depending on the condition. I want to investigate condition 1.

I wrote this: dat[dat$Condition=='1',]$Q1S5 == 1 | dat$Q1S5== 5,]$Extreme1S5 = 1

But it doesn't work. I don't know how to do it, can anybody help me?

Is there a possibility to make a new dataset filtering on Condition 1?

It is not really clear to me what you are doing here. Could you provide FAQ: How to do a minimal reproducible example ( reprex ) for beginners and sample data?

A handy way to supply some sample data is the dput() function. In the case of a large dataset something like dput(head(mydata, 100)) should supply the data we need. Just do dput(mydata) where mydata is your data. Copy the output and paste it here.

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.