[R] data import: strange experience
peter dalgaard
pdalgd at gmail.com
Wed Aug 21 16:54:33 CEST 2013
On Aug 21, 2013, at 16:46 , Sarah Goslee wrote:
> Hi,
>
> We don't know anything about your data or your file, so it's utterly
> impossible to offer useful suggestions.
>
> The very best thing you can do is condense your problem into a
> reproducible example, with fake data if necessary. Otherwise you're
> limited by the ability of the list to guess what you're looking at,
> and our track record with that is spotty.
>
Yes. That being said, though, try read.delim() instead of read.table. Various options are set differently.
-pd
>
> Sarah
>
> On Wed, Aug 21, 2013 at 10:35 AM, SH <emptican at gmail.com> wrote:
>> Dear List:
>>
>> I had some strange experience in importing data. I wonder if anyone of you
>> had the same problem before and would greatly appreciate your suggestion in
>> advance.
>>
>> The original data set in excel format.
>>
>> Here is a brief summary of the procedure I did:
>> 1. I saved the original excel data as csv and txt formats, separately.
>> 2. I imported two data using the following codes. There were no error
>> messages.
>> dftxt = read.table('df.txt',header=T, sep='\t')
>> dfcsv = read.csv('df.csv',header=T, sep=',')
>> 3. When I checked data with 'str', I found that factor levels of a variable
>> were different each other.
>> Levels of dftxt were less than those of dfcsv (48 vs 52).
>> 4. So, I checked 'df.txt' file and found that the missing levels were still
>> there, i.e., there is a no problem in text file. I suspect that something
>> happened when I imported it into R.
>>
>> Since there was no errors in importing the file into R, I do not have an
>> idea where to start to fix it. Do you have any suggestion?
>>
>> Thank you very much in advance,
>>
>> SH
>>
>
> --
> Sarah Goslee
> http://www.functionaldiversity.org
>
> ______________________________________________
> 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.
--
Peter Dalgaard, Professor
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
More information about the R-help
mailing list