altering identity column
On Apr 18, 2011, at 9:02 AM, Bodnar Laszlo EB_HU wrote:
Hi there, I have a huge dataframe containing 70,000 observations. I have filtered this dataframe (let it's name be "transformed_dataframe") as I wanted to select only those observations which are greater than or equal to 60,001 regarding the very first identity column.
I am guessing that what you want is something like dfrm2 <- transformed_dataframe[rownames(transformed_dataframe) >= "60001" , ] Or perhaps (if you carrying the thousands separator into the rownames: dfrm2 <- transformed_dataframe[rownames(transformed_dataframe) >= "60,001" , ] Or if you are using spaces then: dfrm2 <- transformed_dataframe[rownames(transformed_dataframe) >= "60 001" , ] This would involve much less guessing if you offered the results of: str(transformed_dataframe)
So I have a transformed dataframe now including 10,000 obeservations
(from 60,001 - to 70,000) and if you send
"head(transformed_dataframe)" into R it looks like this:
variable1 variable2
variable3 variable4 ...
60
001
... ... ... ...
60
002
... ... ... ...
60
003
... ... ... ...
60
004
... ... ... ...
60
005
... ... ... ...
Sending "tail(transformed_dataframe)" into R it is going to be
something like:
variable1 variable2
variable3 variable4 ...
69
996
... ... ... ...
69
997
... ... ... ...
69
998
... ... ... ...
69
999
... ... ... ...
70
000
... ... ... ...
Now is there a quick way to alter this indexing of rows in case of
my "transformed_dataframe"? I mean, I would like to get indices 1,
2, 3, etc... instead of 60 001, 60 002, 60 003 etc...
rownames(transformed_dataframe) <- 1:10000
So by sending "head(transformed_dataframe)" and
"tail(transformed_dataframe)" I would like to see:
variable1 variable2
variable3 variable4 ...
1
... ... ... ...
2
... ... ... ...
3
... ... ... ...
4
... ... ... ...
5
... ... ... ...
and
variable1 variable2
variable3 variable4 ...
9
996
... ... ... ...
9
997
... ... ... ...
9
998
... ... ... ...
9
999
... ... ... ...
10
000
... ... ... ...
Thank you very much, best regards,
Laszlo
______________________________________________________________________________________________
David Winsemius, MD West Hartford, CT