Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rbind in R gives a weird rowname

Tags:

dataframe

r

I have the following dataframes tt1

> tt1[2,]
        date  close emp pred
2 1982-03-24 112.97  -1    1

and dataframe tt2

> tt2[2,]
        date  close emp pred
2 1982-03-25 113.21   1    1

when I try to use rbind() I get weird row name for the 2nd row.

> rbind(tt1[2,],tt2[2,])
         date  close emp pred
2  1982-03-24 112.97  -1    1
21 1982-03-25 113.21   1    1

any clue has to how to get rid of that have it as 1, 2

like image 570
babu Avatar asked Apr 02 '11 15:04

babu


People also ask

Is Rbind slow in R?

The function rbind() is slow, particularly as the data frame gets bigger. You should never use it in a loop. The right way to do it is to initialize the output object at its final size right from the start and then simply fill it in with each turn of the loop.

Does Rbind remove duplicates?

Note that this does not remove duplicate rows across the two DataFrames. Returns a new DataFrame containing rows of all parameters.

What does row names false mean in R?

The default (is back compatible), FALSE , will signal an error, where NA will “automatic” row names and TRUE will call make. names(value, unique=TRUE) for constructing valid names.


1 Answers

Try

rownames(mydataframe) <- NULL

See the documentation (type ?rownames on the prompt) for more info.

like image 128
Martin Avatar answered Oct 23 '22 04:10

Martin