Re: [R] "invalid argument to unary operator" while selecting rows by name

2016-09-22 Thread ruipbarradas

Hello,

data["601",] doesn't generate an error because you can also refer to a  
row by its name, as an alternative to refering to it by row number.  
It's the same with vectors, just consider the following case.


(x <- c("601"=1, b=2))
x[1]
x["601"]  # the same

But when you want to remove it you must negate an index number so  
x[-"601"] is wrong for reasons already explained.


Rui Barradas


Citando Pauline Laïlle :


Hi, thanks for the answer.
In this case, the row named "601" is not the 601st row of the table, but
the 117th. data[601,] actually refers to a non existing row.
I was wondering why data[-"601,] generates an error message whereas
data["601",] does not?

2016-09-20 19:08 GMT+02:00 Bert Gunter :


Hint: "601"  is not 601.

Have you gone through any R tutorials?

Cheers,
Bert
Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Tue, Sep 20, 2016 at 5:42 AM, Pauline Laïlle
 wrote:
> Dear all,
>
> I built a dataframe with read.csv2(). Initially, row names are integers
> (order of answers to a survey). They are listed in the csv's first
column.
> The import works well and my dataframe looks like I wanted it to look.
>
> Row names go as follows :
>  [1] "6"   "29"  "31"  "32"  "52"  "55"  "63"  "71"  "72"  "80"  "88"
"89"
>  "91"  "93"  "105" "110" "111" "117" "119" "120"
>  [21] "122" "127" "128" "133" "137" "140" "163" "165" "167" "169" "177"
> "178" "179" "184" "186" "192" "193" "200" "201" "228"
> etc.
>
> I would like to drop rows "601" & "604" to clean the dataframe.
>
> While data["601",] shows me the first row i'd like to drop, data[-"601",]
> returns the following :
> Error in -"601" : invalid argument to unary operator
>
> idem with data[c("601","604"),] and data[-c("601","604"),]
>
> It is the first time that I run into this specific error. After reading a
> bit about it I still don't understand what it means and how to fix it.
>
> Thanks for reading!
> Best,
> Pauline.
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.



[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 -- To UNSUBSCRIBE and more, see
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] "invalid argument to unary operator" while selecting rows by name

2016-09-22 Thread Pauline Laïlle
Tanks for all your answers and for taking the time to help me better
understand my mistake.
I will take your advice and do some reading!
Best,
P.

Le mercredi 21 septembre 2016, William Dunlap  a écrit :

> The OP cannot be entirely blamed for thinking that x[,-"ColName"]
> would omit x's "ColName" from the result.  Base R and many packages
> have commonly used functions that do context-sensitive (aka 'nonstandard')
> evaluation.
>
> E.g. subset() evaluates each argument in a different way:
>   > subset(data.frame(ColA=1:3,ColB=-(11:13)), -ColB>11, -ColA)
> ColB
>   2  -12
>   3  -13
>
>
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
>
> On Wed, Sep 21, 2016 at 7:45 AM, Bert Gunter  > wrote:
>
>> No, Rui, your example misses the point. Your initial sentence hits it.
>>
>> The OP needs to carefully read
>> ?"["
>> and/or spend some time with a suitable R tutorial to learn proper
>> syntax for subscripting. Asking foolish questions in lieu of doing her
>> homework seems wrongheaded to me. Others may disagree, of course.
>>
>> Cheers,
>> Bert
>>
>>
>>
>>
>> Cheers,
>> Bert
>> Bert Gunter
>>
>> "The trouble with having an open mind is that people keep coming along
>> and sticking things into it."
>> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>>
>>
>> On Wed, Sep 21, 2016 at 1:26 AM,  > > wrote:
>> > Hello,
>> >
>> > The error message means exactly what it says. The operator '-' is
>> > unary and cannot be followed by a non-numeric atomic object (a vector).
>> > Try for instance
>> >
>> > x <- list(a=1:10, b=rnorm(5))
>> > -x
>> >
>> > Rui Barradas
>> >
>> >
>> > Citando Pauline Laïlle > >:
>> >
>> >> Works like a charm, thanks! Still don't know what that error message
>> >> means though. Any idea?
>> >>
>> >>   2016-09-20 20:13 GMT+02:00 > >:
>> >>> Sorry, I've made a stupid mistake.
>> >>> It's obviously the other way around.
>> >>>
>> >>> ix <- which(rownames(data) %in% c("601", "604"))
>> >>> clean <- data[-ix, ]
>> >>>
>> >>> Rui Barradas
>> >>>
>> >>> Citando ruipbarra...@sapo.pt
>> :
>>  Hello,
>> 
>>  Try something like the following.
>> 
>>  ix <- which(c("601", "604") %in% rownames(data))
>>  clean <- data[-ix, ]
>> 
>>  Hope this helps,
>> 
>>  Rui Barradas
>> 
>>  Citando Pauline Laïlle > >:
>> 
>> > Dear all,
>> >
>> > I built a dataframe with read.csv2(). Initially, row names are
>> integers
>> > (order of answers to a survey). They are listed in the csv's first
>> column.
>> > The import works well and my dataframe looks like I wanted it to
>> look.
>> >
>> > Row names go as follows :
>> > [1] "6"   "29"  "31"  "32"  "52"  "55"  "63"  "71"  "72"  "80"
>> "88"  "89"
>> > "91"  "93"  "105" "110" "111" "117" "119" "120"
>> > [21] "122" "127" "128" "133" "137" "140" "163" "165" "167" "169"
>> "177"
>> > "178" "179" "184" "186" "192" "193" "200" "201" "228"
>> > etc.
>> >
>> > I would like to drop rows "601" & "604" to clean the dataframe.
>> >
>> > While data["601",] shows me the first row i'd like to drop,
>> data[-"601",]
>> > returns the following :
>> > Error in -"601" : invalid argument to unary operator
>> >
>> > idem with data[c("601","604"),] and data[-c("601","604"),]
>> >
>> > It is the first time that I run into this specific error. After
>> reading a
>> > bit about it I still don't understand what it means and how to fix
>> it.
>> >
>> > Thanks for reading!
>> > Best,
>> > Pauline.
>> >
>> > [[alternative HTML version deleted]]
>> >
>> > __
>> > R-help@r-project.org
>>  mailing list --
>> To UNSUBSCRIBE and more, see
>> > 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 --
>> To UNSUBSCRIBE and more, see
>>  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.
>> >>>
>> >>>
>> >
>> >
>> >
>> > [[alternative 

Re: [R] "invalid argument to unary operator" while selecting rows by name

2016-09-22 Thread Pauline Laïlle
Works like a charm, thanks!
Still don't know what that error message means though. Any idea?

2016-09-20 20:13 GMT+02:00 :

> Sorry, I've made a stupid mistake.
> It's obviously the other way around.
>
> ix <- which(rownames(data) %in% c("601", "604"))
> clean <- data[-ix, ]
>
>
> Rui Barradas
>
>
> Citando ruipbarra...@sapo.pt:
>
>
> Hello,
>>
>> Try something like the following.
>>
>> ix <- which(c("601", "604") %in% rownames(data))
>> clean <- data[-ix, ]
>>
>>
>> Hope this helps,
>>
>> Rui Barradas
>>
>>
>>
>>
>> Citando Pauline Laïlle :
>>
>> Dear all,
>>>
>>> I built a dataframe with read.csv2(). Initially, row names are integers
>>> (order of answers to a survey). They are listed in the csv's first
>>> column.
>>> The import works well and my dataframe looks like I wanted it to look.
>>>
>>> Row names go as follows :
>>> [1] "6"   "29"  "31"  "32"  "52"  "55"  "63"  "71"  "72"  "80"  "88"
>>> "89"
>>> "91"  "93"  "105" "110" "111" "117" "119" "120"
>>> [21] "122" "127" "128" "133" "137" "140" "163" "165" "167" "169" "177"
>>> "178" "179" "184" "186" "192" "193" "200" "201" "228"
>>> etc.
>>>
>>> I would like to drop rows "601" & "604" to clean the dataframe.
>>>
>>> While data["601",] shows me the first row i'd like to drop, data[-"601",]
>>> returns the following :
>>> Error in -"601" : invalid argument to unary operator
>>>
>>> idem with data[c("601","604"),] and data[-c("601","604"),]
>>>
>>> It is the first time that I run into this specific error. After reading a
>>> bit about it I still don't understand what it means and how to fix it.
>>>
>>> Thanks for reading!
>>> Best,
>>> Pauline.
>>>
>>> [[alternative HTML version deleted]]
>>>
>>> __
>>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide http://www.R-project.org/posti
>>> ng-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posti
>> ng-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>
>
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] "invalid argument to unary operator" while selecting rows by name

2016-09-22 Thread Pauline Laïlle
Hi, thanks for the answer.
In this case, the row named "601" is not the 601st row of the table, but
the 117th. data[601,] actually refers to a non existing row.
I was wondering why data[-"601,] generates an error message whereas
data["601",] does not?

2016-09-20 19:08 GMT+02:00 Bert Gunter :

> Hint: "601"  is not 601.
>
> Have you gone through any R tutorials?
>
> Cheers,
> Bert
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along
> and sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
> On Tue, Sep 20, 2016 at 5:42 AM, Pauline Laïlle
>  wrote:
> > Dear all,
> >
> > I built a dataframe with read.csv2(). Initially, row names are integers
> > (order of answers to a survey). They are listed in the csv's first
> column.
> > The import works well and my dataframe looks like I wanted it to look.
> >
> > Row names go as follows :
> >  [1] "6"   "29"  "31"  "32"  "52"  "55"  "63"  "71"  "72"  "80"  "88"
> "89"
> >  "91"  "93"  "105" "110" "111" "117" "119" "120"
> >  [21] "122" "127" "128" "133" "137" "140" "163" "165" "167" "169" "177"
> > "178" "179" "184" "186" "192" "193" "200" "201" "228"
> > etc.
> >
> > I would like to drop rows "601" & "604" to clean the dataframe.
> >
> > While data["601",] shows me the first row i'd like to drop, data[-"601",]
> > returns the following :
> > Error in -"601" : invalid argument to unary operator
> >
> > idem with data[c("601","604"),] and data[-c("601","604"),]
> >
> > It is the first time that I run into this specific error. After reading a
> > bit about it I still don't understand what it means and how to fix it.
> >
> > Thanks for reading!
> > Best,
> > Pauline.
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > 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.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] "invalid argument to unary operator" while selecting rows by name

2016-09-21 Thread William Dunlap via R-help
The OP cannot be entirely blamed for thinking that x[,-"ColName"]
would omit x's "ColName" from the result.  Base R and many packages
have commonly used functions that do context-sensitive (aka 'nonstandard')
evaluation.

E.g. subset() evaluates each argument in a different way:
  > subset(data.frame(ColA=1:3,ColB=-(11:13)), -ColB>11, -ColA)
ColB
  2  -12
  3  -13



Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Wed, Sep 21, 2016 at 7:45 AM, Bert Gunter  wrote:

> No, Rui, your example misses the point. Your initial sentence hits it.
>
> The OP needs to carefully read
> ?"["
> and/or spend some time with a suitable R tutorial to learn proper
> syntax for subscripting. Asking foolish questions in lieu of doing her
> homework seems wrongheaded to me. Others may disagree, of course.
>
> Cheers,
> Bert
>
>
>
>
> Cheers,
> Bert
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along
> and sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
> On Wed, Sep 21, 2016 at 1:26 AM,   wrote:
> > Hello,
> >
> > The error message means exactly what it says. The operator '-' is
> > unary and cannot be followed by a non-numeric atomic object (a vector).
> > Try for instance
> >
> > x <- list(a=1:10, b=rnorm(5))
> > -x
> >
> > Rui Barradas
> >
> >
> > Citando Pauline Laïlle :
> >
> >> Works like a charm, thanks! Still don't know what that error message
> >> means though. Any idea?
> >>
> >>   2016-09-20 20:13 GMT+02:00 :
> >>> Sorry, I've made a stupid mistake.
> >>> It's obviously the other way around.
> >>>
> >>> ix <- which(rownames(data) %in% c("601", "604"))
> >>> clean <- data[-ix, ]
> >>>
> >>> Rui Barradas
> >>>
> >>> Citando ruipbarra...@sapo.pt:
>  Hello,
> 
>  Try something like the following.
> 
>  ix <- which(c("601", "604") %in% rownames(data))
>  clean <- data[-ix, ]
> 
>  Hope this helps,
> 
>  Rui Barradas
> 
>  Citando Pauline Laïlle :
> 
> > Dear all,
> >
> > I built a dataframe with read.csv2(). Initially, row names are
> integers
> > (order of answers to a survey). They are listed in the csv's first
> column.
> > The import works well and my dataframe looks like I wanted it to
> look.
> >
> > Row names go as follows :
> > [1] "6"   "29"  "31"  "32"  "52"  "55"  "63"  "71"  "72"  "80"
> "88"  "89"
> > "91"  "93"  "105" "110" "111" "117" "119" "120"
> > [21] "122" "127" "128" "133" "137" "140" "163" "165" "167" "169"
> "177"
> > "178" "179" "184" "186" "192" "193" "200" "201" "228"
> > etc.
> >
> > I would like to drop rows "601" & "604" to clean the dataframe.
> >
> > While data["601",] shows me the first row i'd like to drop,
> data[-"601",]
> > returns the following :
> > Error in -"601" : invalid argument to unary operator
> >
> > idem with data[c("601","604"),] and data[-c("601","604"),]
> >
> > It is the first time that I run into this specific error. After
> reading a
> > bit about it I still don't understand what it means and how to fix
> it.
> >
> > Thanks for reading!
> > Best,
> > Pauline.
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > 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 -- To UNSUBSCRIBE and more, see
>  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.
> >>>
> >>>
> >
> >
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > 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 -- To UNSUBSCRIBE and more, see
> 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.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see

Re: [R] "invalid argument to unary operator" while selecting rows by name

2016-09-21 Thread Bert Gunter
No, Rui, your example misses the point. Your initial sentence hits it.

The OP needs to carefully read
?"["
and/or spend some time with a suitable R tutorial to learn proper
syntax for subscripting. Asking foolish questions in lieu of doing her
homework seems wrongheaded to me. Others may disagree, of course.

Cheers,
Bert




Cheers,
Bert
Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Wed, Sep 21, 2016 at 1:26 AM,   wrote:
> Hello,
>
> The error message means exactly what it says. The operator '-' is
> unary and cannot be followed by a non-numeric atomic object (a vector).
> Try for instance
>
> x <- list(a=1:10, b=rnorm(5))
> -x
>
> Rui Barradas
>
>
> Citando Pauline Laïlle :
>
>> Works like a charm, thanks! Still don't know what that error message
>> means though. Any idea?
>>
>>   2016-09-20 20:13 GMT+02:00 :
>>> Sorry, I've made a stupid mistake.
>>> It's obviously the other way around.
>>>
>>> ix <- which(rownames(data) %in% c("601", "604"))
>>> clean <- data[-ix, ]
>>>
>>> Rui Barradas
>>>
>>> Citando ruipbarra...@sapo.pt:
 Hello,

 Try something like the following.

 ix <- which(c("601", "604") %in% rownames(data))
 clean <- data[-ix, ]

 Hope this helps,

 Rui Barradas

 Citando Pauline Laïlle :

> Dear all,
>
> I built a dataframe with read.csv2(). Initially, row names are integers
> (order of answers to a survey). They are listed in the csv's first column.
> The import works well and my dataframe looks like I wanted it to look.
>
> Row names go as follows :
> [1] "6"   "29"  "31"  "32"  "52"  "55"  "63"  "71"  "72"  "80"  "88"  "89"
> "91"  "93"  "105" "110" "111" "117" "119" "120"
> [21] "122" "127" "128" "133" "137" "140" "163" "165" "167" "169" "177"
> "178" "179" "184" "186" "192" "193" "200" "201" "228"
> etc.
>
> I would like to drop rows "601" & "604" to clean the dataframe.
>
> While data["601",] shows me the first row i'd like to drop, data[-"601",]
> returns the following :
> Error in -"601" : invalid argument to unary operator
>
> idem with data[c("601","604"),] and data[-c("601","604"),]
>
> It is the first time that I run into this specific error. After reading a
> bit about it I still don't understand what it means and how to fix it.
>
> Thanks for reading!
> Best,
> Pauline.
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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 -- To UNSUBSCRIBE and more, see
 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.
>>>
>>>
>
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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 -- To UNSUBSCRIBE and more, see
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] "invalid argument to unary operator" while selecting rows by name

2016-09-21 Thread S Ellison
> > Works like a charm, thanks! Still don't know what that error message
> > means though. Any idea?

You tried to negate a character string.
-"601"

'-' can't do that.

[-x] relies on negative _numbers_ to remove elements, not on separate 
interpretation of '-' and 'x'.



S Ellison


***
This email and any attachments are confidential. Any use, copying or
disclosure other than by the intended recipient is unauthorised. If 
you have received this message in error, please notify the sender 
immediately via +44(0)20 8943 7000 or notify postmas...@lgcgroup.com 
and delete this message and any copies from your computer and network. 
LGC Limited. Registered in England 2991879. 
Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] "invalid argument to unary operator" while selecting rows by name

