Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LPA with Long Data #179

Open
benjaminwnelson opened this issue Apr 7, 2021 · 1 comment
Open

LPA with Long Data #179

benjaminwnelson opened this issue Apr 7, 2021 · 1 comment

Comments

@benjaminwnelson
Copy link

This is a fantastic package! Is there a way to export LPA profile classes, while keeping subject ids for long data?

@spacecadet333
Copy link

spacecadet333 commented Aug 18, 2023

This helped me. It looks like the order of your data frame and the list output of profiles remain in the same order. If you add a sequential ID column, you can join after LPA is conducted:

#add sequential number column to data frame
data<- data
numr_rows= nrow(data)
data$seqID<- seq.int(numr_rows)

#run LPA
LPA<- data %>%
 select(c(X1, X2, X3)) %>%
 single_imputation() %>%
 estimate_profiles(3) 

#add sequential ID to Model classification and convert to data frame
data.with.class<- LPA$model_1_class_3$model$classification%>%as.data.frame()
data.with.class$seqID<- seq.int(nrow(data.with.class)) 

#use left_join function to join based on sequential ID
data.join<- left_join(data, data.with.class, by= "seqID")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants