0

I need to sort a data.fram by the first column (Trade Value). The properties of my data.frame are:

 str(Data_OUT) 'data.frame': 68 obs. of 9 variables: $ Trade Value : num 6 7.5 8 8.5 9 9 9.5 10 10.5 10.5 ... $ Running Back.Player Name : chr "" "" "" "" ... $ Running Back.Trend : num NA NA NA NA NA NA 0 0 NA NA ... $ Wide Receiver.Player Name: chr "Mohamed Sanu" "Marquise Brown" "Tyrell Williams" "Marvin Jones" ... $ Wide Receiver.Trend : num 0 0 0 0 0 0 0 0 0 0 ... $ Tight End.Player Name : chr "" "" "" "" ... $ Tight End.Trend : num NA NA NA NA NA NA NA NA NA NA ... $ Quarterback.Player Name : chr "" "" "" "" ... $ Quarterback.Trend : num NA NA NA NA NA NA 0 NA NA NA ... summary(Data_OUT) Trade Value Running Back.Player Name Running Back.Trend Wide Receiver.Player Name Min. : 6.00 Length:68 Min. :0 Length:68 1st Qu.:12.88 Class :character 1st Qu.:0 Class :character Median :21.25 Mode :character Median :0 Mode :character Mean :24.73 Mean :0 3rd Qu.:32.00 3rd Qu.:0 Max. :69.00 Max. :0 NA's :33 Wide Receiver.Trend Tight End.Player Name Tight End.Trend Quarterback.Player Name Min. :0 Length:68 Min. :0 Length:68 1st Qu.:0 Class :character 1st Qu.:0 Class :character Median :0 Mode :character Median :0 Mode :character Mean :0 Mean :0 3rd Qu.:0 3rd Qu.:0 Max. :0 Max. :0 NA's :32 NA's :60 Quarterback.Trend Min. :0 1st Qu.:0 Median :0 Mean :0 3rd Qu.:0 Max. :0 NA's :59 

I am trying to use this code:

Data_OUT <- Data_OUT %>% dplyr::arrange(desc('Trade Value')) 

but the result is that the table is sort ascending instead of descending.

and I have tried:

Data_OUT <- Data_OUT[order(-'Trend Value'),] 

but I get the error: "Error in -"Trend Value" : invalid argument to unary operator"

Anyone have other suggestions?

Thanks!

0

1 Answer 1

1

You can change to, be careful with the ` and '

Data_OUT <- Data_OUT %>% dplyr::arrange(desc(`Trade Value`)) 
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for that! How do I type ` rather than ' ?
If you're a Windows user, Alt + 9 + 6 would do.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.