tidyr

How do I summarize data that is broken into many columns?

时光怂恿深爱的人放手 提交于 2020-08-26 07:17:30
问题 I have a data set that contains answers to a "select as many as apply" question with each possible answer in separate columns. So, assuming our question is "What color shirt is acceptable to you?" it looks something like this: id Q3_Red Q3_Blue Q3_Green Q3_Purple 9 8 Green Purple 7 Green 6 Red 5 Purple 4 Blue 3 Blue Purple 2 Red Blue Green 1 Red Purple 10 Red Purple Which you can make into an actual data frame with: tmp <- data.frame("id" = c(009,008,007,006,005,004,003,002,001,010), "Q3_Red"

Write an efficient loop to compare gps coordinates

China☆狼群 提交于 2020-08-08 07:11:11
问题 I want to go through a dataframe of GPS coordinates and remove all coordinates that are to close to each other. pick first row clalulate the distance between selected and the next row if the distance is < mindist and current row is not the last row continue to next row else select the current row (leave it in dataframe) and if the selected row is not the last row repeat from the begining The result should be a dataframe with gps points that are at least mindist away from each other One