2016-09-21 Thread ruipbarradas
Hello,

The error message means exactly what it says. The operator '-' is  
unary and cannot be followed by a non-numeric atomic object (a vector).
Try for instance

x <- list(a=1:10, b=rnorm(5))
-x

Rui Barradas
 

Citando Pauline Laïlle :

> Works like a charm, thanks! Still don't know what that error message  
> means though. Any idea?
>
>   2016-09-20 20:13 GMT+02:00 :
>> Sorry, I've made a stupid mistake.
>> It's obviously the other way around.
>>
>> ix <- which(rownames(data) %in% c("601", "604"))
>> clean <- data[-ix, ]
>>
>> Rui Barradas
>>
>> Citando ruipbarra...@sapo.pt:   
>>> Hello,
>>>
>>> Try something like the following.
>>>
>>> ix <- which(c("601", "604") %in% rownames(data))
>>> clean <- data[-ix, ]
>>>
>>> Hope this helps,
>>>
>>> Rui Barradas
>>>
>>> Citando Pauline Laïlle :
>>>  
 Dear all,

 I built a dataframe with read.csv2(). Initially, row names are integers
 (order of answers to a survey). They are listed in the csv's first column.
 The import works well and my dataframe looks like I wanted it to look.

 Row names go as follows :
 [1] "6"   "29"  "31"  "32"  "52"  "55"  "63"  "71"  "72"  "80"  "88"  "89"
 "91"  "93"  "105" "110" "111" "117" "119" "120"
 [21] "122" "127" "128" "133" "137" "140" "163" "165" "167" "169" "177"
 "178" "179" "184" "186" "192" "193" "200" "201" "228"
 etc.

 I would like to drop rows "601" & "604" to clean the dataframe.

 While data["601",] shows me the first row i'd like to drop, data[-"601",]
 returns the following :
 Error in -"601" : invalid argument to unary operator

 idem with data[c("601","604"),] and data[-c("601","604"),]

 It is the first time that I run into this specific error. After reading a
 bit about it I still don't understand what it means and how to fix it.

 Thanks for reading!
 Best,
 Pauline.

         [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
 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 -- To UNSUBSCRIBE and more, see
>>> 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.
>>
>>  

 

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] "invalid argument to unary operator" while selecting rows by name

