Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tokenized Text Word Position in Output
#3
Thanks Ting! Here is what worked for me on R:

# Break the dataframe into a list of dataframes based on 'trial_num'
df_list <- split(data, data$trial_num)

# Add row index as a column to each dataframe
df_list <- lapply(df_list, function(df) {
  df$word_position <- 1:nrow(df)
  return(df)
})

# Combine the dataframes back together
combined_df <- do.call(rbind, df_list)

# Sort the combined dataframe by 'part_number' and 'trial_num'
combined_df <- combined_df %>% arrange(part_number, trial_num)

# View the resulting dataframe
print(combined_df)
Reply


Messages In This Thread
RE: Tokenized Text Word Position in Output - by aromanir - 05-11-2023, 05:46 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)