[R] Import in R with White Spaces

Sarah Goslee sarah.goslee at gmail.com
Mon Oct 3 21:30:19 CEST 2011


Hi,

On Mon, Oct 3, 2011 at 11:14 AM, francy <francy.casalino at gmail.com> wrote:
> Hi,
>
> I have a simple question about importing data, I would be very grateful if
> you could help me out.
>
> I have used read.csv(file name, header=T, sep=",") to bring in a csv file I
> saved in MS Excel.The problem is I have white spaces in the middle of values
> (not in the column names), and this messes up the column entries. Since I
> have many many files that I am importing and I have spaces in all of them, I
> was looking for a way to avoid going into all of them and changing the white
> spaec to, for example, an underscore.
> Can you suggest whether there is a way to tell R that each element delimited
> by "," is actually a different entry, regardless of whether there are white
> spaces in between?

Since you're exporting from Excel, make sure that quoting is turned on in
the export options. That way an entire value, including white space, will
be in quotes and thus read as an entire value. That should have been
done by default, and specifying sep as you did should have worked.

So actually, we may need more information beyond what you've provided.

Sarah

-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list