Xiangwu
Xiangwu

Reputation: 745

R, is it possible to read a CSV file from the end row the beginning row?

When I read in a CSV file to draw a plot, is it possible to read the CSV data in the order from bottom to up?

Position, value
1,    90
2,    88
3,    34
4,    45
5,    45
6,    89
7,    53
......

The order I want the CSV to be read in:

......
7,    53
6,    89
5,    45
4,    45
3,    34
2,    88
1,    90

My real data sheet would have thousands rows.

Upvotes: 1

Views: 1703

Answers (1)

Dominic Comtois
Dominic Comtois

Reputation: 10431

Unless you have really specific reasons to really read from the bottom, you can always sort after reading it the usual way... e.g.

my.data <- read.csv(...)
my.data <- my.data[nrow(my.data):1,]

Upvotes: 4

Related Questions