[R-SIG-Mac] import data Mac OS

Thor Jensen thor.jsn at gmail.com
Mon May 2 16:41:13 CEST 2011


Brilliant!

That did it, the .csv2 worked!  Simple fix for a simple project that
had me blocked.

Thanks for the other tips as well, I'll look into str() now.

Best wishes,

Thor




On Mon, May 2, 2011 at 4:32 PM, Ben Madin
<lists at remoteinformation.com.au> wrote:
> Is it possible that the columns are separated by semicolons in the file. Can you open the .csv file in a text editor? Right click and choose open with ... and use textedit or bbedit or textmate or something?
>
> if so, if you read the help page (use ?read.csv) you will see that you can specify the separator in the command (sep=';' might work) or you could actually use the read.csv2 command (you will see that it defaults to the semicolon)
>
> test <- read.csv2(file="~/Desktop/heightweight.csv")
>
> another useful command that isn't always apparent to beginners is the str command, ie :
>
> str(test)
>
> good luck again.
>
> cheers
>
> Ben
>
>
> On 02/05/2011, at 10:22 PM, Thor Jensen wrote:
>
>> Hello everyone,
>>
>> Thanks a ton to everyone on this thread.  Apologies for breaking
>> posting etiquette - this was my first post.
>>
>> I got it to work using a few different suggestions, the only thing is
>> the my .csv file is appearing in R as separated by semicolons.  The
>> column headings are separated only by a period, preventing me from
>> manipulating the data.  For example:
>>
>>> Test=read.csv(file="~/Desktop/heightweight.csv")
>> Message d'avis :
>> In read.table(file = file, header = header, sep = sep, quote = quote,  :
>>  readTableHeader a trouvé une ligne finale incomplète dans
>> '~/Desktop/heightweight.csv'
>>> Test
>>  Height.Weight
>> 1       200;180
>> 2       180;170
>> 3       160;130
>> 4       210;200
>>> Test$Height
>> [1] 200;180 180;170 160;130 210;200
>> Levels: 160;130 180;170 200;180 210;200
>>> Test$Weight
>> NULL
>>>
>>
>> I have been using the above .csv file to learn the R program before
>> importing a much larger data set, some three thousand rows long.
>> Thanks again for all the inputs, and if I am using the thread
>> incorrectly feel free to say so.  Not intending to abuse the service.
>>
>> Many thanks,
>>
>> Thor
>>
>> On Mon, May 2, 2011 at 3:28 PM, Thor Jensen <thor.jsn at gmail.com> wrote:
>>> Hello,
>>>
>>> I am unable to write a pathway to .csv files saved on my computer.  I
>>> can get this to work on a windows machine, but the mac returns a
>>> message saying the file does not exist.  Any tips on how to import
>>> data on mac's?  For example, the below line was unsuccesful.
>>> read.csv(file="Macintosh HD:Users:ThorJ:Desktop:heightweight.csv"
>>>
>>> Many thanks,
>>>
>>> Thor
>>>
>>
>> _______________________________________________
>> R-SIG-Mac mailing list
>> R-SIG-Mac at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
>
>



More information about the R-SIG-Mac mailing list