Re: [R] Weird read.xls behavior

From: David Winsemius <dwinsemius_at_comcast.net>
Date: Tue, 10 May 2011 10:59:32 -0400

On May 10, 2011, at 10:54 AM, Jun Shen wrote:

> Hi, Kenneth,
>
> I would like a bit more advice on how to use gsub to remove the
> spaces at
> the beginning or the end for a data frame and still keep the data
> frame in
> the same format. The way I see is something like
>
> gsub(' *$', '' , unlist(dataframe)). But the result is not a data
> frame
> anymore. Thanks.
>

  1. Please do not attach unrelated questions to existing threads.
  2. Please do include reproducible code that creates an example to work with.
  3. Please do read the help page for gsub with careful attention to the datatypes it expects as input and the values it will return.
-- 
David.

> Jun
>
> On Mon, May 9, 2011 at 11:01 PM, Kenneth Roy Cabrera Torres <
> krcabrer_at_une.net.co> wrote:
>
>> Maybe in the original there are some "ghost" spaces after ng/ml,
>> verify them.
>>
>> Any way you can erase the first and the last white spaces with gsub
>> function.
>>
>> HTH
>>
>> Kenneth
>> El lun, 09-05-2011 a las 22:44 -0500, Jun Shen escribió:
>>> Dear list,
>>>
>>> I used read.xls to read in an excel file, which has both character
>>> and
>>> numeric columns. Everything seems fine except in the last column,
>>> I have
>>> this character value "ng/ml". When reading in, read.xls seems to
>>> add a
>> space
>>> at the end of it, became "ng/ml ". How can I prevent read.xls
>>> doing so?
>>> Thanks.
>>>
>>>> read.xls(data, header=T, as.is=T)
>>>
>>> Jun
>>>
>>> [[alternative HTML version deleted]]
>>>
>>> ______________________________________________
>>> R-help_at_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.
>>
>>
>>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_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.
David Winsemius, MD West Hartford, CT ______________________________________________ R-help_at_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.
Received on Tue 10 May 2011 - 15:07:35 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 10 May 2011 - 15:30:07 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive