grouping and ordering a dataframe

I would like to group my data frame (ZIKV_red_tibble), by two separate character variables (ACC and Protein), I would then like to order the rows within each grouping by the numeric variable "POSITION". Using the code below, I keep getting the error message "Error in order(POSITION) : object 'POSITION' not found.

ZIKV_red_tibble%>%
group_by(ACC)%>%
group_by(Protein)%>%
ZIKV_red_tibble_ordered<-ZIKV_red_tibble[order(POSITION),]

arrange will by default order in ascending order, if you wish descending use arrange(desc(POSITION))

ZIKV_red_tibble%>%
group_by(ACC, Protein)%>%
arrange(POSITION)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.