Re: [R] Re move row.names column in dataframe

2013-03-14 Thread PIKAL Petr
Hi

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of jeharmse
 Sent: Monday, March 11, 2013 5:28 PM
 To: r-help@r-project.org
 Subject: Re: [R] Re move row.names column in dataframe
 
  1.If your data frame is numeric, change it to matrix.
 It isn't necessarily numeric.
 
  2.Or make your own function
 I think that's the solution, but the function has to handle both NA and
 non-numeric.
 
 equal.NA - function(x,y)
 all(is.na(x)==is.na(y))  all(is.na(x) | x==y)
 
 I'm still worried that row names could bite me in some other way, and
 would prefer to be able to discard them.

As you did not include my answer I can not be 100% sure but for comparison 
purpose matrix way behaves correctly 

Regards
Petr

 
 
 
 
 --
 View this message in context: http://r.789695.n4.nabble.com/Remove-row-
 names-column-in-dataframe-tp856647p4660956.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Re move row.names column in dataframe

2013-03-12 Thread jeharmse
Thank you. This does what I want (apparently by coercing data.frame to list
with no other structure).



--
View this message in context: 
http://r.789695.n4.nabble.com/Remove-row-names-column-in-dataframe-tp856647p4661049.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Re move row.names column in dataframe

2013-03-11 Thread PIKAL Petr
Hi

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of jeharmse
 Sent: Friday, March 08, 2013 7:41 PM
 To: r-help@r-project.org
 Subject: Re: [R] Re move row.names column in dataframe
 
 
 ... the row.names will not interfere with any merging operation ...
 
 Row names do not interfere with merge, but they cause other problems.
 In the example, I want to test whether rows have the same entries (in
 some or all columns). identical fails because of the row names, and
 all( == ) can fail if there are NAs. There are ways around this, but it
 would be cleaner to be able to remove row names.
 
  df - data.frame(x=c(1,1,NA,NA), y=c(2,2,7,7))
  identical(df[1,],df[2,])
 [1] FALSE
  all(df[1,]==df[2,])
 [1] TRUE
  all(df[3,]==df[4,])
 [1] NA

I beg your pardon, whot does row names do with the above result? What do you 
expect as a result of

all(df[3,]==df[4,])

Regards
Petr

 
 
 
 
 --
 View this message in context: http://r.789695.n4.nabble.com/Remove-row-
 names-column-in-dataframe-tp856647p4660743.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Re move row.names column in dataframe

2013-03-11 Thread Jorgen Harmse
identical(df[1,],df[2,]) is FALSE because of the row names. all( == ) is just a 
work-around that I attempted.

Jorgen.

On Mar 11, 2013, at 02:53 , PIKAL Petr wrote:

 
 df - data.frame(x=c(1,1,NA,NA), y=c(2,2,7,7))
 identical(df[1,],df[2,])
 [1] FALSE
 all(df[1,]==df[2,])
 [1] TRUE
 all(df[3,]==df[4,])
 [1] NA
 
 I beg your pardon, whot does row names do with the above result? What do you 
 expect as a result of
 
 all(df[3,]==df[4,])
 
 Regards
 Petr
 


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Re move row.names column in dataframe

2013-03-11 Thread PIKAL Petr
Hi

OK, I now got the point. You have several options

1.If your data frame is numeric, change it to matrix.
m-as.matrix(df)
m
  x y
[1,]  1 2
[2,]  1 2
[3,] NA 7
[4,] NA 7
identical(m[1,],m[2,])
[1] TRUE

2.Or make your own function
nidentical- function(x,y) {
xn-as.numeric(x)
yn-as.numeric(y)
identical(xn,yn)}

nidentical(df[1,],df[2,])
[1] TRUE

which works for matrix too.

Both works also for factor variables  and the second option issues warning when 
dealing with character values. I did not tested it with other data types.
If you used as.character instead of as.numeric, the result will be probably 
same (except the warning)

Regards
Petr


From: Jorgen Harmse [mailto:jorgen.har...@civitaslearning.com]
Sent: Monday, March 11, 2013 2:08 PM
To: PIKAL Petr
Cc: r-help@r-project.org
Subject: Re: [R] Re move row.names column in dataframe

identical(df[1,],df[2,]) is FALSE because of the row names. all( == ) is just a 
work-around that I attempted.

Jorgen.

On Mar 11, 2013, at 02:53 , PIKAL Petr wrote:



df - data.frame(x=c(1,1,NA,NA), y=c(2,2,7,7))
identical(df[1,],df[2,])
[1] FALSE
all(df[1,]==df[2,])
[1] TRUE
all(df[3,]==df[4,])
[1] NA

I beg your pardon, whot does row names do with the above result? What do you 
expect as a result of

all(df[3,]==df[4,])

Regards
Petr


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Re move row.names column in dataframe

2013-03-11 Thread Peter Ehlers

On 2013-03-11 06:07, Jorgen Harmse wrote:

