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 385777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:30:46+00:00 2026-05-12T15:30:46+00:00

The function below works perfectly for my purpose. The display is wonderful. Now my

  • 0

The function below works perfectly for my purpose. The display is wonderful. Now my problem is I need to be able to do it again, many times, on other variables that fit other patterns.

In this example, I’ve output results for “q4a”, I would like to be able to do it for sequences of questions that follow patterns like: q4 < a – z > or q < 4 – 10 >< a – z >, automagically.

Is there some way to iterate this such that the specified variable (in this case q4a) changes each time?

Here’s my function:

require(reshape) # Using it for melt
require(foreign) # Using it for read.spss

d1 <- read.spss(...) ## Read in SPSS file

attach(d1,warn.conflicts=F) ## Attach SPSS data

q4a_08 <- d1[,grep("q4a_",colnames(d1))] ## Pull in everything matching q4a_X
q4a_08 <- melt(q4a_08) ## restructure data for post-hoc

detach(d1)

q4aaov <- aov(formula=value~variable,data=q4a) ## anova

Thanks in advance!

  • 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-05-12T15:30:46+00:00Added an answer on May 12, 2026 at 3:30 pm

    Not sure if this is what you are looking for, but to generate the list of questions:

    > gsub('^', 'q', gsub(' ', '', 
        apply(expand.grid(1:10,letters),1,
               function(r) paste(r, sep='', collapse='')
             )))
      [1] "q1a"  "q2a"  "q3a"  "q4a"  "q5a"  "q6a"  "q7a"  "q8a"  "q9a"  "q10a"
     [11] "q1b"  "q2b"  "q3b"  "q4b"  "q5b"  "q6b"  "q7b"  "q8b"  "q9b"  "q10b"
     [21] "q1c"  "q2c"  "q3c"  "q4c"  "q5c"  "q6c"  "q7c"  "q8c"  "q9c"  "q10c"
     [31] "q1d"  "q2d"  "q3d"  "q4d"  "q5d"  "q6d"  "q7d"  "q8d"  "q9d"  "q10d"
     [41] "q1e"  "q2e"  "q3e"  "q4e"  "q5e"  "q6e"  "q7e"  "q8e"  "q9e"  "q10e"
     [51] "q1f"  "q2f"  "q3f"  "q4f"  "q5f"  "q6f"  "q7f"  "q8f"  "q9f"  "q10f"
     [61] "q1g"  "q2g"  "q3g"  "q4g"  "q5g"  "q6g"  "q7g"  "q8g"  "q9g"  "q10g"
     [71] "q1h"  "q2h"  "q3h"  "q4h"  "q5h"  "q6h"  "q7h"  "q8h"  "q9h"  "q10h"
     [81] "q1i"  "q2i"  "q3i"  "q4i"  "q5i"  "q6i"  "q7i"  "q8i"  "q9i"  "q10i"
     [91] "q1j"  "q2j"  "q3j"  "q4j"  "q5j"  "q6j"  "q7j"  "q8j"  "q9j"  "q10j"
     ...
    

    And then you turn your inner part of the analysis into a function that takes the question prefix as a parameter:

    analyzeQuestion <- function (prefix)
    {
      q <- d1[,grep(prefix,colnames(d1))] ## Pull in everything matching q4a_X
      q <- melt(q) ## restructure data for post-hoc
    
      qaaov <- aov(formula=value~variable,data=q4a) ## anova
      return (LTukey(q4aaov,which="",conf.level=0.95)) ## Tukey's post-hoc
    }
    

    Now – I’m not sure where your ‘q4a’ variable is coming from (as used in the aov(..., data=q4a)– so not sure what to do about that bit. But hopefully this helps.

    To put the two together you can use sapply() to apply the analyzeQuestion function to each of the prefixes that we automagically generated.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function below which works perfectly, but now the client came back
I'm making table rows click-able with jQuery's $.live() function. Works perfectly on Chrome, Firefox
The function below was used in two .php documents. This code works perfectly in
I am testing this simple code below and it works... $(document).ready( function() { $('.show-modal').click(
The following method below works perfectly if $output is a string. Although in a
I am having a problem turning the function below into a plugin, could you
My code below works in firefox perfectly..but not in Safari. When I use the
The following script below is not running in IE7 but works perfectly fine in
The code below will show / hide a div on click. It works perfectly
I'm calling setNeedsDisplayInRect from an NSTimer function every two seconds. This works perfectly, and

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.