2016-09-20 Thread ruipbarradas

Sorry, I've made a stupid mistake.
It's obviously the other way around.

ix <- which(rownames(data) %in% c("601", "604"))
clean <- data[-ix, ]


Rui Barradas


Citando ruipbarra...@sapo.pt:


Hello,

Try something like the following.

ix <- which(c("601", "604") %in% rownames(data))
clean <- data[-ix, ]


Hope this helps,

Rui Barradas




Citando Pauline Laïlle :


Dear all,

I built a dataframe with read.csv2(). Initially, row names are integers
(order of answers to a survey). They are listed in the csv's first column.
The import works well and my dataframe looks like I wanted it to look.

Row names go as follows :
[1] "6"   "29"  "31"  "32"  "52"  "55"  "63"  "71"  "72"  "80"  "88"  "89"
"91"  "93"  "105" "110" "111" "117" "119" "120"
[21] "122" "127" "128" "133" "137" "140" "163" "165" "167" "169" "177"
"178" "179" "184" "186" "192" "193" "200" "201" "228"
etc.

I would like to drop rows "601" & "604" to clean the dataframe.

While data["601",] shows me the first row i'd like to drop, data[-"601",]
returns the following :
Error in -"601" : invalid argument to unary operator

idem with data[c("601","604"),] and data[-c("601","604"),]