identical(df[1,],df[2,]) is FALSE because of the row names. all( == ) is just a 
work-around that I attempted.

Jorgen.



I would just wrap the elements in c():

 identical( c(df[1,]), c(df[2,]) )

Peter Ehlers



On Mar 11, 2013, at 02:53 , PIKAL Petr wrote:




df - data.frame(x=c(1,1,NA,NA), y=c(2,2,7,7))
identical(df[1,],df[2,])

[1] FALSE

all(df[1,]==df[2,])

[1] TRUE

all(df[3,]==df[4,])

[1] NA


I beg your pardon, whot does row names do with the above result? What do you 
expect as a result of

all(df[3,]==df[4,])

Regards
Petr




[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Re move row.names column in dataframe

2013-03-11 Thread jeharmse
 1.If your data frame is numeric, change it to matrix. 
It isn't necessarily numeric.

 2.Or make your own function 
I think that's the solution, but the function has to handle both NA and
non-numeric.

equal.NA - function(x,y)
all(is.na(x)==is.na(y))  all(is.na(x) | x==y)

I'm still worried that row names could bite me in some other way, and would
prefer to be able to discard them.




--
View this message in context: 
http://r.789695.n4.nabble.com/Remove-row-names-column-in-dataframe-tp856647p4660956.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Re move row.names column in dataframe

2013-03-08 Thread jeharmse

... the row.names will not interfere with any merging operation ...

Row names do not interfere with merge, but they cause other problems. In the
example, I want to test whether rows have the same entries (in some or all
columns). identical fails because of the row names, and all( == ) can fail
if there are NAs. There are ways around this, but it would be cleaner to be
able to remove row names.

 df - data.frame(x=c(1,1,NA,NA), y=c(2,2,7,7))
 identical(df[1,],df[2,])
[1] FALSE
 all(df[1,]==df[2,])
[1] TRUE
 all(df[3,]==df[4,])
[1] NA




--
View this message in context: 
http://r.789695.n4.nabble.com/Remove-row-names-column-in-dataframe-tp856647p4660743.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Re move row.names column in dataframe

2008-06-22 Thread tonyxv


Hello,

aa-c(1,1,2,2,3,3,4,4,5,5,6,6)
bb-c(56,56,33,33,53,53,20,20,63,63,9,9) 
cc-data.frame(aa,bb) 
uniquedf - unique(cc)
View(uniquedf)


Why does the column row.names appear in the new dataframe and how do I get
rid of it.

uniquedf$row.names - NULL does not seem to work.

For what I'm doing this is a useless column and can cause confusion and/or
problems for subsequent merging/filtering etc.


Thanks.
-- 
View this message in context: 
http://www.nabble.com/Remove-row.names-column-in-dataframe-tp18050179p18050179.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Re move row.names column in dataframe

2008-06-22 Thread Bill.Venables
- There is no column in the data frame called row.names.  It only
looks that way when you use the viewer.

- All data frames must have row and column names.  This is not
negotiable.  Also, the row.names will not interfere with any merging
operation because they are not a column of the data frame: they are the
row names.


Bill Venables
CSIRO Laboratories
mailto:[EMAIL PROTECTED]
http://www.cmis.csiro.au/bill.venables/ 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of tonyxv
Sent: Sunday, 22 June 2008 11:15 AM
To: r-help@r-project.org
Subject: [R] Re move row.names column in dataframe



Hello,

aa-c(1,1,2,2,3,3,4,4,5,5,6,6)
bb-c(56,56,33,33,53,53,20,20,63,63,9,9) 
cc-data.frame(aa,bb) 
uniquedf - unique(cc)
View(uniquedf)


Why does the column row.names appear in the new dataframe and how do I
get
rid of it.

uniquedf$row.names - NULL does not seem to work.

For what I'm doing this is a useless column and can cause confusion
and/or
problems for subsequent merging/filtering etc.


Thanks.
-- 
View this message in context:
http://www.nabble.com/Remove-row.names-column-in-dataframe-tp18050179p18
050179.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Re move row.names column in dataframe

2008-06-21 Thread Berend Hasselman



tonyxv wrote:
 
 
 Hello,
 
 aa-c(1,1,2,2,3,3,4,4,5,5,6,6)
 bb-c(56,56,33,33,53,53,20,20,63,63,9,9) 
 cc-data.frame(aa,bb) 
 uniquedf - unique(cc)
 View(uniquedf)
 
 
 Why does the column row.names appear in the new dataframe and how do I
 get rid of it.
 
 uniquedf$row.names - NULL does not seem to work.
 
 For what I'm doing this is a useless column and can cause confusion and/or
 problems for subsequent merging/filtering etc.
 
 
 Thanks.
 

There is no column row.names; there are only row names.

In R enter

?unique
?View
?row.names
?data.frame

and your questions will  be answered.

To get sequential row numbers you can do

row.names(uniquedf) - NULL


Berend
-- 
View this message in context: 
http://www.nabble.com/Remove-row.names-column-in-dataframe-tp18050179p18051448.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.