0

first time poster. Thanks for your help.

I surveyed high school students, grouped by sex, using a Likert survey pre- and post-test. I have my data organized pre- and post-test, but right now it's:

     sex `1Pre` `1Post` `2Pre` `2Post` `3Pre` `3Post` `4Pre` `4Post` `5Pre` `5Post` `6Pre`
   <dbl>  <dbl>   <dbl>  <dbl>   <dbl>  <dbl>   <dbl>  <dbl>   <dbl>  <dbl>   <dbl>  <dbl>
 1     0      3       3      2       1      3       2      1       2      4       3      4
 2     0      3       2      2       2      2       2      1       1      2       3      2
 3     0      2       3      1       3      3       3      2       1      3       3      3
 4     0      3       3      2       2      2       2      1       1      3       3      3
 5     0      2       2      1       2      1       3      1       1      2       3      3

...etc., up to 12 Pre- and Post-, where I'd rather gather my columns of 1Pre and 1Post into one single variable for each respondent. Like:

Student  sex    Q1  
1         0      3
1         0      3
2         0      3
2         0      2

Am I thinking about this the wrong way? Do I make my data go from "wide" to "long"? New to R - thank you so much!

  • 1
    It's easier to help you if you include data in a [reproducible format](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) use `dput()` or the `reprex` package to make data we can copy/paste into R. But you should be able to find basic reshaping info on the duplicate. Try that and if you get suck feel free to ask a more specific question – MrFlick Feb 27 '20 at 17:31
  • I solved the problem this way: # Set data frame as wide msse_wide <- read_xls("ProcessDataMSSE.xls") colnames(msse_wide) # Displays names of columns head(msse_wide) # Set data frame as long, after running wide code above msse_long <- msse_wide %>% gather(question,obs_prepost, c(2:25)) # This pulls the columns from 2 to 25 (not including the "sex" column), test it out first as a precaution # NOW MY DATA IS TIDY!!!! :) – Tara Lepore Feb 27 '20 at 21:27

0 Answers0