Hi. I am having a dataset of student class performance with selected parameters. The questionnaire coding is as given in data1. The student names appear horizontally and the respective parameter scores come after that.
For example, the first student is Sinchana. Her scores is given in q_1_1, q_1_2, etc.. till q_1_11. The numbers 1-11 signify different parameters. The second students is Swati. Her scores are given in q_2_1, q_2_2, etc.. till q_2_11.
I want this data format to change and appear as given in data2. Is this possible to do?
library(tidyverse)
library(janitor)
#>
#> Attaching package: 'janitor'
#> The following objects are masked from 'package:stats':
#>
#> chisq.test, fisher.test
data1<-tibble::tribble(
~enumerator, ~en_name, ~confirm_en_name, ~tchidentrychoice, ~clusterid, ~schoolid, ~teacherid, ~cal_name1, ~cal_name2, ~cal_name3, ~cal_name4, ~cal_name5, ~cal_name6, ~cal_name7, ~cal_name8, ~cal_name9, ~cal_name10, ~q_1_1, ~q_1_2, ~q_1_3, ~q_1_4, ~q_1_5, ~q_1_6, ~q_1_7, ~q_1_8, ~q_1_9, ~q_1_10, ~q_1_11, ~q_2, ~q_2_1, ~q_2_2, ~q_2_3, ~q_2_4, ~q_2_5, ~q_2_6, ~q_2_7, ~q_2_8, ~q_2_9, ~q_2_10, ~q_2_11, ~q_3, ~q_3_1, ~q_3_2, ~q_3_3, ~q_3_4, ~q_3_5, ~q_3_6, ~q_3_7, ~q_3_8, ~q_3_9, ~q_3_10, ~q_3_11, ~q_4, ~q_4_1, ~q_4_2, ~q_4_3, ~q_4_4, ~q_4_5, ~q_4_6, ~q_4_7, ~q_4_8, ~q_4_9, ~q_4_10, ~q_4_11, ~q_5, ~q_5_1, ~q_5_2, ~q_5_3, ~q_5_4, ~q_5_5, ~q_5_6, ~q_5_7, ~q_5_8, ~q_5_9, ~q_5_10, ~q_5_11, ~q_6, ~q_6_1, ~q_6_2, ~q_6_3, ~q_6_4, ~q_6_5, ~q_6_6, ~q_6_7, ~q_6_8, ~q_6_9, ~q_6_10, ~q_6_11, ~q_7, ~q_7_1, ~q_7_2, ~q_7_3, ~q_7_4, ~q_7_5, ~q_7_6, ~q_7_7, ~q_7_8, ~q_7_9, ~q_7_10, ~q_7_11, ~q_8, ~q_8_1, ~q_8_2, ~q_8_3, ~q_8_4, ~q_8_5, ~q_8_6, ~q_8_7, ~q_8_8, ~q_8_9, ~q_8_10, ~q_8_11, ~q_9, ~q_9_1, ~q_9_2, ~q_9_3, ~q_9_4, ~q_9_5, ~q_9_6, ~q_9_7, ~q_9_8, ~q_9_9, ~q_9_10, ~q_9_11, ~q_10, ~q_10_1, ~q_10_2, ~q_10_3, ~q_10_4, ~q_10_5, ~q_10_6, ~q_10_7, ~q_10_8, ~q_10_9, ~q_10_10, ~q_10_11,
"PEN001", "Gangavva B Hiremath", 1L, 1L, "Sattapur", "ABC", "TCH1", "Sinchana Hiregoudar", "Swathi Ganiger", "Deepa Vantetin", "Chaitra Kusugalla", "Veeranna Gouda", "Basavaraj Madiwal", "Apoorva Doddamani", "Ashmita R kamble", "Ara■■■■ R kamble", "Basavaraj madivalar", 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 4L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, "7 9", 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 0L, 0L, 2L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, NA, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, NA, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 4L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, "3 8", 0L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, NA, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, NA, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L
)
data2<-tibble::tribble(
~cal_name, ~reading, ~demo, ~reprimand_phy, ~reprimand_word, ~speaking, ~discipline, ~respond, ~answer, ~writing, ~sports, ~academics,
"Sinchana Hiregoudar", 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
"Swathi Ganiger", 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
"Deepa Vantetin", 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 1L, 0L, 0L,
"Chaitra Kusugalla", 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
"Veeranna Gouda", 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
"Basavaraj Madiwal", 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
"Apoorva Doddamani", 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
"Ashmita R kamble", 0L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L,
"Ara■■■■ R kamble", 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
"Basavaraj madivalar", 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L
)
Created on 2022-06-14 by the reprex package (v2.0.1)