Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201943

Changing the format of a weird data frame

$
0
0

I have a csv file that contains a really weird table that I want to format in a proper way.

The Background: Students are able to answer questions on an online platform. The questions are labeled Test1, Test2, Test3. The three questions are presented as packs, but the order of questions is randomized. It can be Test1, Test2, Test3 or Test2, Test3, Test1 etc.

I can download the results in a csv file. If I put the results to a dataframe, it looks like this.

Original Format

What I need for an analysis of the results is the following format:

Desired Format

I was thinking about localising each occurrence of "Name" in the first column to cut the dataframe into single data frames, where each dataframe represents one student, like this:

StudentA

StudentB

For StudentB, I could just rearrange the columns, so it looks like

enter image description here

I could then remove the column descriptions of every student that is ordered as StudentB and put them back together, giving me

enter image description here

Although I am a R Beginner, im pretty confident I could find a way to do that, BUT how can I reorder StudentA?

So my first question: Which is a better way to do this? Second question: What about students that answered multiple tests?

Best regards!


Viewing all articles
Browse latest Browse all 201943

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>