It is the first time that I run into this specific error. After reading a
bit about it I still don't understand what it means and how to fix it.

Thanks for reading!
Best,
Pauline.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 -- To UNSUBSCRIBE and more, see
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 -- To UNSUBSCRIBE and more, see
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] "invalid argument to unary operator" while selecting rows by name

2016-09-20 Thread ruipbarradas

Hello,

Try something like the following.

ix <- which(c("601", "604") %in% rownames(data))
clean <- data[-ix, ]


Hope this helps,

Rui Barradas




Citando Pauline Laïlle :


Dear all,

I built a dataframe with read.csv2(). Initially, row names are integers
(order of answers to a survey). They are listed in the csv's first column.
The import works well and my dataframe looks like I wanted it to look.

Row names go as follows :
 [1] "6"   "29"  "31"  "32"  "52"  "55"  "63"  "71"  "72"  "80"  "88"  "89"
 "91"  "93"  "105" "110" "111" "117" "119" "120"
 [21] "122" "127" "128" "133" "137" "140" "163" "165" "167" "169" "177"
"178" "179" "184" "186" "192" "193" "200" "201" "228"
etc.

I would like to drop rows "601" & "604" to clean the dataframe.

While data["601",] shows me the first row i'd like to drop, data[-"601",]
returns the following :
Error in -"601" : invalid argument to unary operator

