Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9149259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:27:10+00:00 2026-06-17T11:27:10+00:00

I have a data frame that looks like this: > head(Data1A) Prime Target CorrectAnswer

  • 0

I have a data frame that looks like this:

> head(Data1A)
        Prime Target CorrectAnswer Accuracy   RT   Block TrialType
1     bezaaid barkme    PseudoWord        1 3450 Block 1        NA
2       hazen lemmet          Word        1 1108 Block 1        NA
3  bergtoppen slavin          Word        1 1160 Block 1        NA
4       wekte gareel          Word        1 1250 Block 1        NA
5      zessen studio          Word        1  557 Block 1        NA
6 nauwkeurige hotens    PseudoWord        1  882 Block 1        NA

As you can see, the column TrialType has to be filled, and I need a conditional statement to do it. I know what I want and I wrote in down in pseudocode as best as I could, but I am light years away of being able to implement this in the right syntax. Any help is much appreciated.

The Pseudocode:

For each cell in Data1A$TrialType if the corresponding cell in Data1A$Block is equal to Block 2 or Block 3 and the corresponding row in Data1A$CorrectAnswer is equal to Word OR if the corresponding cell in Data1A$Block is equal to “Block 4” or “Block 5” and the corresponding cell in Data1A$CorrectAnswer is equal to PseudoWord then the corresponding cell in TrialType will be equal to Regular else if the corresponding cell in Data1A$Block is equal to Block 1 or Block 6 OR if the corresponding cell in Data1A$Block is equal to Block 2 or Block3 and the corresponding row in Data1A$CorrectAnswer is equal to pseudoWord OR if the corresponding cell in Data1A$Block is equal to Block 4 or Block 5 and the corresponding cell in Data1A$CorrectAnswer is equal to Word then the corresponding cell in Data1A$TrialType is equal to Random

I hope this is understandable. I will be checking in case there are doubts regarding my intentions with the pseudocode.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T11:27:11+00:00Added an answer on June 17, 2026 at 11:27 am

    I really get a headeach to simplify your logic here.

    But This should work.

    I generate some data

    dat <- read.table(text =        "Prime Target CorrectAnswer Accuracy   RT   Block TrialType
                      1     bezaaid barkme    PseudoWord        1 3450 'Block 4'        NA
                      2       hazen lemmet          Word        1 1108 'Block 5'        NA
                      3  bergtoppen slavin          Word        1 1160 'Block 4'        NA
                      1     bezaaid barkme    PseudoWord        1 3450 'Block 5'        NA
                      2       hazen lemmet          Word        1 1108 'Block 2'        NA
                      3  bergtoppen slavin          Word        1 1160 'Block 3'        NA
                      1     bezaaid barkme    PseudoWord        1 3450 'Block 2'        NA
                      2       hazen lemmet          Word        1 1108 'Block 3'        NA
                      3  bergtoppen slavin          Word        1 1160 'Block 1'        NA
                      4       wekte gareel          Word        1 1250 'Block 6'        NA
                      5      zessen studio          Word        1  557 'Block 1'        NA
                      6 nauwkeurige hotens    PseudoWord        1  882 'Block 3'        NA",header = T,row.names = NULL)
    

    Then I implement your logic:

    transform(dat,
              TrialType= ifelse(Block %in% c('Block 4','Block 5'),
                                ifelse(CorrectAnswer =="Word" ,"Random","Regular"),
                                ifelse(Block  %in% c('Block 2','Block 3'),
                                       ifelse(CorrectAnswer =="Word" ,"Regular","Random"),
                                       'Random')))
    

    Here the result

      row.names       Prime Target CorrectAnswer Accuracy   RT   Block TrialType
    1          1     bezaaid barkme    PseudoWord        1 3450 Block 4   Regular
    2          2       hazen lemmet          Word        1 1108 Block 5    Random
    3          3  bergtoppen slavin          Word        1 1160 Block 4    Random
    4          1     bezaaid barkme    PseudoWord        1 3450 Block 5   Regular
    5          2       hazen lemmet          Word        1 1108 Block 2   Regular
    6          3  bergtoppen slavin          Word        1 1160 Block 3   Regular
    7          1     bezaaid barkme    PseudoWord        1 3450 Block 2    Random
    8          2       hazen lemmet          Word        1 1108 Block 3   Regular
    9          3  bergtoppen slavin          Word        1 1160 Block 1    Random
    10         4       wekte gareel          Word        1 1250 Block 6    Random
    11         5      zessen studio          Word        1  557 Block 1    Random
    12         6 nauwkeurige hotens    PseudoWord        1  882 Block 3    Random
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data.frame that looks like this: > head(ff.df) .id pio caremgmt prev
I have a data.frame that looks like this > head(df) Memory Memory Memory Memory
I have a semi-melted data frame that looks like this: head(final_melt) Group Source variable
I have a data.frame named pp that looks like this: > head(pp) X02R X03N
I have a data.frame in R that looks like this: score rms template aln_id
I have a data frame in R that looks like this: > TimeOffset, Source,
I have a data frame that looks like this: Chr start stop ref alt
I'm in a situation like this: I have a data.frame that looks like the
I have a data frame that looks like this: user1,product1,0 user1,product2,2 user1,product3,1 user1,product4,2 user2,product3,0
I have a ROC.Value data frame that looks like this: Years 1 2 3

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.