LAMP Consortium

LAMP Data Processing Code Issues

Hi! I was trying to access the passive data measures via R and ran into some issues with the code:

data_list <- list()
for (i in 1:length(participants)) {
  tmp <- lamp$ActivityEvent$allByParticipant(participants[i])
  if (length(tmp) > 0) { # Some are null, some are empty lists
    tmp <- right_join(activity_map %>% dplyr::select(activity, name), 
                      jsonlite::flatten(tmp) %>% 
                        mutate(timestamp = anytime(as.numeric(timestamp)/1000, tz = "America/New_York")) %>% # Converting times from unix time stamp to YYYY-MM-DD
                        rename(activity_duration = duration) %>% 
                        mutate(id = participants[i]),
                      by="activity")
    tmp_event_list <- list()
    
    # This is a workaround for survey items being too nested
    for (j in 1:nrow(tmp)) {
      if (length(tmp[j,]$temporal_slices[[1]]) > 0) {
        tmp_event_list[[j]] <- cbind(tmp[j,], tmp[j,]$temporal_slices[[1]]) %>% dplyr::select(-temporal_slices)
      }
    }
    data_list[[i]] <- rbindlist(tmp_event_list, fill = T)
  }
}

The output was a never-ending block of :

row names were found from a short variable and have been discardedrow names were found from a short variable and have been discardedrow names were found from a short variable and have been discardedrow names were found from a short variable and have been discardedrow names were found from a short variable and have been discardedrow names were found from a short variable and have been discardedrow names were found from a short variable and have been discardedrow names were found from a short variable and have been discardedrow names were found from a short variable and have been discarded

If anyone could help me troubleshoot I would be very grateful! TIA

That is just a warning that shouldn’t affect the output or stop the code from running, but you can replace the offending line with this code:

tmp_event_list[[j]] <- cbind(tmp[j,], tmp[j,]$temporal_slices[[1]]) %>% dplyr::select(-temporal_slices, row.names = NULL)

Let me know if that doesn’t work or if any other questions come up!

Thank you!!