idem with data[c("601","604"),] and data[-c("601","604"),]

It is the first time that I run into this specific error. After reading a
bit about it I still don't understand what it means and how to fix it.

Thanks for reading!
Best,
Pauline.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 -- To UNSUBSCRIBE and more, see
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] "invalid argument to unary operator" while selecting rows by name

2016-09-20 Thread Bert Gunter
Hint: "601"  is not 601.

Have you gone through any R tutorials?

Cheers,
Bert
Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Tue, Sep 20, 2016 at 5:42 AM, Pauline Laïlle
 wrote:
> Dear all,
>
> I built a dataframe with read.csv2(). Initially, row names are integers
> (order of answers to a survey). They are listed in the csv's first column.
> The import works well and my dataframe looks like I wanted it to look.
>
> Row names go as follows :
>  [1] "6"   "29"  "31"  "32"  "52"  "55"  "63"  "71"  "72"  "80"  "88"  "89"
>  "91"  "93"  "105" "110" "111" "117" "119" "120"
>  [21] "122" "127" "128" "133" "137" "140" "163" "165" "167" "169" "177"
> "178" "179" "184" "186" "192" "193" "200" "201" "228"
> etc.
>
> I would like to drop rows "601" & "604" to clean the dataframe.
>
> While data["601",] shows me the first row i'd like to drop, data[-"601",]
> returns the following :
> Error in -"601" : invalid argument to unary operator
>
> idem with data[c("601","604"),] and data[-c("601","604"),]
>
> It is the first time that I run into this specific error. After reading a
> bit about it I still don't understand what it means and how to fix it.
>
> Thanks for reading!
> Best,
> Pauline.
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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 -- To UNSUBSCRIBE and more, see
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] "invalid argument to unary operator" while selecting rows by name

2016-09-20 Thread Pauline Laïlle
Dear all,

I built a dataframe with read.csv2(). Initially, row names are integers
(order of answers to a survey). They are listed in the csv's first column.
The import works well and my dataframe looks like I wanted it to look.

Row names go as follows :
 [1] "6"   "29"  "31"  "32"  "52"  "55"  "63"  "71"  "72"  "80"  "88"  "89"
 "91"  "93"  "105" "110" "111" "117" "119" "120"
 [21] "122" "127" "128" "133" "137" "140" "163" "165" "167" "169" "177"
"178" "179" "184" "186" "192" "193" "200" "201" "228"
etc.

I would like to drop rows "601" & "604" to clean the dataframe.

While data["601",] shows me the first row i'd like to drop, data[-"601",]
returns the following :
Error in -"601" : invalid argument to unary operator

idem with data[c("601","604"),] and data[-c("601","604"),]

It is the first time that I run into this specific error. After reading a
bit about it I still don't understand what it means and how to fix it.

Thanks for reading!
Best,
Pauline.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.