Restructuring datasets into long form using R

preview_player
Показать описание
In this video I am going to show you how to restructure a dataset into long form using R statistical software. If you are planning on analyzing a longitudinal dataset or a repeated measures design, then restructuring your dataset into long form will probably be one of the first steps you will have to take, before proceeding with actual analysis.

Below is all the R code I used in this video. Please note that angle brackets are not allowed in youtube video descriptions, so I left notes below where the angle brackets need to be inserted within the code.

# Step 1: Upload the dataset

head(Data1)

# Step 2: Restructuring dataset from rows into columns

head(Data2)

# Step 3: Rename columns

names(Data2)[c(4)] (insert angle bracket here)- c("Training_Time")

names(Data2)[c(3)] (insert angle bracket here)- c("Training_Score")

# Step 4: Recode values under Training_Time column

library(car)

# Step 5: Save dataset to csv file

### NOTE: make sure to include .csv in the above code or else it will not save as a proper csv file. I did not include this in the video. The code should look like below...

Рекомендации по теме
Комментарии
Автор

This worked for me! thanks a lot. It took me around a week to figure out but your codes did it for me in hardly anytime!

veenakamble
Автор

This video would have saved my dissertation! Only suggestion would have been to not use the “:” notation in the stack() command and instead show how to list out the stacked vectors instead (in case they aren’t ordered ideally in datasets)

jermainebecker