Re: [R] Minimum and blanks

2009-10-01 Thread Chris Li

Thanks Joris and Peter. Sorry for not giving enough details. I have tried
your suggestions and the problem is solved. Thank you. :)


JorisMeys wrote:
> 
> The minimum of a character vector is returned according to the unicode
> or ascii code values, but I guess that's not what Chris is looking
> for.
> 
> Chris, please always try to provide a minimal working example of code
> to see what is wrong.
> 
> Something goes wrong with the input in your example. As Peter
> rightfully pointed out, your vector is considered a character vector.
> So you need to :
> 
> 1) replace "" with NA
>   e.g. x <-  ifelse(x=='',NA,x)
> Better to do something like that when reading in the code.
> 
> 2) use the argument na.rm : min (x, na.rm=T)
> 
> kind regards
> Joris
> 
> On Thu, Oct 1, 2009 at 8:36 AM, Peter Ehlers  wrote:
>> Chris,
>>
>> What is your definition of the minimum of a *character* vector?
>>
>>  -Peter Ehlers
>>
>> Chris Li wrote:
>>>
>>> Hi all,
>>>
>>> I want to calculate the minimum of a column which contains blanks.
>>>
>>> R returns "" as the minimum, which is not I want.
>>>
>>> Is there a way to overcome it?
>>>
>>> Thanks in advance.
>>> Chris
>>
>> __
>> 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.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Minimum-and-blanks-tp25692189p25707736.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] Minimum and blanks

2009-10-01 Thread joris meys
The minimum of a character vector is returned according to the unicode
or ascii code values, but I guess that's not what Chris is looking
for.

Chris, please always try to provide a minimal working example of code
to see what is wrong.

Something goes wrong with the input in your example. As Peter
rightfully pointed out, your vector is considered a character vector.
So you need to :

1) replace "" with NA
  e.g. x <-  ifelse(x=='',NA,x)
Better to do something like that when reading in the code.

2) use the argument na.rm : min (x, na.rm=T)

kind regards
Joris

On Thu, Oct 1, 2009 at 8:36 AM, Peter Ehlers  wrote:
> Chris,
>
> What is your definition of the minimum of a *character* vector?
>
>  -Peter Ehlers
>
> Chris Li wrote:
>>
>> Hi all,
>>
>> I want to calculate the minimum of a column which contains blanks.
>>
>> R returns "" as the minimum, which is not I want.
>>
>> Is there a way to overcome it?
>>
>> Thanks in advance.
>> Chris
>
> __
> 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] Minimum and blanks

2009-09-30 Thread Peter Ehlers

Chris,

What is your definition of the minimum of a *character* vector?

 -Peter Ehlers

Chris Li wrote:

Hi all,

I want to calculate the minimum of a column which contains blanks.

R returns "" as the minimum, which is not I want.

Is there a way to overcome it?

Thanks in advance.
Chris


__
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] Minimum and blanks

2009-09-30 Thread Chris Li

Hi all,

I want to calculate the minimum of a column which contains blanks.

R returns "" as the minimum, which is not I want.

Is there a way to overcome it?

Thanks in advance.
Chris
-- 
View this message in context: 
http://www.nabble.com/Minimum-and-blanks-tp25692189p25692189.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.