Re: [R] Importing data with value labels into R

2022-11-14 Thread IAGO GINÉ VÁZQUEZ
Hello Maryam,

The haven function for reading Stata files is read_dta (not read.dta!!!). May 
this be your issue?

Iago


De: R-help  de part de Maryam Iraniparast 

Enviat el: dilluns, 14 de novembre de 2022 19:07
Per a: r-help@r-project.org 
Tema: [R] Importing data with value labels into R

Hello!

I want to read SPSS data into R and I want to carry the value labels with my 
dataset.
Based on my research, only Stata file can transfer the value labels to R (It is 
easy to save SPSS data with Stata format).
The last time I did that successfully, I was using R4.2.1 and the following 
code. But it does not work anymore.


install.packages("tidyverse")

install.packages("haven")
library(tidyverse)

library(haven)

df=file.choose() *Note: Select the STATA file from the folder where it is saved.

dataset=read.dta(df)

I appreciate any thoughts or suggestion.

Thanks,
Mary

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Importing data using Foreign

2020-08-27 Thread Elham Daadmehr
Thanks a lot. I’ve got it just now.

On Wed, Aug 26, 2020 at 6:03 PM peter dalgaard  wrote:

> It is because you don't know whether you want it or not.
>
> It is a bit more obvious with integer indexing, as in color[race]: if race
> is NA you don't know what color to put in, but the result should be the
> same length as race.
>
> With logical indices, the behaviour is a bit annoying, but ultimately
> follows from the coercion rules: You might think that you could treat NA as
> FALSE (& the subset() function does just that), but then you'd get the
> problem that x[NA] would differ from x[as.integer(NA)] because NA is of
> mode "logical", lowest in the coercion hierarchy.
>
> -pd
>
> > On 26 Aug 2020, at 17:06 , Elham Daadmehr  wrote:
> >
> > Thanks guys. but I'm a bit confused. the input is the first column
> (z[,1] and z1[,1]).
> > How is it possible that a subset of a non-NA vector, contains NA?
> >
> > On Wed, Aug 26, 2020 at 4:58 PM Eric Berger 
> wrote:
> > Good point! :-)
> >
> >
> > On Wed, Aug 26, 2020 at 5:55 PM peter dalgaard  wrote:
> > Offhand, I suspect that the NAs are in the 8th column.
> >
> > > On 26 Aug 2020, at 10:57 , Elham Daadmehr 
> wrote:
> > >
> > > Hi all,
> > >
> > > I have a simple problem. I get stuck in using the imported spss data
> (.sav)
> > > using "read.spss".
> > > I imported data (z) without any problem. After importing, the first
> column
> > > doesn't contain any "NA". but when I choose a subset of it (like:
> > > z[z[,8]=="11"|z[,8]=="12"|z[,8]=="14",]), lots of NA appears (even in
> the
> > > first column).
> > >
> > > The (.sav) file is the output of Compustat (WRDS).
> > >
> > > It is terrible, I can't find the mistake.
> > >
> > > Thank you in advance for your help,
> > > Elham
> > >
> > >   [[alternative HTML version deleted]]
> > >
> > > __
> > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > > 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
> > Office: A 4.23
> > Email: pd@cbs.dk  Priv: pda...@gmail.com
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > 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
> Office: A 4.23
> Email: pd@cbs.dk  Priv: pda...@gmail.com
>
>
>
>
>
>
>
>
>
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Importing data using Foreign

2020-08-27 Thread Elham Daadmehr
Thanks for your reply.

You're right, here is what I did:

> library(foreign)

> sz201401=read.spss("/Users/e.daadmehr/Desktop/Term/LastLast/untitled
folder/2014/1.sav", to.data.frame=TRUE)

Warning message:

In read.spss("/Users/e.daadmehr/Desktop/Term/LastLast/untitled
folder/2014/1.sav",  :

  /Users/e.daadmehr/Desktop/Term/LastLast/untitled folder/2014/1.sav:
Compression bias (0) is not the usual value of 100

> z =sz201401

> is.list(z)

[1] TRUE

> z=as.data.frame(z)

> is.data.frame(z)

[1] TRUE

> z=z[,-c(10)]

> sum(is.na(z[,1]))

[1] 0

> z1=z[z[,8]=="11"|z[,8]=="12"|z[,8]=="14",]

> sum(is.na(z1[,1]))

[1] 399


my file is not compressed.


Thank you in advance,

Elham



On Wed, Aug 26, 2020 at 3:31 PM Eric Berger  wrote:

> Hi Elham,
> You are not giving us much to go on here.
> Show us the commands that (a) confirm there are no NA's in the first
> column of z
> and (b) output a row of z that has an NA in the first column.
> Here's how one might do this:
> (a) sum(is.na(z[,1]))
> (b) z[ match(TRUE, z[,8] %in% c("11","12","14")), ]
>
> Eric
>
>
> On Wed, Aug 26, 2020 at 3:56 PM Elham Daadmehr 
> wrote:
>
>> Hi all,
>>
>> I have a simple problem. I get stuck in using the imported spss data
>> (.sav)
>> using "read.spss".
>> I imported data (z) without any problem. After importing, the first column
>> doesn't contain any "NA". but when I choose a subset of it (like:
>> z[z[,8]=="11"|z[,8]=="12"|z[,8]=="14",]), lots of NA appears (even in the
>> first column).
>>
>> The (.sav) file is the output of Compustat (WRDS).
>>
>> It is terrible, I can't find the mistake.
>>
>> Thank you in advance for your help,
>> Elham
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Importing data using Foreign

2020-08-27 Thread Elham Daadmehr
Thanks guys. but I'm a bit confused. the input is the first column (z[,1]
and z1[,1]).
How is it possible that a subset of a non-NA vector, contains NA?

On Wed, Aug 26, 2020 at 4:58 PM Eric Berger  wrote:

> Good point! :-)
>
>
> On Wed, Aug 26, 2020 at 5:55 PM peter dalgaard  wrote:
>
>> Offhand, I suspect that the NAs are in the 8th column.
>>
>> > On 26 Aug 2020, at 10:57 , Elham Daadmehr  wrote:
>> >
>> > Hi all,
>> >
>> > I have a simple problem. I get stuck in using the imported spss data
>> (.sav)
>> > using "read.spss".
>> > I imported data (z) without any problem. After importing, the first
>> column
>> > doesn't contain any "NA". but when I choose a subset of it (like:
>> > z[z[,8]=="11"|z[,8]=="12"|z[,8]=="14",]), lots of NA appears (even in
>> the
>> > first column).
>> >
>> > The (.sav) file is the output of Compustat (WRDS).
>> >
>> > It is terrible, I can't find the mistake.
>> >
>> > Thank you in advance for your help,
>> > Elham
>> >
>> >   [[alternative HTML version deleted]]
>> >
>> > __
>> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> > 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
>> Office: A 4.23
>> Email: pd@cbs.dk  Priv: pda...@gmail.com
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Importing data using Foreign

2020-08-26 Thread peter dalgaard
It is because you don't know whether you want it or not. 

It is a bit more obvious with integer indexing, as in color[race]: if race is 
NA you don't know what color to put in, but the result should be the same 
length as race. 

With logical indices, the behaviour is a bit annoying, but ultimately follows 
from the coercion rules: You might think that you could treat NA as FALSE (& 
the subset() function does just that), but then you'd get the problem that 
x[NA] would differ from x[as.integer(NA)] because NA is of mode "logical", 
lowest in the coercion hierarchy.

-pd

> On 26 Aug 2020, at 17:06 , Elham Daadmehr  wrote:
> 
> Thanks guys. but I'm a bit confused. the input is the first column (z[,1] and 
> z1[,1]).
> How is it possible that a subset of a non-NA vector, contains NA?
> 
> On Wed, Aug 26, 2020 at 4:58 PM Eric Berger  wrote:
> Good point! :-)
> 
> 
> On Wed, Aug 26, 2020 at 5:55 PM peter dalgaard  wrote:
> Offhand, I suspect that the NAs are in the 8th column.
> 
> > On 26 Aug 2020, at 10:57 , Elham Daadmehr  wrote:
> > 
> > Hi all,
> > 
> > I have a simple problem. I get stuck in using the imported spss data (.sav)
> > using "read.spss".
> > I imported data (z) without any problem. After importing, the first column
> > doesn't contain any "NA". but when I choose a subset of it (like:
> > z[z[,8]=="11"|z[,8]=="12"|z[,8]=="14",]), lots of NA appears (even in the
> > first column).
> > 
> > The (.sav) file is the output of Compustat (WRDS).
> > 
> > It is terrible, I can't find the mistake.
> > 
> > Thank you in advance for your help,
> > Elham
> > 
> >   [[alternative HTML version deleted]]
> > 
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > 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
> Office: A 4.23
> Email: pd@cbs.dk  Priv: pda...@gmail.com
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@gmail.com

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Importing data using Foreign

2020-08-26 Thread Eric Berger
c(1:3)[c(1,NA,3)]
[1] 1 NA 3


On Wed, Aug 26, 2020 at 6:06 PM Elham Daadmehr  wrote:

> Thanks guys. but I'm a bit confused. the input is the first column (z[,1]
> and z1[,1]).
> How is it possible that a subset of a non-NA vector, contains NA?
>
> On Wed, Aug 26, 2020 at 4:58 PM Eric Berger  wrote:
>
>> Good point! :-)
>>
>>
>> On Wed, Aug 26, 2020 at 5:55 PM peter dalgaard  wrote:
>>
>>> Offhand, I suspect that the NAs are in the 8th column.
>>>
>>> > On 26 Aug 2020, at 10:57 , Elham Daadmehr 
>>> wrote:
>>> >
>>> > Hi all,
>>> >
>>> > I have a simple problem. I get stuck in using the imported spss data
>>> (.sav)
>>> > using "read.spss".
>>> > I imported data (z) without any problem. After importing, the first
>>> column
>>> > doesn't contain any "NA". but when I choose a subset of it (like:
>>> > z[z[,8]=="11"|z[,8]=="12"|z[,8]=="14",]), lots of NA appears (even in
>>> the
>>> > first column).
>>> >
>>> > The (.sav) file is the output of Compustat (WRDS).
>>> >
>>> > It is terrible, I can't find the mistake.
>>> >
>>> > Thank you in advance for your help,
>>> > Elham
>>> >
>>> >   [[alternative HTML version deleted]]
>>> >
>>> > __
>>> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> > 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
>>> Office: A 4.23
>>> Email: pd@cbs.dk  Priv: pda...@gmail.com
>>>
>>> __
>>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> 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@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Importing data using Foreign

2020-08-26 Thread Eric Berger
Good point! :-)


On Wed, Aug 26, 2020 at 5:55 PM peter dalgaard  wrote:

> Offhand, I suspect that the NAs are in the 8th column.
>
> > On 26 Aug 2020, at 10:57 , Elham Daadmehr  wrote:
> >
> > Hi all,
> >
> > I have a simple problem. I get stuck in using the imported spss data
> (.sav)
> > using "read.spss".
> > I imported data (z) without any problem. After importing, the first
> column
> > doesn't contain any "NA". but when I choose a subset of it (like:
> > z[z[,8]=="11"|z[,8]=="12"|z[,8]=="14",]), lots of NA appears (even in the
> > first column).
> >
> > The (.sav) file is the output of Compustat (WRDS).
> >
> > It is terrible, I can't find the mistake.
> >
> > Thank you in advance for your help,
> > Elham
> >
> >   [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > 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
> Office: A 4.23
> Email: pd@cbs.dk  Priv: pda...@gmail.com
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Importing data using Foreign

2020-08-26 Thread peter dalgaard
Offhand, I suspect that the NAs are in the 8th column.

> On 26 Aug 2020, at 10:57 , Elham Daadmehr  wrote:
> 
> Hi all,
> 
> I have a simple problem. I get stuck in using the imported spss data (.sav)
> using "read.spss".
> I imported data (z) without any problem. After importing, the first column
> doesn't contain any "NA". but when I choose a subset of it (like:
> z[z[,8]=="11"|z[,8]=="12"|z[,8]=="14",]), lots of NA appears (even in the
> first column).
> 
> The (.sav) file is the output of Compustat (WRDS).
> 
> It is terrible, I can't find the mistake.
> 
> Thank you in advance for your help,
> Elham
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@gmail.com

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Importing data using Foreign

2020-08-26 Thread Eric Berger
Hi Elham,
You are not giving us much to go on here.
Show us the commands that (a) confirm there are no NA's in the first column
of z
and (b) output a row of z that has an NA in the first column.
Here's how one might do this:
(a) sum(is.na(z[,1]))
(b) z[ match(TRUE, z[,8] %in% c("11","12","14")), ]

Eric


On Wed, Aug 26, 2020 at 3:56 PM Elham Daadmehr  wrote:

> Hi all,
>
> I have a simple problem. I get stuck in using the imported spss data (.sav)
> using "read.spss".
> I imported data (z) without any problem. After importing, the first column
> doesn't contain any "NA". but when I choose a subset of it (like:
> z[z[,8]=="11"|z[,8]=="12"|z[,8]=="14",]), lots of NA appears (even in the
> first column).
>
> The (.sav) file is the output of Compustat (WRDS).
>
> It is terrible, I can't find the mistake.
>
> Thank you in advance for your help,
> Elham
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] importing data error question

2019-01-18 Thread Fox, John
Dear Jihee,

> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of ???
> Sent: Wednesday, January 16, 2019 7:02 PM
> To: Fox, John 
> Cc: r-help@r-project.org
> Subject: Re: [R] importing data error question
> 
> Thanks for your help!
> 
> I was having trouble with finding how to use english...
> 
> Even though I try to use english language, I couldn't change language of R
> commander. (it is still korean)
> 
> Sorry but.. do you know how to change language of "R commander"? I have
> no idea why it doesn't change.

But the screenshots you sent in previous messages *did* show the Rcmdr in 
English, so you apparently successfully changed the language, I assume via the 
command Sys.setenv(LANGUAGE="en") that I suggested.

John

> 
> Best,
> 
> Jihee
> 
> From:  "Fox, John" 
> 
> Sent: Thursday, January 17, 2019 1:59:03 AM
> 
> To:"우지희" 
> 
> Cc:"r-help@r-project.org" 
> 
> Subject:Re: [R] importing data error question
> 
>   Dear jihee,
> 
>  I've looked into this problem further, using my Mac where it's easier to
> temporarily change languages and character sets than on Windows, and I
> discovered the following:
> 
>  I was able to duplicate your problem with importing Excel files when working
> in Korean. There's a similar problem with the import SAS b7dat files but not
> with the other file-import dialogs.
> 
>  I observed a similar problem when working in Chinese (LANG="zh") but not in
> simplified Chinese (zh_CN) or Japanese (ja), so the problem isn't simply with
> non-Latin character sets. There is no problem in English, Spanish (es), or
> French (fr), and I didn't check the other languages into which the Rcmdr is
> translated.
> 
>  I think that the problem originates in the Korean and Chinese translation 
> files
> and I'll contact the translators to see whether they can fix it.
> 
>  Thank you for reporting this issue.
> 
>  John
> 
>  > On Jan 14, 2019, at 11:36 PM, Fox, John  wrote:
>  >
>  > Dear jihee,
>  >
>  >> On Jan 14, 2019, at 9:00 PM, 우지희  wrote:
>  >>
>  >> You said previously that you were using a Mac, so I'm surprised that you
> now say that you're using Windows. I don't have a Windows 7 system, but I
> can confirm that importing from Excel files works perfectly fine under
> Windows 10, as I just verified, and I'd be surprised if the Windows version
> matters.
>  >>
>  >> --> no, I never said i was using a Mac.
>  >
>  > Sorry, I guess I got that from the error message you originally reported,
> which was "Error in structure(.External(.C_dotTclObjv, objv), class = 
> "tclObj") :
> [tcl] bad Macintosh file type "“*”"." I've never seen that error and it seems
> peculiar that it would occur on a Windows system.
>  >
>  >>
>  >> You still haven't reported the versions of R, the Rcmdr package, and the
> other packages that you're using. The easiest way to do this is to show the
> output of the sessionInfo() command.
>  >>
>  >> --> sessionInfo()
>  >> R version 3.5.2 (2018-12-20)
>  >> Platform: x86_64-w64-mingw32/x64 (64-bit)  >> Running under: Windows
> 7 x64 (build 7601) Service Pack 1  >>  >> Matrix products: default  >>  >>
> locale:
>  >> [1] LC_COLLATE=Korean_Korea.949 LC_CTYPE=Korean_Korea.949  >> [3]
> LC_MONETARY=Korean_Korea.949 LC_NUMERIC=C  >> [5]
> LC_TIME=Korean_Korea.949  >>  >> attached base packages:
>  >> [1] tcltk splines stats graphics grDevices utils datasets methods  >> [9] 
> base
> >>  >> other attached packages:
>  >> [1] RcmdrPlugin.SensoMineR_1.11-01 RcmdrPlugin.FactoMineR_1.6-0  >>
> [3] Rcmdr_2.5-1 effects_4.1-0  >> [5] RcmdrMisc_2.5-1 sandwich_2.5-0  >> [7]
> car_3.0-2 carData_3.0-2  >> [9] SensoMineR_1.23 FactoMineR_1.41  >>  >>
> loaded via a namespace (and not attached):
>  >> [1] gtools_3.8.1 Formula_1.2-3 latticeExtra_0.6-28  >> [4] 
> cellranger_1.1.0
> pillar_1.3.1 backports_1.1.3  >> [7] lattice_0.20-38 digest_0.6.18
> RColorBrewer_1.1-2  >> [10] checkmate_1.8.5 minqa_1.2.4 colorspace_1.3-2
> >> [13] survey_3.35 htmltools_0.3.6 Matrix_1.2-15  >> [16] plyr_1.8.4
> pkgconfig_2.0.2 haven_2.0.0  >> [19] scales_1.0.0 openxlsx_4.1.0 rio_0.5.16
> >> [22] lme4_1.1-19 htmlTable_1.13.1 tibble_1.4.2  >> [25] relimp_1.0-5
> ggplot2_3.1.0 nnet_7.3-12  >> [28] lazyeval_0.2.1 survival_2.43-3 magrittr_1.5
> >> [31] crayon_1.3.4 readx

Re: [R] importing data error question

2019-01-18 Thread 우지희
Thanks for your help! 

I was having trouble with finding how to use english... 

Even though I try to use english language, I couldn't change language of R 
commander. (it is still korean) 

Sorry but.. do you know how to change language of "R commander"? I have no idea 
why it doesn't change. 

Best, 

Jihee 

From:  "Fox, John"  

Sent: Thursday, January 17, 2019 1:59:03 AM 

To:"우지희"  

Cc:"r-help@r-project.org"  

Subject:Re: [R] importing data error question 

  Dear jihee,

 I've looked into this problem further, using my Mac where it's easier to 
temporarily change languages and character sets than on Windows, and I 
discovered the following:

 I was able to duplicate your problem with importing Excel files when working 
in Korean. There's a similar problem with the import SAS b7dat files but not 
with the other file-import dialogs.

 I observed a similar problem when working in Chinese (LANG="zh") but not in 
simplified Chinese (zh_CN) or Japanese (ja), so the problem isn't simply with 
non-Latin character sets. There is no problem in English, Spanish (es), or 
French (fr), and I didn't check the other languages into which the Rcmdr is 
translated.

 I think that the problem originates in the Korean and Chinese translation 
files and I'll contact the translators to see whether they can fix it.

 Thank you for reporting this issue.

 John

 > On Jan 14, 2019, at 11:36 PM, Fox, John  wrote:
 > 
 > Dear jihee,
 > 
 >> On Jan 14, 2019, at 9:00 PM, 우지희  wrote:
 >> 
 >> You said previously that you were using a Mac, so I'm surprised that you 
 >> now say that you're using Windows. I don't have a Windows 7 system, but I 
 >> can confirm that importing from Excel files works perfectly fine under 
 >> Windows 10, as I just verified, and I'd be surprised if the Windows version 
 >> matters. 
 >> 
 >> --> no, I never said i was using a Mac. 
 > 
 > Sorry, I guess I got that from the error message you originally reported, 
 > which was "Error in structure(.External(.C_dotTclObjv, objv), class = 
 > "tclObj") : [tcl] bad Macintosh file type "“*”"." I've never seen that error 
 > and it seems peculiar that it would occur on a Windows system.
 > 
 >> 
 >> You still haven't reported the versions of R, the Rcmdr package, and the 
 >> other packages that you're using. The easiest way to do this is to show the 
 >> output of the sessionInfo() command. 
 >> 
 >> --> sessionInfo()
 >> R version 3.5.2 (2018-12-20)
 >> Platform: x86_64-w64-mingw32/x64 (64-bit)
 >> Running under: Windows 7 x64 (build 7601) Service Pack 1
 >> 
 >> Matrix products: default
 >> 
 >> locale:
 >> [1] LC_COLLATE=Korean_Korea.949 LC_CTYPE=Korean_Korea.949 
 >> [3] LC_MONETARY=Korean_Korea.949 LC_NUMERIC=C 
 >> [5] LC_TIME=Korean_Korea.949 
 >> 
 >> attached base packages:
 >> [1] tcltk splines stats graphics grDevices utils datasets methods 
 >> [9] base 
 >> 
 >> other attached packages:
 >> [1] RcmdrPlugin.SensoMineR_1.11-01 RcmdrPlugin.FactoMineR_1.6-0 
 >> [3] Rcmdr_2.5-1 effects_4.1-0 
 >> [5] RcmdrMisc_2.5-1 sandwich_2.5-0 
 >> [7] car_3.0-2 carData_3.0-2 
 >> [9] SensoMineR_1.23 FactoMineR_1.41 
 >> 
 >> loaded via a namespace (and not attached):
 >> [1] gtools_3.8.1 Formula_1.2-3 latticeExtra_0.6-28 
 >> [4] cellranger_1.1.0 pillar_1.3.1 backports_1.1.3 
 >> [7] lattice_0.20-38 digest_0.6.18 RColorBrewer_1.1-2 
 >> [10] checkmate_1.8.5 minqa_1.2.4 colorspace_1.3-2 
 >> [13] survey_3.35 htmltools_0.3.6 Matrix_1.2-15 
 >> [16] plyr_1.8.4 pkgconfig_2.0.2 haven_2.0.0 
 >> [19] scales_1.0.0 openxlsx_4.1.0 rio_0.5.16 
 >> [22] lme4_1.1-19 htmlTable_1.13.1 tibble_1.4.2 
 >> [25] relimp_1.0-5 ggplot2_3.1.0 nnet_7.3-12 
 >> [28] lazyeval_0.2.1 survival_2.43-3 magrittr_1.5 
 >> [31] crayon_1.3.4 readxl_1.2.0 nlme_3.1-137 
 >> [34] MASS_7.3-51.1 forcats_0.3.0 foreign_0.8-71 
 >> [37] class_7.3-14 tools_3.5.2 data.table_1.11.8 
 >> [40] hms_0.4.2 tcltk2_1.2-11 stringr_1.3.1 
 >> [43] munsell_0.5.0 cluster_2.0.7-1 zip_1.0.0 
 >> [46] flashClust_1.01-2 compiler_3.5.2 e1071_1.7-0 
 >> [49] rlang_0.3.1 grid_3.5.2 nloptr_1.2.1 
 >> [52] rstudioapi_0.9.0 htmlwidgets_1.3 leaps_3.0 
 >> [55] base64enc_0.1-3 gtable_0.2.0 abind_1.4-5 
 >> [58] curl_3.2 reshape2_1.4.3 AlgDesign_1.1-7.3 
 >> [61] gridExtra_2.3 zoo_1.8-4 knitr_1.21 
 >> [64] nortest_1.0-4 Hmisc_4.1-1 KernSmooth_2.23-15 
 >> [67] stringi_1.2.4 Rcpp_1.0.0 rpart_4.1-13 
 >> [70] acepack_1.4.1 scatterplot3d_0.3-41 xfun_0.4 
 >> 
 >> This was the status that I tried to import Excel data. 
 > 
 > These packages seem up-to-date.
 > 
 >> 
 >> Also, have you tried importing an Excel file in the Rcmdr *without* the two 
 >> plug-in packages loaded, as I suggested in my original response? 
 >> 
 >> --> I tried without plug-in packages, but It didn't work. 
 > 
 > OK, so you tried the setup that works for me and, I assume from the lack of 
 > similar error reports, for others.
 > 
 >> 
 >> It occurs to me that the problem may be produced by using the Rcmdr under R 
 >> with a non-Latin set, but if that 

Re: [R] importing data error question

2019-01-18 Thread Fox, John
Dear Jihee,

> On Jan 17, 2019, at 7:00 PM, 우지희  wrote:
> 
> Dear John,
>  
> (1) I noticed that you loaded the FactoMineR and SensoMineR plug-ins. Try 
> again without loading these plug-ins.
> not worked :(
>  
> 

OK. I don't understand why that doesn't work. There is likely some peculiarity 
in your system, but I have no idea what it is, and I can't think what else I 
might do without access to your computer.

>  
>  
> (2) Download and try reading the plain-text data file from 
> , 
> using "Data > Import data > From text file, clipboard, or URL"; you can take 
> all of the defaults in the resulting dialog box.
>  
> I think importing is working but I can't view data set. it says ERROR: DATA 
> FRAME TOO WIDE
>  
> 

You tried to read the Excel file Prestige.xlsx as if it were a plain-text file, 
which produces nonsense. This was my fault: I sent the wrong link; the correct 
file is at 
.

Best,
 John

>  
>  
>  
> I have no idea neither. ;(
> I might give up from now,,
>  
>  
> Thanks again!
>  
> Best,
> Jihee
>  
>  
>  
> From: "Fox, John" 
> Sent: Friday, January 18, 2019 12:02:42 AM
> To:"우지희" 
> Cc:"" 
> Subject:Re: [R] importing data error question
>  
>  
> Dear Jihee,
> 
> Your latest attempt has gotten farther than the previous one but has produced 
> a different error. The command to read the data set was generated properly. 
> You can see whether the data set was in fact read by typing prestige (the 
> name you gave to the data set) at the > command prompt in the R console. 
> Assuming that the data set was read, an error occurred when the Rcmdr tried 
> to make it the active data set. I'm afraid that I don't understand how this 
> could happen because this procedure works correctly for me and for others. 
> The underlying code is invoked whenever the Rcmdr reads a dara set.
> 
> I suggest that you try two additional things:
> 
> (1) I noticed that you loaded the FactoMineR and SensoMineR plug-ins. Try 
> again without loading these plug-ins.
> 
> (2) Download and try reading the plain-text data file from 
> , 
> using "Data > Import data > From text file, clipboard, or URL"; you can take 
> all of the defaults in the resulting dialog box.
> 
> If neither of these works then I'm afraid that I'm out of ideas. There's 
> something peculiar about your R installation that I can't detect.
> 
> Best,
> John
> 
> 
> 
> > On Jan 17, 2019, at 12:24 AM, 우지희  wrote:
> > 
> > Dear John,
> >  
> > I tried with your file. R commander could read the file but there's still 
> > no active dataset
> >  
> > Anyway I'll send my file, too
> >  
> > Jihee
> >  
> > <528c421a382d426895f6446b32fbc6f0.png>
> >  
> > From: "Fox, John" 
> > Sent: Thursday, January 17, 2019 2:09:52 PM
> > To:"우지희" 
> > Cc:"" 
> > Subject:Re: [R] importing data error question
> >  
> >  
> > Dear Jihee,
> > 
> > This appears to be a different problem. You were apparently able to access 
> > the spreadsheet file, but the R Commander didn't find a suitable worksheet 
> > in it.
> > 
> > Try downloading and reading the file at 
> > . If 
> > that works, send me privately (i.e., directly) your Excel spreadsheet file 
> > and I'll take a look at it.
> > 
> > Best,
> > John
> > 
> > > On Jan 16, 2019, at 9:49 PM, 우지희  wrote:
> > > 
> > > Dear John,
> > >  
> > > now i can use english thank you very much!!
> > >  
> > > um.. but nothing's changed... with that {r} message at R Markdown.
> > >  
> > > There's no dataset.
> > >  
> > > i tried both .xls and .xlsx .
> > >  
> > >  
> > > Jihee
> > >  
> > >  
> > >  
> > > 
> > >  
> > >  
> > >  
> > > From: "Fox, John" 
> > > Sent: Thursday, January 17, 2019 10:59:44 AM
> > > To:"우지희" 
> > > Cc:"" 
> > > Subject:Re: [R] importing data error question
> > >  
> > >  
> > > Dear Jihee,
> > > 
> > > Probably the easiest way to change the language to English temporarily in 
> > > R is to enter the command
> > > 
> > > Sys.setenv(LANGUAGE="en")
> > > 
> > > at the R command prompt prior to loading the Rcmdr package.
> > > 
> > > I hope that this helps,
> > > John
> > > 
> > > 
> > > > On Jan 16, 2019, at 7:02 PM, 우지희  wrote:
> > > > 
> > > > Thanks for your help!
> > > >  
> > > > I was having trouble with finding how to use english...
> > > >  
> > > > Even though I try to use english language, I couldn't change language 
> > > > of R commander. (it is still korean)
> > > >  
> > > > Sorry but.. do you know how to change language of "R commander"? I have 
> > > > no idea why it doesn't change.
> > > >  
> > > > Best,
> > > > Jihee
> > > >  
> > > > From: "Fox, John" 
> > > > Sent: Thursday, January 17, 2019 1:59:03 AM
> > > > To:"우지희" 
> > > > Cc:"r-help@r-project.org" 
> > > > Subject:Re: [R] importing data 

Re: [R] importing data error question

2019-01-17 Thread Fox, John
Dear Jihee,

Your latest attempt has gotten farther than the previous one but has produced a 
different error. The command to read the data set was generated properly. You 
can see whether the data set was in fact read by typing prestige (the name you 
gave to the data set) at the > command prompt in the R console. Assuming that 
the data set was read, an error occurred when the Rcmdr tried to make it the 
active data set. I'm afraid that I don't understand how this could happen 
because this procedure works correctly for me and for others. The underlying 
code is invoked whenever the Rcmdr reads a dara set.

I suggest that you try two additional things:

(1) I noticed that you loaded the FactoMineR and SensoMineR plug-ins. Try again 
without loading these plug-ins.

(2) Download and try reading the plain-text data file from 
, using 
"Data > Import data > From text file, clipboard, or URL"; you can take all of 
the defaults in the resulting dialog box.

If neither of these works then I'm afraid that I'm out of ideas. There's 
something peculiar about your R installation that I can't detect.

Best,
 John



> On Jan 17, 2019, at 12:24 AM, 우지희  wrote:
> 
> Dear John,
>  
> I tried with your file. R commander could read the file but there's still no 
> active dataset
>  
> Anyway I'll send my file, too
>  
> Jihee
>  
> <528c421a382d426895f6446b32fbc6f0.png>
>  
> From: "Fox, John" 
> Sent: Thursday, January 17, 2019 2:09:52 PM
> To:"우지희" 
> Cc:"" 
> Subject:Re: [R] importing data error question
>  
>  
> Dear Jihee,
> 
> This appears to be a different problem. You were apparently able to access 
> the spreadsheet file, but the R Commander didn't find a suitable worksheet in 
> it.
> 
> Try downloading and reading the file at 
> . If 
> that works, send me privately (i.e., directly) your Excel spreadsheet file 
> and I'll take a look at it.
> 
> Best,
> John
> 
> > On Jan 16, 2019, at 9:49 PM, 우지희  wrote:
> > 
> > Dear John,
> >  
> > now i can use english thank you very much!!
> >  
> > um.. but nothing's changed... with that {r} message at R Markdown.
> >  
> > There's no dataset.
> >  
> > i tried both .xls and .xlsx .
> >  
> >  
> > Jihee
> >  
> >  
> >  
> > 
> >  
> >  
> >  
> > From: "Fox, John" 
> > Sent: Thursday, January 17, 2019 10:59:44 AM
> > To:"우지희" 
> > Cc:"" 
> > Subject:Re: [R] importing data error question
> >  
> >  
> > Dear Jihee,
> > 
> > Probably the easiest way to change the language to English temporarily in R 
> > is to enter the command
> > 
> > Sys.setenv(LANGUAGE="en")
> > 
> > at the R command prompt prior to loading the Rcmdr package.
> > 
> > I hope that this helps,
> > John
> > 
> > 
> > > On Jan 16, 2019, at 7:02 PM, 우지희  wrote:
> > > 
> > > Thanks for your help!
> > >  
> > > I was having trouble with finding how to use english...
> > >  
> > > Even though I try to use english language, I couldn't change language of 
> > > R commander. (it is still korean)
> > >  
> > > Sorry but.. do you know how to change language of "R commander"? I have 
> > > no idea why it doesn't change.
> > >  
> > > Best,
> > > Jihee
> > >  
> > > From: "Fox, John" 
> > > Sent: Thursday, January 17, 2019 1:59:03 AM
> > > To:"우지희" 
> > > Cc:"r-help@r-project.org" 
> > > Subject:Re: [R] importing data error question
> > >  
> > >  
> > > Dear jihee,
> > > 
> > > I've looked into this problem further, using my Mac where it's easier to 
> > > temporarily change languages and character sets than on Windows, and I 
> > > discovered the following:
> > > 
> > > I was able to duplicate your problem with importing Excel files when 
> > > working in Korean. There's a similar problem with the import SAS b7dat 
> > > files but not with the other file-import dialogs.
> > > 
> > > I observed a similar problem when working in Chinese (LANG="zh") but not 
> > > in simplified Chinese (zh_CN) or Japanese (ja), so the problem isn't 
> > > simply with non-Latin character sets. There is no problem in English, 
> > > Spanish (es), or French (fr), and I didn't check the other languages into 
> > > which the Rcmdr is translated.
> > > 
> > > I think that the problem originates in the Korean and Chinese translation 
> > > files and I'll contact the translators to see whether they can fix it.
> > > 
> > > Thank you for reporting this issue.
> > > 
> > > John
> > > 
> > > > On Jan 14, 2019, at 11:36 PM, Fox, John  wrote:
> > > > 
> > > > Dear jihee,
> > > > 
> > > >> On Jan 14, 2019, at 9:00 PM, 우지희  wrote:
> > > >> 
> > > >> You said previously that you were using a Mac, so I'm surprised that 
> > > >> you now say that you're using Windows. I don't have a Windows 7 
> > > >> system, but I can confirm that importing from Excel files works 
> > > >> perfectly fine under Windows 10, as I just verified, and I'd be 
> > > >> surprised if the Windows version matters. 
> > > >> 
> > 

Re: [R] importing data error question

2019-01-16 Thread Fox, John
Dear Jihee,

This appears to be a different problem. You were  apparently able to access the 
spreadsheet file, but the R Commander didn't find a suitable worksheet in it.

Try downloading and reading the file at 
. If 
that works, send me privately (i.e., directly) your Excel spreadsheet file and 
I'll take a look at it.

Best,
 John

> On Jan 16, 2019, at 9:49 PM, 우지희  wrote:
> 
> Dear John,
>  
> now i can use english thank you very much!!
>  
> um.. but nothing's changed... with that {r} message at R Markdown.
>  
> There's no dataset.
>  
> i tried both .xls and .xlsx .
>  
>  
> Jihee
>  
>  
>  
> 
>  
>  
>  
> From: "Fox, John" 
> Sent: Thursday, January 17, 2019 10:59:44 AM
> To:"우지희" 
> Cc:"" 
> Subject:Re: [R] importing data error question
>  
>  
> Dear Jihee,
> 
> Probably the easiest way to change the language to English temporarily in R 
> is to enter the command
> 
> Sys.setenv(LANGUAGE="en")
> 
> at the R command prompt prior to loading the Rcmdr package.
> 
> I hope that this helps,
> John
> 
> 
> > On Jan 16, 2019, at 7:02 PM, 우지희  wrote:
> > 
> > Thanks for your help!
> >  
> > I was having trouble with finding how to use english...
> >  
> > Even though I try to use english language, I couldn't change language of R 
> > commander. (it is still korean)
> >  
> > Sorry but.. do you know how to change language of "R commander"? I have no 
> > idea why it doesn't change.
> >  
> > Best,
> > Jihee
> >  
> > From: "Fox, John" 
> > Sent: Thursday, January 17, 2019 1:59:03 AM
> > To:"우지희" 
> > Cc:"r-help@r-project.org" 
> > Subject:Re: [R] importing data error question
> >  
> >  
> > Dear jihee,
> > 
> > I've looked into this problem further, using my Mac where it's easier to 
> > temporarily change languages and character sets than on Windows, and I 
> > discovered the following:
> > 
> > I was able to duplicate your problem with importing Excel files when 
> > working in Korean. There's a similar problem with the import SAS b7dat 
> > files but not with the other file-import dialogs.
> > 
> > I observed a similar problem when working in Chinese (LANG="zh") but not in 
> > simplified Chinese (zh_CN) or Japanese (ja), so the problem isn't simply 
> > with non-Latin character sets. There is no problem in English, Spanish 
> > (es), or French (fr), and I didn't check the other languages into which the 
> > Rcmdr is translated.
> > 
> > I think that the problem originates in the Korean and Chinese translation 
> > files and I'll contact the translators to see whether they can fix it.
> > 
> > Thank you for reporting this issue.
> > 
> > John
> > 
> > > On Jan 14, 2019, at 11:36 PM, Fox, John  wrote:
> > > 
> > > Dear jihee,
> > > 
> > >> On Jan 14, 2019, at 9:00 PM, 우지희  wrote:
> > >> 
> > >> You said previously that you were using a Mac, so I'm surprised that you 
> > >> now say that you're using Windows. I don't have a Windows 7 system, but 
> > >> I can confirm that importing from Excel files works perfectly fine under 
> > >> Windows 10, as I just verified, and I'd be surprised if the Windows 
> > >> version matters. 
> > >> 
> > >> --> no, I never said i was using a Mac. 
> > > 
> > > Sorry, I guess I got that from the error message you originally reported, 
> > > which was "Error in structure(.External(.C_dotTclObjv, objv), class = 
> > > "tclObj") : [tcl] bad Macintosh file type "“*”"." I've never seen that 
> > > error and it seems peculiar that it would occur on a Windows system.
> > > 
> > >> 
> > >> You still haven't reported the versions of R, the Rcmdr package, and the 
> > >> other packages that you're using. The easiest way to do this is to show 
> > >> the output of the sessionInfo() command. 
> > >> 
> > >> --> sessionInfo()
> > >> R version 3.5.2 (2018-12-20)
> > >> Platform: x86_64-w64-mingw32/x64 (64-bit)
> > >> Running under: Windows 7 x64 (build 7601) Service Pack 1
> > >> 
> > >> Matrix products: default
> > >> 
> > >> locale:
> > >> [1] LC_COLLATE=Korean_Korea.949 LC_CTYPE=Korean_Korea.949  
> > >> [3] LC_MONETARY=Korean_Korea.949 LC_NUMERIC=C  
> > >> [5] LC_TIME=Korean_Korea.949  
> > >> 
> > >> attached base packages:
> > >> [1] tcltk splines stats graphics grDevices utils datasets methods  
> > >> [9] base  
> > >> 
> > >> other attached packages:
> > >> [1] RcmdrPlugin.SensoMineR_1.11-01 RcmdrPlugin.FactoMineR_1.6-0  
> > >> [3] Rcmdr_2.5-1 effects_4.1-0  
> > >> [5] RcmdrMisc_2.5-1 sandwich_2.5-0  
> > >> [7] car_3.0-2 carData_3.0-2  
> > >> [9] SensoMineR_1.23 FactoMineR_1.41  
> > >> 
> > >> loaded via a namespace (and not attached):
> > >> [1] gtools_3.8.1 Formula_1.2-3 latticeExtra_0.6-28 
> > >> [4] cellranger_1.1.0 pillar_1.3.1 backports_1.1.3  
> > >> [7] lattice_0.20-38 digest_0.6.18 RColorBrewer_1.1-2  
> > >> [10] checkmate_1.8.5 minqa_1.2.4 colorspace_1.3-2  
> > >> [13] survey_3.35 htmltools_0.3.6 Matrix_1.2-15  
> > >> [16] plyr_1.8.4 pkgconfig_2.0.2 haven_2.0.0  
> > >> [19] 

Re: [R] importing data error question

2019-01-16 Thread Fox, John
Dear Jihee,

Probably the easiest way to change the language to English temporarily in R is 
to enter the command

Sys.setenv(LANGUAGE="en")

at the R command prompt prior to loading the Rcmdr package.

I hope that this helps,
 John


> On Jan 16, 2019, at 7:02 PM, 우지희  wrote:
> 
> Thanks for your help!
>  
> I was having trouble with finding how to use english...
>  
> Even though I try to use english language, I couldn't change language of R 
> commander. (it is still korean)
>  
> Sorry but.. do you know how to change language of "R commander"? I have no 
> idea why it doesn't change.
>  
> Best,
> Jihee
>  
> From: "Fox, John" 
> Sent: Thursday, January 17, 2019 1:59:03 AM
> To:"우지희" 
> Cc:"r-help@r-project.org" 
> Subject:Re: [R] importing data error question
>  
>  
> Dear jihee,
> 
> I've looked into this problem further, using my Mac where it's easier to 
> temporarily change languages and character sets than on Windows, and I 
> discovered the following:
> 
> I was able to duplicate your problem with importing Excel files when working 
> in Korean. There's a similar problem with the import SAS b7dat files but not 
> with the other file-import dialogs.
> 
> I observed a similar problem when working in Chinese (LANG="zh") but not in 
> simplified Chinese (zh_CN) or Japanese (ja), so the problem isn't simply with 
> non-Latin character sets. There is no problem in English, Spanish (es), or 
> French (fr), and I didn't check the other languages into which the Rcmdr is 
> translated.
> 
> I think that the problem originates in the Korean and Chinese translation 
> files and I'll contact the translators to see whether they can fix it.
> 
> Thank you for reporting this issue.
> 
> John
> 
> > On Jan 14, 2019, at 11:36 PM, Fox, John  wrote:
> > 
> > Dear jihee,
> > 
> >> On Jan 14, 2019, at 9:00 PM, 우지희  wrote:
> >> 
> >> You said previously that you were using a Mac, so I'm surprised that you 
> >> now say that you're using Windows. I don't have a Windows 7 system, but I 
> >> can confirm that importing from Excel files works perfectly fine under 
> >> Windows 10, as I just verified, and I'd be surprised if the Windows 
> >> version matters. 
> >> 
> >> --> no, I never said i was using a Mac. 
> > 
> > Sorry, I guess I got that from the error message you originally reported, 
> > which was "Error in structure(.External(.C_dotTclObjv, objv), class = 
> > "tclObj") : [tcl] bad Macintosh file type "“*”"." I've never seen that 
> > error and it seems peculiar that it would occur on a Windows system.
> > 
> >> 
> >> You still haven't reported the versions of R, the Rcmdr package, and the 
> >> other packages that you're using. The easiest way to do this is to show 
> >> the output of the sessionInfo() command. 
> >> 
> >> --> sessionInfo()
> >> R version 3.5.2 (2018-12-20)
> >> Platform: x86_64-w64-mingw32/x64 (64-bit)
> >> Running under: Windows 7 x64 (build 7601) Service Pack 1
> >> 
> >> Matrix products: default
> >> 
> >> locale:
> >> [1] LC_COLLATE=Korean_Korea.949 LC_CTYPE=Korean_Korea.949  
> >> [3] LC_MONETARY=Korean_Korea.949 LC_NUMERIC=C  
> >> [5] LC_TIME=Korean_Korea.949  
> >> 
> >> attached base packages:
> >> [1] tcltk splines stats graphics grDevices utils datasets methods  
> >> [9] base  
> >> 
> >> other attached packages:
> >> [1] RcmdrPlugin.SensoMineR_1.11-01 RcmdrPlugin.FactoMineR_1.6-0  
> >> [3] Rcmdr_2.5-1 effects_4.1-0  
> >> [5] RcmdrMisc_2.5-1 sandwich_2.5-0  
> >> [7] car_3.0-2 carData_3.0-2  
> >> [9] SensoMineR_1.23 FactoMineR_1.41  
> >> 
> >> loaded via a namespace (and not attached):
> >> [1] gtools_3.8.1 Formula_1.2-3 latticeExtra_0.6-28 
> >> [4] cellranger_1.1.0 pillar_1.3.1 backports_1.1.3  
> >> [7] lattice_0.20-38 digest_0.6.18 RColorBrewer_1.1-2  
> >> [10] checkmate_1.8.5 minqa_1.2.4 colorspace_1.3-2  
> >> [13] survey_3.35 htmltools_0.3.6 Matrix_1.2-15  
> >> [16] plyr_1.8.4 pkgconfig_2.0.2 haven_2.0.0  
> >> [19] scales_1.0.0 openxlsx_4.1.0 rio_0.5.16  
> >> [22] lme4_1.1-19 htmlTable_1.13.1 tibble_1.4.2  
> >> [25] relimp_1.0-5 ggplot2_3.1.0 nnet_7.3-12  
> >> [28] lazyeval_0.2.1 survival_2.43-3 magrittr_1.5  
> >> [31] crayon_1.3.4 readxl_1.2.0 nlme_3.1-137  
> >> [34] MASS_7.3-51.1 forcats_0.3.0 foreign_0.8-71  
> >> [37] class_7.3-14 tools_3.5.2 data.table_1.11.8  
> >> [40] hms_0.4.2 tcltk2_1.2-11 stringr_1.3.1  
> >> [43] munsell_0.5.0 cluster_2.0.7-1 zip_1.0.0  
> >> [46] flashClust_1.01-2 compiler_3.5.2 e1071_1.7-0  
> >> [49] rlang_0.3.1 grid_3.5.2 nloptr_1.2.1  
> >> [52] rstudioapi_0.9.0 htmlwidgets_1.3 leaps_3.0  
> >> [55] base64enc_0.1-3 gtable_0.2.0 abind_1.4-5  
> >> [58] curl_3.2 reshape2_1.4.3 AlgDesign_1.1-7.3  
> >> [61] gridExtra_2.3 zoo_1.8-4 knitr_1.21  
> >> [64] nortest_1.0-4 Hmisc_4.1-1 KernSmooth_2.23-15  
> >> [67] stringi_1.2.4 Rcpp_1.0.0 rpart_4.1-13  
> >> [70] acepack_1.4.1 scatterplot3d_0.3-41 xfun_0.4  
> >> 
> >> This was the status that I tried to import Excel data. 
> > 
> > These packages seem up-to-date.
> > 
> >> 
> 

Re: [R] importing data error question

2019-01-16 Thread Fox, John
Dear jihee,

I've looked into this problem further, using my Mac where it's easier to 
temporarily change languages and character sets than on Windows, and I 
discovered the following:

I was able to duplicate your problem with importing Excel files when working in 
Korean. There's a similar problem with the import SAS b7dat files but not with 
the other file-import dialogs.

I observed a similar problem when working in Chinese (LANG="zh") but not in 
simplified Chinese (zh_CN) or Japanese (ja), so the problem isn't simply with 
non-Latin character sets. There is no problem in English, Spanish (es), or 
French (fr), and I didn't check the other languages into which the Rcmdr is 
translated.

I think that the problem originates in the Korean and Chinese translation files 
and I'll contact the translators to see whether they can fix it.

Thank you for reporting this issue.

John

> On Jan 14, 2019, at 11:36 PM, Fox, John  wrote:
> 
> Dear jihee,
> 
>> On Jan 14, 2019, at 9:00 PM, 우지희  wrote:
>> 
>> You said previously that you were using a Mac, so I'm surprised that you now 
>> say that you're using Windows. I don't have a Windows 7 system, but I can 
>> confirm that importing from Excel files works perfectly fine under Windows 
>> 10, as I just verified, and I'd be surprised if the Windows version matters. 
>> 
>> --> no, I never said i was using a Mac. 
> 
> Sorry, I guess I got that from the error message you originally reported, 
> which was "Error in structure(.External(.C_dotTclObjv, objv), class = 
> "tclObj") : [tcl] bad Macintosh file type "“*”"." I've never seen that error 
> and it seems peculiar that it would occur on a Windows system.
> 
>> 
>> You still haven't reported the versions of R, the Rcmdr package, and the 
>> other packages that you're using. The easiest way to do this is to show the 
>> output of the sessionInfo() command. 
>> 
>> --> sessionInfo()
>> R version 3.5.2 (2018-12-20)
>> Platform: x86_64-w64-mingw32/x64 (64-bit)
>> Running under: Windows 7 x64 (build 7601) Service Pack 1
>> 
>> Matrix products: default
>> 
>> locale:
>> [1] LC_COLLATE=Korean_Korea.949  LC_CTYPE=Korean_Korea.949   
>> [3] LC_MONETARY=Korean_Korea.949 LC_NUMERIC=C
>> [5] LC_TIME=Korean_Korea.949
>> 
>> attached base packages:
>> [1] tcltk splines   stats graphics  grDevices utils datasets  
>> methods  
>> [9] base 
>> 
>> other attached packages:
>> [1] RcmdrPlugin.SensoMineR_1.11-01 RcmdrPlugin.FactoMineR_1.6-0  
>> [3] Rcmdr_2.5-1effects_4.1-0 
>> [5] RcmdrMisc_2.5-1sandwich_2.5-0
>> [7] car_3.0-2  carData_3.0-2 
>> [9] SensoMineR_1.23FactoMineR_1.41   
>> 
>> loaded via a namespace (and not attached):
>> [1] gtools_3.8.1 Formula_1.2-3latticeExtra_0.6-28 
>> [4] cellranger_1.1.0 pillar_1.3.1 backports_1.1.3 
>> [7] lattice_0.20-38  digest_0.6.18RColorBrewer_1.1-2  
>> [10] checkmate_1.8.5  minqa_1.2.4  colorspace_1.3-2
>> [13] survey_3.35  htmltools_0.3.6  Matrix_1.2-15   
>> [16] plyr_1.8.4   pkgconfig_2.0.2  haven_2.0.0 
>> [19] scales_1.0.0 openxlsx_4.1.0   rio_0.5.16  
>> [22] lme4_1.1-19  htmlTable_1.13.1 tibble_1.4.2
>> [25] relimp_1.0-5 ggplot2_3.1.0nnet_7.3-12 
>> [28] lazyeval_0.2.1   survival_2.43-3  magrittr_1.5
>> [31] crayon_1.3.4 readxl_1.2.0 nlme_3.1-137
>> [34] MASS_7.3-51.1forcats_0.3.0foreign_0.8-71  
>> [37] class_7.3-14 tools_3.5.2  data.table_1.11.8   
>> [40] hms_0.4.2tcltk2_1.2-11stringr_1.3.1   
>> [43] munsell_0.5.0cluster_2.0.7-1  zip_1.0.0   
>> [46] flashClust_1.01-2compiler_3.5.2   e1071_1.7-0 
>> [49] rlang_0.3.1  grid_3.5.2   nloptr_1.2.1
>> [52] rstudioapi_0.9.0 htmlwidgets_1.3  leaps_3.0   
>> [55] base64enc_0.1-3  gtable_0.2.0 abind_1.4-5 
>> [58] curl_3.2 reshape2_1.4.3   AlgDesign_1.1-7.3   
>> [61] gridExtra_2.3zoo_1.8-4knitr_1.21  
>> [64] nortest_1.0-4Hmisc_4.1-1  KernSmooth_2.23-15  
>> [67] stringi_1.2.4Rcpp_1.0.0   rpart_4.1-13
>> [70] acepack_1.4.1scatterplot3d_0.3-41 xfun_0.4
>> 
>> This was the status that I tried to import Excel data. 
> 
> These packages seem up-to-date.
> 
>> 
>> Also, have you tried importing an Excel file in the Rcmdr *without* the two 
>> plug-in packages loaded, as I suggested in my original response?  
>> 
>> --> I tried without plug-in packages, but It didn't work. 
> 
> OK, so you tried the setup that works for me and, I assume from the lack of 
> similar error reports, for others.
> 
>> 
>> It occurs to me that the 

Re: [R] importing data error question

2019-01-14 Thread Fox, John
Dear jihee,

> On Jan 14, 2019, at 9:00 PM, 우지희  wrote:
> 
> You said previously that you were using a Mac, so I'm surprised that you now 
> say that you're using Windows. I don't have a Windows 7 system, but I can 
> confirm that importing from Excel files works perfectly fine under Windows 
> 10, as I just verified, and I'd be surprised if the Windows version matters. 
> 
> --> no, I never said i was using a Mac. 

Sorry, I guess I got that from the error message you originally reported, which 
was "Error in structure(.External(.C_dotTclObjv, objv), class = "tclObj") : 
[tcl] bad Macintosh file type "“*”"." I've never seen that error and it seems 
peculiar that it would occur on a Windows system.

> 
> You still haven't reported the versions of R, the Rcmdr package, and the 
> other packages that you're using. The easiest way to do this is to show the 
> output of the sessionInfo() command. 
> 
> --> sessionInfo()
> R version 3.5.2 (2018-12-20)
> Platform: x86_64-w64-mingw32/x64 (64-bit)
> Running under: Windows 7 x64 (build 7601) Service Pack 1
> 
> Matrix products: default
> 
> locale:
> [1] LC_COLLATE=Korean_Korea.949  LC_CTYPE=Korean_Korea.949   
> [3] LC_MONETARY=Korean_Korea.949 LC_NUMERIC=C
> [5] LC_TIME=Korean_Korea.949
> 
> attached base packages:
> [1] tcltk splines   stats graphics  grDevices utils datasets  
> methods  
> [9] base 
> 
> other attached packages:
>  [1] RcmdrPlugin.SensoMineR_1.11-01 RcmdrPlugin.FactoMineR_1.6-0  
>  [3] Rcmdr_2.5-1effects_4.1-0 
>  [5] RcmdrMisc_2.5-1sandwich_2.5-0
>  [7] car_3.0-2  carData_3.0-2 
>  [9] SensoMineR_1.23FactoMineR_1.41   
> 
> loaded via a namespace (and not attached):
>  [1] gtools_3.8.1 Formula_1.2-3latticeExtra_0.6-28 
>  [4] cellranger_1.1.0 pillar_1.3.1 backports_1.1.3 
>  [7] lattice_0.20-38  digest_0.6.18RColorBrewer_1.1-2  
> [10] checkmate_1.8.5  minqa_1.2.4  colorspace_1.3-2
> [13] survey_3.35  htmltools_0.3.6  Matrix_1.2-15   
> [16] plyr_1.8.4   pkgconfig_2.0.2  haven_2.0.0 
> [19] scales_1.0.0 openxlsx_4.1.0   rio_0.5.16  
> [22] lme4_1.1-19  htmlTable_1.13.1 tibble_1.4.2
> [25] relimp_1.0-5 ggplot2_3.1.0nnet_7.3-12 
> [28] lazyeval_0.2.1   survival_2.43-3  magrittr_1.5
> [31] crayon_1.3.4 readxl_1.2.0 nlme_3.1-137
> [34] MASS_7.3-51.1forcats_0.3.0foreign_0.8-71  
> [37] class_7.3-14 tools_3.5.2  data.table_1.11.8   
> [40] hms_0.4.2tcltk2_1.2-11stringr_1.3.1   
> [43] munsell_0.5.0cluster_2.0.7-1  zip_1.0.0   
> [46] flashClust_1.01-2compiler_3.5.2   e1071_1.7-0 
> [49] rlang_0.3.1  grid_3.5.2   nloptr_1.2.1
> [52] rstudioapi_0.9.0 htmlwidgets_1.3  leaps_3.0   
> [55] base64enc_0.1-3  gtable_0.2.0 abind_1.4-5 
> [58] curl_3.2 reshape2_1.4.3   AlgDesign_1.1-7.3   
> [61] gridExtra_2.3zoo_1.8-4knitr_1.21  
> [64] nortest_1.0-4Hmisc_4.1-1  KernSmooth_2.23-15  
> [67] stringi_1.2.4Rcpp_1.0.0   rpart_4.1-13
> [70] acepack_1.4.1scatterplot3d_0.3-41 xfun_0.4
> 
> This was the status that I tried to import Excel data. 

These packages seem up-to-date.

> 
> Also, have you tried importing an Excel file in the Rcmdr *without* the two 
> plug-in packages loaded, as I suggested in my original response?  
> 
> --> I tried without plug-in packages, but It didn't work. 

OK, so you tried the setup that works for me and, I assume from the lack of 
similar error reports, for others.

> 
> It occurs to me that the problem may be produced by using the Rcmdr under R 
> with a non-Latin set, but if that were the case I would have expected the 
> problem to have surfaced earlier. Did you try reading another kind of file, 
> such as a plain-text data file? 
> 
> --> I don't know what is plain-text data file. 

A plain-text data file could, e.g., be created from an Excel file by exporting 
a worksheet as a .csv (comma-separated-values) file; you could read this into 
the Rcmdr via Data > Import data > from text file, specifying the field 
separator as commas.

> 
> i'll try R with English. 

I'm curious to see what happens.

Best,
 John

> 
> From:  "Fox, John"  
> 
> Sent: Monday, January 14, 2019 11:15:36 PM 
> 
> To:"우지희"  
> 
> Cc:""  
> 
> Subject:Re: [R] importing data error question 
> 
>Dear jihee,
> 
>> On Jan 13, 2019, at 9:28 PM, 우지희  wrote:
>> 
>> 
>> 
>> From: "우지희" 
>> Sent: Monday, January 14, 2019 9:40:26 AM
>> To:"Fox, John" 
>> Subject:Re: [R] importing data error question
>> 
>> 
>> Thanks for your replies.
>> 

Re: [R] importing data error question

2019-01-14 Thread 우지희
You said previously that you were using a Mac, so I'm surprised that you now 
say that you're using Windows. I don't have a Windows 7 system, but I can 
confirm that importing from Excel files works perfectly fine under Windows 10, 
as I just verified, and I'd be surprised if the Windows version matters. 

--> no, I never said i was using a Mac. 

You still haven't reported the versions of R, the Rcmdr package, and the other 
packages that you're using. The easiest way to do this is to show the output of 
the sessionInfo() command. 

--> sessionInfo()
 R version 3.5.2 (2018-12-20)
 Platform: x86_64-w64-mingw32/x64 (64-bit)
 Running under: Windows 7 x64 (build 7601) Service Pack 1

 Matrix products: default

 locale:
 [1] LC_COLLATE=Korean_Korea.949  LC_CTYPE=Korean_Korea.949   
 [3] LC_MONETARY=Korean_Korea.949 LC_NUMERIC=C                
 [5] LC_TIME=Korean_Korea.949    

 attached base packages:
 [1] tcltk     splines   stats     graphics  grDevices utils     datasets  
methods  
 [9] base     

 other attached packages:
  [1] RcmdrPlugin.SensoMineR_1.11-01 RcmdrPlugin.FactoMineR_1.6-0  
  [3] Rcmdr_2.5-1                    effects_4.1-0                 
  [5] RcmdrMisc_2.5-1                sandwich_2.5-0                
  [7] car_3.0-2                      carData_3.0-2                 
  [9] SensoMineR_1.23                FactoMineR_1.41               

 loaded via a namespace (and not attached):
  [1] gtools_3.8.1         Formula_1.2-3        latticeExtra_0.6-28 
  [4] cellranger_1.1.0     pillar_1.3.1         backports_1.1.3     
  [7] lattice_0.20-38      digest_0.6.18        RColorBrewer_1.1-2  
 [10] checkmate_1.8.5      minqa_1.2.4          colorspace_1.3-2    
 [13] survey_3.35          htmltools_0.3.6      Matrix_1.2-15       
 [16] plyr_1.8.4           pkgconfig_2.0.2      haven_2.0.0         
 [19] scales_1.0.0         openxlsx_4.1.0       rio_0.5.16          
 [22] lme4_1.1-19          htmlTable_1.13.1     tibble_1.4.2        
 [25] relimp_1.0-5         ggplot2_3.1.0        nnet_7.3-12         
 [28] lazyeval_0.2.1       survival_2.43-3      magrittr_1.5        
 [31] crayon_1.3.4         readxl_1.2.0         nlme_3.1-137        
 [34] MASS_7.3-51.1        forcats_0.3.0        foreign_0.8-71      
 [37] class_7.3-14         tools_3.5.2          data.table_1.11.8   
 [40] hms_0.4.2            tcltk2_1.2-11        stringr_1.3.1       
 [43] munsell_0.5.0        cluster_2.0.7-1      zip_1.0.0           
 [46] flashClust_1.01-2    compiler_3.5.2       e1071_1.7-0         
 [49] rlang_0.3.1          grid_3.5.2           nloptr_1.2.1        
 [52] rstudioapi_0.9.0     htmlwidgets_1.3      leaps_3.0           
 [55] base64enc_0.1-3      gtable_0.2.0         abind_1.4-5         
 [58] curl_3.2             reshape2_1.4.3       AlgDesign_1.1-7.3   
 [61] gridExtra_2.3        zoo_1.8-4            knitr_1.21          
 [64] nortest_1.0-4        Hmisc_4.1-1          KernSmooth_2.23-15  
 [67] stringi_1.2.4        Rcpp_1.0.0           rpart_4.1-13        
 [70] acepack_1.4.1        scatterplot3d_0.3-41 xfun_0.4            

This was the status that I tried to import Excel data. 

Also, have you tried importing an Excel file in the Rcmdr *without* the two 
plug-in packages loaded, as I suggested in my original response?  

--> I tried without plug-in packages, but It didn't work. 

 It occurs to me that the problem may be produced by using the Rcmdr under R 
with a non-Latin set, but if that were the case I would have expected the 
problem to have surfaced earlier. Did you try reading another kind of file, 
such as a plain-text data file? 

--> I don't know what is plain-text data file. 

i'll try R with English. 

From:  "Fox, John"  

Sent: Monday, January 14, 2019 11:15:36 PM 

To:"우지희"  

Cc:""  

Subject:Re: [R] importing data error question 

   Dear jihee,

  > On Jan 13, 2019, at 9:28 PM, 우지희  wrote:
  > 
  > 
  > 
  > From: "우지희" 
  > Sent: Monday, January 14, 2019 9:40:26 AM
  > To:"Fox, John" 
  > Subject:Re: [R] importing data error question
  > 
  > 
  > Thanks for your replies.
  > 
  > I'm using windows 7, I loaded FactoMineR,

 You said previously that you were using a Mac, so I'm surprised that you now 
say that you're using Windows. I don't have a Windows 7 system, but I can 
confirm that importing from Excel files works perfectly fine under Windows 10, 
as I just verified, and I'd be surprised if the Windows version matters.

  > SensoMineR and then Rcmdr. (Downloaded FacroMineR, SensoMineR, Rcmdr, 
Rcmdrplugin.FactomineR, Rcmdrplugin.SensomineR and other required packages that 
downloaded automatically)
  > This problem occurred when I select Data > Import data > From Excel file.
  > I checked FactoMineR and SensoMineR packages are loaded and using..

  You still haven't reported the versions of R, the Rcmdr package, and the 
other packages that you're using. The easiest way to do this is to show the 
output of the sessionInfo() command.

  Also, have you tried importing an Excel 

Re: [R] importing data error question

2019-01-14 Thread Fox, John
Dear jihee,

> On Jan 13, 2019, at 9:28 PM, 우지희  wrote:
> 
>  
>  
> From: "우지희" 
> Sent: Monday, January 14, 2019 9:40:26 AM
> To:"Fox, John" 
> Subject:Re: [R] importing data error question
>  
>  
> Thanks for your replies.
>  
> I'm using windows 7, I loaded FactoMineR,

You said previously that you were using a Mac, so I'm surprised that you now 
say that you're using Windows. I don't have a Windows 7 system, but I can 
confirm that importing from Excel files works perfectly fine under Windows 10, 
as I just verified, and I'd be surprised if the Windows version matters.

> SensoMineR and then Rcmdr. (Downloaded FacroMineR, SensoMineR, Rcmdr, 
> Rcmdrplugin.FactomineR, Rcmdrplugin.SensomineR and other required packages 
> that downloaded automatically)
> This problem occurred when I select Data > Import data > From Excel file.
> I checked FactoMineR and SensoMineR packages are loaded and using..

You still haven't reported the versions of R, the Rcmdr package, and the other 
packages that you're using. The easiest way to do this is to show the output of 
the sessionInfo() command.

Also, have you tried importing an Excel file in the Rcmdr *without* the two 
plug-in packages loaded, as I suggested in my original response? 

It occurs to me that the problem may be produced by using the Rcmdr under R 
with a non-Latin set, but if that were the case I would have expected the 
problem to have surfaced earlier. Did you try reading another kind of file, 
such as a plain-text data file?

Best,
 John

>  
>  
>  
> From: "Fox, John" 
> Sent: Friday, January 11, 2019 10:48:38 PM
> To:"PIKAL Petr" 
> Cc:"우지희" ; "r-help@R-project.org" 
> Subject:Re: [R] importing data error question
>  
>  
> Dear Petr and jihee,
> 
> The Rcmdr can import Excel files, and as I just verified, it can do so on a 
> Mac listing files of all types (*) in the open-file dialog box (which is the 
> default). 
> 
> So, as Petr suggests, more information is required to help you, including the 
> versions of macOS, R, and all packages you have loaded. In particular, does 
> the problem occur when you try to read the Excel file *without* FactoMineR 
> and SensoMineR loaded? Also, when the does problem occur -- immediately when 
> you select Data > Import data > From Excel file, or at some other point?
> 
> Best,
> John
> 
> -
> John Fox, Professor Emeritus
> McMaster University
> Hamilton, Ontario, Canada
> Web: http::/socserv.mcmaster.ca/jfox
> 
> > On Jan 11, 2019, at 5:07 AM, PIKAL Petr  wrote:
> > 
> > Hi
> > 
> > I do not use Rcmdr but from documentation it seems to me that it does not 
> > have much to do with importing data from Excel.
> > 
> > So without some additional info from your side (at least used commands) you 
> > hardly get any reasonable answer.
> > 
> > Cheers
> > Petr
> > 
> >> -Original Message-
> >> From: R-help  On Behalf Of ???
> >> Sent: Friday, January 11, 2019 9:14 AM
> >> To: r-help@R-project.org
> >> Subject: [R] importing data error question
> >> 
> >> Hi I'm jihee and I have a question about error...
> >> 
> >> I'm using R 3.5.2 and tried to use Rcmdr package.
> >> 
> >> and using FactoMineR and SensoMineR to analyze sensory data through PCA
> >> 
> >> but i can't import excel data with Rcmdr.
> >> 
> >> it has this messege :
> >> 
> >> Error in structure(.External(.C_dotTclObjv, objv), class = "tclObj") :
> >> [tcl] bad Macintosh file type "“*”"
> >> 
> >> what is wrong with my R??? T_T
> >> 
> >> Thanks for your help.
> >> 
> >> jihee.
> >> [[alternative HTML version deleted]]
> >> 
> >> __
> >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >> 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.
> > Osobní údaje: Informace o zpracování a ochraně osobních údajů obchodních 
> > partnerů PRECHEZA a.s. jsou zveřejněny na: 
> > https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ | Information about 
> > processing and protection of business partner’s personal data are available 
> > on website: https://www.precheza.cz/en/personal-data-protection-principles/
> > Důvěrnost: Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné 
> > a podléhají tomuto právně závaznému prohláąení o vyloučení odpovědnosti: 
> > https://www.precheza.cz/01-dovetek/ | This email and any documents attached 
> > to it may be confidential and are subject to the legally binding 
> > disclaimer: https://www.precheza.cz/en/01-disclaimer/
> > 
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > 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] importing data error question

2019-01-11 Thread Fox, John
Dear Petr and jihee,

The Rcmdr can import Excel files, and as I just verified, it can do so on a Mac 
listing files of all types (*) in the open-file dialog box (which is the 
default). 

So, as Petr suggests, more information is required to help you, including the 
versions of macOS, R, and all packages you have loaded. In particular, does the 
problem occur when you try to read the Excel file *without* FactoMineR and 
SensoMineR loaded? Also, when the does problem occur -- immediately when you 
select Data > Import data > From Excel file, or at some other point?

Best,
 John

  -
  John Fox, Professor Emeritus
  McMaster University
  Hamilton, Ontario, Canada
  Web: http::/socserv.mcmaster.ca/jfox

> On Jan 11, 2019, at 5:07 AM, PIKAL Petr  wrote:
> 
> Hi
> 
> I do not use Rcmdr but from documentation it seems to me that it does not 
> have much to do with importing data from Excel.
> 
> So without some additional info from your side (at least used commands) you 
> hardly get any reasonable answer.
> 
> Cheers
> Petr
> 
>> -Original Message-
>> From: R-help  On Behalf Of ???
>> Sent: Friday, January 11, 2019 9:14 AM
>> To: r-help@R-project.org
>> Subject: [R] importing data error question
>> 
>> Hi I'm jihee and I have a question about error...
>> 
>> I'm using R 3.5.2 and tried to use Rcmdr package.
>> 
>> and using FactoMineR and SensoMineR to analyze sensory data through PCA
>> 
>> but i can't import excel data with Rcmdr.
>> 
>> it has this messege :
>> 
>> Error in structure(.External(.C_dotTclObjv, objv), class = "tclObj") :
>>   [tcl] bad Macintosh file type "“*”"
>> 
>> what is wrong with my R??? T_T
>> 
>> Thanks for your help.
>> 
>> jihee.
>> [[alternative HTML version deleted]]
>> 
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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.
> Osobní údaje: Informace o zpracování a ochraně osobních údajů obchodních 
> partnerů PRECHEZA a.s. jsou zveřejněny na: 
> https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ | Information about 
> processing and protection of business partner’s personal data are available 
> on website: https://www.precheza.cz/en/personal-data-protection-principles/
> Důvěrnost: Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a 
> podléhají tomuto právně závaznému prohláąení o vyloučení odpovědnosti: 
> https://www.precheza.cz/01-dovetek/ | This email and any documents attached 
> to it may be confidential and are subject to the legally binding disclaimer: 
> https://www.precheza.cz/en/01-disclaimer/
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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 -- To UNSUBSCRIBE and more, see
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] importing data error question

2019-01-11 Thread PIKAL Petr
Hi

I do not use Rcmdr but from documentation it seems to me that it does not have 
much to do with importing data from Excel.

So without some additional info from your side (at least used commands) you 
hardly get any reasonable answer.

Cheers
Petr

> -Original Message-
> From: R-help  On Behalf Of ???
> Sent: Friday, January 11, 2019 9:14 AM
> To: r-help@R-project.org
> Subject: [R] importing data error question
>
> Hi I'm jihee and I have a question about error...
>
> I'm using R 3.5.2 and tried to use Rcmdr package.
>
> and using FactoMineR and SensoMineR to analyze sensory data through PCA
>
> but i can't import excel data with Rcmdr.
>
> it has this messege :
>
> Error in structure(.External(.C_dotTclObjv, objv), class = "tclObj") :
>[tcl] bad Macintosh file type "“*”"
>
> what is wrong with my R??? T_T
>
> Thanks for your help.
>
> jihee.
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
Osobní údaje: Informace o zpracování a ochraně osobních údajů obchodních 
partnerů PRECHEZA a.s. jsou zveřejněny na: 
https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ | Information about 
processing and protection of business partner’s personal data are available on 
website: https://www.precheza.cz/en/personal-data-protection-principles/
Důvěrnost: Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a 
podléhají tomuto právně závaznému prohláąení o vyloučení odpovědnosti: 
https://www.precheza.cz/01-dovetek/ | This email and any documents attached to 
it may be confidential and are subject to the legally binding disclaimer: 
https://www.precheza.cz/en/01-disclaimer/

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Importing data from a text file with no separator

2016-06-09 Thread Duncan Murdoch

On 09/06/2016 8:56 AM, Federman, Douglas wrote:

?read.fwf

There is a data import/export document on cran.r-project.org


And included with R distributions.  It's one of the manuals, and will be 
accessible via the help menu in front ends that have one.


Duncan Murdoch





-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Paolo Letizia
Sent: Wednesday, June 08, 2016 8:40 PM
To: r-help@r-project.org
Subject: [R] Importing data from a text file with no separator

I have row data in a text file, where each row consists of 22 numerical 
characters. Each row consists of three different column but there is no 
separator. Specifically, the first two characters of the raw represent  the 
first column of data, the subsequent 8 characters represent the second column 
of data and the last 12 characters represent the third column of data. An 
example follows:

row data:
10030614911608

The first two characters, "10", is the column "Regime"; the subsequent 8 characters, "03061490", is 
the column "Industry", and the last 12 characters, "00011608", is the column dollar value. How do I 
import the column data into R without having any separator in the text file?
Thanks for your help, Paolo.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 
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 -- To UNSUBSCRIBE and more, see
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 -- To UNSUBSCRIBE and more, see
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] Importing data from a text file with no separator

2016-06-09 Thread Federman, Douglas
?read.fwf

There is a data import/export document on cran.r-project.org 



-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Paolo Letizia
Sent: Wednesday, June 08, 2016 8:40 PM
To: r-help@r-project.org
Subject: [R] Importing data from a text file with no separator

I have row data in a text file, where each row consists of 22 numerical 
characters. Each row consists of three different column but there is no 
separator. Specifically, the first two characters of the raw represent  the 
first column of data, the subsequent 8 characters represent the second column 
of data and the last 12 characters represent the third column of data. An 
example follows:

row data:
10030614911608

The first two characters, "10", is the column "Regime"; the subsequent 8 
characters, "03061490", is the column "Industry", and the last 12 characters, 
"00011608", is the column dollar value. How do I import the column data 
into R without having any separator in the text file?
Thanks for your help, Paolo.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 
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 -- To UNSUBSCRIBE and more, see
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] Importing data from a text file with no separator

2016-06-08 Thread Adrian Dușa
See:
?read.fwf

Example:
> ff <- tempfile()
> cat(file = ff, "10030614911608", "10030614911608", sep =
"\n")

> read.fwf(ff, widths = c(2,8,10), colClasses = "character")
  V1   V2 V3
1 10 03061490 000116
2 10 03061490 000116

> unlink(ff)

Hth,
Adrian


On Thu, Jun 9, 2016 at 3:40 AM, Paolo Letizia 
wrote:

> I have row data in a text file, where each row consists of 22 numerical
> characters. Each row consists of three different column but there is no
> separator. Specifically, the first two characters of the raw represent  the
> first column of data, the subsequent 8 characters represent the second
> column of data and the last 12 characters represent the third column of
> data. An example follows:
>
> row data:
> 10030614911608
>
> The first two characters, "10", is the column "Regime"; the subsequent 8
> characters, "03061490", is the column "Industry", and the last 12
> characters, "00011608", is the column dollar value. How do I import the
> column data into R without having any separator in the text file?
> Thanks for your help, Paolo.
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>



-- 
Adrian Dusa
University of Bucharest
Romanian Social Data Archive
Soseaua Panduri nr.90
050663 Bucharest sector 5
Romania

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Importing data by targeting in filenames inside a nested list

2015-12-09 Thread PIKAL Petr
Hi

I did not see any answer so I give it a try. Your approach seems to be OK. 
However you probably need to polish your code to get the correct part of nested 
list.

> lll<-list(a=rnorm(10), b= list(x=1:10, y<-letters))

> lll[[1]]
 [1] -0.1876418  1.5933030 -0.1799642  0.1713959  1.1079227 -0.5885820
 [7] -1.1629393 -1.7157378 -1.5088232 -0.1150207

> lll[[2]]
$x
 [1]  1  2  3  4  5  6  7  8  9 10

[[2]]
 [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s"
[20] "t" "u" "v" "w" "x" "y" "z"

> lll[[2]][[1]]
 [1]  1  2  3  4  5  6  7  8  9 10

> lll[[2]][[2]]
 [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s"
[20] "t" "u" "v" "w" "x" "y" "z"
>

Cheers
Petr


> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of BARLAS
> Marios 247554
> Sent: Tuesday, December 08, 2015 12:30 PM
> To: r-help@r-project.org
> Subject: [R] Importing data by targeting in filenames inside a nested
> list
>
> Hello everyone,
>
> So, rookie me is trying to write a smart code, so here's what I'm
> doing:
>
> I have a list of a couple of hundrend files, some of which refer to
> different experiments.
> The naming of the file refers to the experiment and the serial number
> to the topological reference on my sample.
>
> Performing my data analysis in 1 file class at a time looks OK, so I'm
> trying to generalize my code.
> I figured out I could group them together by performing a pattern read
> on a nested list, which works for getting the file names and grouping
> them but then I'm getting some problems when I try to perform the
> import from the nested list. My code looks like this:
>
> # Vector containing file name patterns to be read and grouped together
> measurement_filenames <- c("*Q_Read_prist*", "*Quasi_Forming*",
> "*read_set#1*","*Q_Reset_pForm#1*","*read_reset#2*","*quasistatic_set*"
> , "*read_set#2*", "*quasistatic_reset#2*" )
>
> # Create a list of the files to be read in sorted in a natural fashion
> electrical_meas_files <- lapply(measurement_filenames, function(x)
> naturalsort(list.files(path, pattern=x)))
> names(electrical_meas_files) <- measurement_filenames
>
> # Perform data import for each element
>
> for(i in 1:length(measurement_filenames))
> {
>   electrical_meas_raw_data[[i]] <- lapply(electrical_meas_files[[i]],
> function(x) read.xlsx(file=x, sheetName="Data", header=TRUE,
> as.data.frame =TRUE,  stringsAsFactors = F) )
> }
>
>
>
> My idea is to come up with a nested list of the structure
> {list of different experiments}
>   {list of all sites where the experiment was run}
>   {set of dataframes with all data for each site}
>
>
> Do I make sense or am I over-complicating the situation ?
>
>
> Any ideas how I could write this piece of code or improve it ?
>
> Thanks in advance,
> Mario
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.


Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny 
pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a 
to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce 
s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným 
dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost 
žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně 
pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně 
osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi 
či osobě jím zastoupené známá.

This e-mail and any documents attached to it may be confidential and are 
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. 
Delete the contents of this e-mail with all attachments and its copies from 
your system.
If you are not the intended recipient of this e-mail, you are not authorized to 
use, disseminate, copy or disclose this e-mail in any manner.
The sender of 

Re: [R] Importing data by targeting in filenames inside a nested list

2015-12-08 Thread Ivan Calandra

Hi Mario,

It is at the limit of my skills so I'm not sure this will be a real 
solution. But it might help you anyway (and there will be more competent 
people anyway).


What does not make sense to me is why you set the names of your files 
and then use them to list them with list.files()

What don't you just do
electrical_meas_files <- list.files(path, pattern)
and define a pattern if you don't want to read all of them?

For the next step, I don't think you need to lapply() at all; it is 
already in the loop. I usually prefer loops to lapply() because I find 
it more intuitive. But your lapply() solution would work as well.


So I think that your code is somewhat redundant (but I might have missed 
something). This should do it:


#first define your output data list that will be iteratively filled, 
this will increase speed
electrical_meas_raw_data <- vector(mode="list", 
length=length(electrical_meas_files))


#then read the files (seq_along() is great)
for(i in seq_along(measurement_filenames)){
electrical_meas_raw_data[[i]] <- 
read.xlsx(file=electrical_meas_files[[i]], sheetName="Data", 
header=TRUE, as.data.frame =TRUE, stringsAsFactors = F)

}

HTH,
Ivan

--
Ivan Calandra, PhD
University of Reims Champagne-Ardenne
GEGENAA - EA 3795
CREA - 2 esplanade Roland Garros
51100 Reims, France
+33(0)3 26 77 36 89
ivan.calan...@univ-reims.fr
https://www.researchgate.net/profile/Ivan_Calandra

Le 08/12/15 12:29, BARLAS Marios 247554 a écrit :

Hello everyone,

So, rookie me is trying to write a smart code, so here's what I'm doing:

I have a list of a couple of hundrend files, some of which refer to different 
experiments.
The naming of the file refers to the experiment and the serial number to the 
topological reference on my sample.

Performing my data analysis in 1 file class at a time looks OK, so I'm trying 
to generalize my code.
I figured out I could group them together by performing a pattern read on a 
nested list, which works for getting the file names and grouping them but then 
I'm getting some problems when I try to perform the import from the nested 
list. My code looks like this:

# Vector containing file name patterns to be read and grouped together
measurement_filenames <- c("*Q_Read_prist*", "*Quasi_Forming*", 
"*read_set#1*","*Q_Reset_pForm#1*","*read_reset#2*","*quasistatic_set*", "*read_set#2*", 
"*quasistatic_reset#2*" )

# Create a list of the files to be read in sorted in a natural fashion
electrical_meas_files <- lapply(measurement_filenames, function(x) 
naturalsort(list.files(path, pattern=x)))
names(electrical_meas_files) <- measurement_filenames

# Perform data import for each element

for(i in 1:length(measurement_filenames))
{
   electrical_meas_raw_data[[i]] <- lapply(electrical_meas_files[[i]], function(x) 
read.xlsx(file=x, sheetName="Data", header=TRUE, as.data.frame =TRUE,  
stringsAsFactors = F) )
}



My idea is to come up with a nested list of the structure
{list of different experiments}
{list of all sites where the experiment was run}
{set of dataframes with all data for each site}


Do I make sense or am I over-complicating the situation ?


Any ideas how I could write this piece of code or improve it ?

Thanks in advance,
Mario

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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 -- To UNSUBSCRIBE and more, see
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] Importing data into R

2014-01-11 Thread arun
Hi,
May be this helps:
url - 
http://genome.ucsc.edu/cgi-bin/hgc?hgsid=358528009g=htcDnaNearGenei=uc003qec.4c=chr6l=133562494r=133853258o=knownGenehgSeq.promoter=onboolshad.hgSeq.promoter=0hgSeq.promoterSize=10759hgSeq.utrExon5=onboolshad.hgSeq.utrExon5=0hgSeq.cdsExon=onboolshad.hgSeq.cdsExon=0hgSeq.utrExon3=onboolshad.hgSeq.utrExon3=0hgSeq.intron=onboolshad.hgSeq.intron=0hgSeq.downstream=onboolshad.hgSeq.downstream=0hgSeq.downstreamSize=hgSeq.granularity=genehgSeq.padding5=0hgSeq.padding3=0boolshad.hgSeq.splitCDSUTR=0hgSeq.casing=upperboolshad.hgSeq.maskRepeats=0hgSeq.repMasking=lowersubmit=submit;
lines1 - readLines(url,n=-1)
length(lines1)
#[1] 6235
lines2 - lines1[-c(1:3,6235)]
 sum(nchar(lines2))
#[1] 311522
vec1 - unlist(strsplit(lines2,))
 length(vec1)
#[1] 311522
A.K.


So I have a set of data here(note: ignore the first line, the data sets from 
the second line). There are 
311,522 characters in total. I wish to import this into R such that each single 
character is in one cell, so I end up with a 311,522 by 1 column vector. 
However, when I copied the data into a text file and then 
imported that into R, each line is recognized as one single character 
and instead I end up with a column vector where each entry is the entire line 
rather than a single character. 

How can I get around this?

__
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] Importing data by odbcConnectExcel in 64 bit

2013-07-16 Thread Adams, Jean
Can't help you with the odbcConnectExcel, but I can suggest an alternative
... loadWorkbook() and readWorksheet() in the XLConnect package work on
Windows 7 64-bit.

library(XLConnect)
wb - loadWorkbook(C:/Temp/Mydata.xlsx)
dat - readWorksheet(wb, sheet=Sheet1)

Jean


On Tue, Jul 16, 2013 at 1:25 PM, Ahmed Attia ahmedati...@gmail.com wrote:

 I have probably an old question.

 I have R.3.0.1 installed in 64 bit windows 7. The odbcConnectExcel in RODBC
 library does not work. Tried odbcConnectExcel2007 still does not work.


 Any ideas.

 Thanks


 Melissa-sqlFetch(odbcConnectExcel2007(F:\\Cotton2012\\validation.xlsx),sqtable
 = Sheet3,
 + na.strings = NA, as.is = TRUE)
 Error in sqlFetch(odbcConnectExcel2007(F:\\Cotton2012\\validation.xlsx),
  :
   first argument is not an open RODBC channel
 In addition: Warning messages:
 1: In odbcDriverConnect(con, tabQuote = c([, ]), ...) :
   [RODBC] ERROR: state IM002, code 0, message [Microsoft][ODBC Driver
 Manager] Data source name not found and no default driver specified
 2: In odbcDriverConnect(con, tabQuote = c([, ]), ...) :
   ODBC connection failed
 

 Melissa-sqlFetch(odbcConnectExcel(F:\\Cotton2012\\validation.xlsx),sqtable
 = Sheet3,
 + na.strings = NA, as.is = TRUE)
 Error in odbcConnectExcel(F:\\Cotton2012\\validation.xlsx) :
   odbcConnectExcel is only usable with 32-bit Windows

 --
 Ahmed M. Attia


 Research Assistant
 Dept. Of SoilCrop Sciences
 Texas AM University
 ahmed ahmeda...@zu.edu.eg.at...@ag.tamu.edu
 Cell phone: 001-979-248-5215

 [[alternative HTML version deleted]]

 __
 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.


[[alternative HTML version deleted]]

__
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] Importing data by odbcConnectExcel in 64 bit

2013-07-16 Thread Peter Alspach
Tena koe

Perhaps the help file will give you some ideas:

odbcConnectAccess, odbcConnectDbase and odbcConnectExcel are convenience 
wrappers to generate connection strings for those file types. The files given 
can be relative to the R working directory or absolute paths (and it seems also 
relative to the user's home directory). The file name can be omitted, which 
will on Rgui bring up a dialog box to search for a file.

Note: they will only work with English-language 32-bit versions of the 
Microsoft drivers, which may or may not be installed in other locales, and are 
not usable from 64-bit R. The 2007 versions work with the drivers which are 
installed with Office 2007/2010 and give access to formats such as '*.xlsx' and 
'*.accdb'. These drivers are also available separately and there is a 64-bit 
version: see the package manual. (You must have the 32-bit drivers when using 
32-bit R and the 64-bit drivers when using 64-bit R: otherwise there will be a 
cryptic message about a driver not being found. And the 64-bit drivers cannot 
be installed alongside 32-bit Microsoft Office, and vice versa.

See the package manual for some of the peculiarities of the Excel drivers. 
readOnly = TRUE may allow very limited changes (to insert and update rows).

HTH 

Peter Alspach

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Ahmed Attia
Sent: Wednesday, 17 July 2013 6:25 a.m.
To: r-help@r-project.org
Subject: [R] Importing data by odbcConnectExcel in 64 bit

I have probably an old question.

I have R.3.0.1 installed in 64 bit windows 7. The odbcConnectExcel in RODBC 
library does not work. Tried odbcConnectExcel2007 still does not work.


Any ideas.

Thanks

Melissa-sqlFetch(odbcConnectExcel2007(F:\\Cotton2012\\validation.xlsx),sqtable
= Sheet3,
+ na.strings = NA, as.is = TRUE)
Error in sqlFetch(odbcConnectExcel2007(F:\\Cotton2012\\validation.xlsx),
 :
  first argument is not an open RODBC channel In addition: Warning messages:
1: In odbcDriverConnect(con, tabQuote = c([, ]), ...) :
  [RODBC] ERROR: state IM002, code 0, message [Microsoft][ODBC Driver Manager] 
Data source name not found and no default driver specified
2: In odbcDriverConnect(con, tabQuote = c([, ]), ...) :
  ODBC connection failed

Melissa-sqlFetch(odbcConnectExcel(F:\\Cotton2012\\validation.xlsx),sqtable
= Sheet3,
+ na.strings = NA, as.is = TRUE)
Error in odbcConnectExcel(F:\\Cotton2012\\validation.xlsx) :
  odbcConnectExcel is only usable with 32-bit Windows

--
Ahmed M. Attia


Research Assistant
Dept. Of SoilCrop Sciences
Texas AM University
ahmed ahmeda...@zu.edu.eg.at...@ag.tamu.edu
Cell phone: 001-979-248-5215

[[alternative HTML version deleted]]

__
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.

The contents of this e-mail are confidential and may be ...{{dropped:14}}

__
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] importing data

2013-01-28 Thread Ivan Calandra

What about this then:
list_of_datasets - lapply(file_names, read.table, other_args_to_read.table)

Something that might then be useful is:
names(list_of_datasets) - file_names

Does it do it now?

Ivan

--
Ivan CALANDRA
Université de Bourgogne
UMR CNRS/uB 6282 Biogéosciences
6 Boulevard Gabriel
21000 Dijon, FRANCE
+33(0)3.80.39.63.06
ivan.calan...@u-bourgogne.fr
http://biogeosciences.u-bourgogne.fr/calandra

Le 28/01/13 07:34, Ray Cheung a écrit :
Thanks a million for all help provided!! I can do what I intend to 
using the for loop. However, I'm still eager to try the list.files 
approach. Here is the error message that I got using Ivan's code:


 list_of_dataset - do.call(read.table, file_names)
Error in do.call(read.table, file_names) : second argument must be a list

Please advise.

Ray

On Sun, Jan 27, 2013 at 10:57 PM, Ivan Calandra 
ivan.calan...@u-bourgogne.fr mailto:ivan.calan...@u-bourgogne.fr 
wrote:


Hi Ray!

I'm insisting with list.files...!

What about like this (untested)?
file_names - list.files(path=C:/.../data, pattern=.dat$,
full.names=TRUE)
list_of_dataset - do.call(read.table, file_names)

Let me know if this helps!
Ivan

-- Ivan CALANDRA Université de Bourgogne UMR CNRS/uB 6282
Biogéosciences 6 Boulevard Gabriel 21000 Dijon, FRANCE
+33(0)3.80.39.63.06 tel:%2B33%280%293.80.39.63.06
ivan.calan...@u-bourgogne.fr mailto:ivan.calan...@u-bourgogne.fr
http://biogeosciences.u-bourgogne.fr/calandra

Le 26/01/13 10:03, Ray Cheung a écrit :

Thanks for your commands, Ivan and Michael! However, I am still
not producing the right codes. Would you please help me on
this? I've written the following codes. Please comment. Thank you
very much.
Task: Reading data1.dat to data1000.dat (with missing files) into
R. Missing files can be omitted in the list.
###FUNCTION TO READ FILES
little_helpful - function(n) {
file_name - paste0(C:/.../data, n, .dat)
read.table(file_name)
}
###RETURN AN OBJECT WHICH CHECKS FOR THE EXISTENCE OF FILES
check  - function(n) {
a - ifelse(file.exists(paste0(C:/.../data, n, .dat)), 1, 0)
a
}
###Combining the functions
IMPORT - function(n) {
   L - check(1:n)
   for (i in 1:n) {
  if (L[i] == 1)
  list_of_datasets - lapply(i, little_helpful) else
list_of_datasets - 0
  }
   list_of_datasets
   }
Thanks for all comments.
Best Regards,
Ray

On Fri, Jan 25, 2013 at 5:48 PM, Ivan Calandra
ivan.calan...@u-bourgogne.fr
mailto:ivan.calan...@u-bourgogne.fr wrote:

Hi,

Not sure this is what you need, but what about list.files()?
It can get you all the files from a given folder, and you
could then work this list with regular expressions for example.

HTH,
Ivan

--
Ivan CALANDRA
Université de Bourgogne
UMR CNRS/uB 6282 Biogéosciences
6 Boulevard Gabriel
21000 Dijon, FRANCE
+33(0)3.80.39.63.06 tel:%2B33%280%293.80.39.63.06
ivan.calan...@u-bourgogne.fr
mailto:ivan.calan...@u-bourgogne.fr
http://biogeosciences.u-bourgogne.fr/calandra

Le 25/01/13 10:00, R. Michael Weylandt a écrit :

On Fri, Jan 25, 2013 at 6:11 AM, Ray Cheung
ray1...@gmail.com mailto:ray1...@gmail.com wrote:

Dear Michael,

Thanks for your codes. However, lapply does not work
in my case since I've
some files missing in the data (say, the file
data101.dat). Do you have any
suggestions on this?? Thank you very much.

You could simply add a test using file.exists() but I'm
not sure what
you want to do with the M matrix then -- omit the slice
(so the others
are all shifted down one) or fill it entirely with NA's.

Michael

__
R-help@r-project.org mailto: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 mailto: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, 

Re: [R] importing data

2013-01-28 Thread Ray Cheung
Dear Ivan,

It works perfectly fine now. I love this code more since I need not delete
the NULL list myself (and it should be faster, right?). Thank you very much
for your help!

cheers,
Ray

On Mon, Jan 28, 2013 at 5:32 PM, Ivan Calandra ivan.calan...@u-bourgogne.fr
 wrote:

 What about this then:
 list_of_datasets - lapply(file_names, read.table,
 other_args_to_read.table)

 Something that might then be useful is:
 names(list_of_datasets) - file_names

 Does it do it now?


 Ivan

 --
 Ivan CALANDRA
 Université de Bourgogne
 UMR CNRS/uB 6282 Biogéosciences
 6 Boulevard Gabriel
 21000 Dijon, FRANCE
 +33(0)3.80.39.63.06
 ivan.calan...@u-bourgogne.fr
 http://biogeosciences.u-**bourgogne.fr/calandrahttp://biogeosciences.u-bourgogne.fr/calandra

 Le 28/01/13 07:34, Ray Cheung a écrit :

 Thanks a million for all help provided!! I can do what I intend to using
 the for loop. However, I'm still eager to try the list.files approach.
 Here is the error message that I got using Ivan's code:

  list_of_dataset - do.call(read.table, file_names)
 Error in do.call(read.table, file_names) : second argument must be a list

 Please advise.

 Ray

 On Sun, Jan 27, 2013 at 10:57 PM, Ivan Calandra 
 ivan.calan...@u-bourgogne.fr 
 mailto:ivan.calandra@u-**bourgogne.frivan.calan...@u-bourgogne.fr
 wrote:

 Hi Ray!

 I'm insisting with list.files...!

 What about like this (untested)?
 file_names - list.files(path=C:/.../data, pattern=.dat$,
 full.names=TRUE)
 list_of_dataset - do.call(read.table, file_names)

 Let me know if this helps!
 Ivan

 -- Ivan CALANDRA Université de Bourgogne UMR CNRS/uB 6282
 Biogéosciences 6 Boulevard Gabriel 21000 Dijon, FRANCE
 +33(0)3.80.39.63.06 tel:%2B33%280%293.80.39.63.**06
 ivan.calan...@u-bourgogne.fr 
 mailto:ivan.calandra@u-**bourgogne.frivan.calan...@u-bourgogne.fr
 

 
 http://biogeosciences.u-**bourgogne.fr/calandrahttp://biogeosciences.u-bourgogne.fr/calandra

 Le 26/01/13 10:03, Ray Cheung a écrit :

 Thanks for your commands, Ivan and Michael! However, I am still
 not producing the right codes. Would you please help me on
 this? I've written the following codes. Please comment. Thank you
 very much.
 Task: Reading data1.dat to data1000.dat (with missing files) into
 R. Missing files can be omitted in the list.
 ###FUNCTION TO READ FILES
 little_helpful - function(n) {
 file_name - paste0(C:/.../data, n, .dat)
 read.table(file_name)
 }
 ###RETURN AN OBJECT WHICH CHECKS FOR THE EXISTENCE OF FILES
 check  - function(n) {
 a - ifelse(file.exists(paste0(C:/**.../data, n, .dat)), 1, 0)
 a
 }
 ###Combining the functions
 IMPORT - function(n) {
L - check(1:n)
for (i in 1:n) {
   if (L[i] == 1)
   list_of_datasets - lapply(i, little_helpful) else
 list_of_datasets - 0
   }
list_of_datasets
}
 Thanks for all comments.
 Best Regards,
 Ray

 On Fri, Jan 25, 2013 at 5:48 PM, Ivan Calandra
 ivan.calan...@u-bourgogne.fr
 mailto:ivan.calandra@u-**bourgogne.frivan.calan...@u-bourgogne.fr
 wrote:

 Hi,

 Not sure this is what you need, but what about list.files()?
 It can get you all the files from a given folder, and you
 could then work this list with regular expressions for example.

 HTH,
 Ivan

 --
 Ivan CALANDRA
 Université de Bourgogne
 UMR CNRS/uB 6282 Biogéosciences
 6 Boulevard Gabriel
 21000 Dijon, FRANCE
 +33(0)3.80.39.63.06 tel:%2B33%280%293.80.39.63.**06
 ivan.calan...@u-bourgogne.fr
 mailto:ivan.calandra@u-**bourgogne.frivan.calan...@u-bourgogne.fr
 

 
 http://biogeosciences.u-**bourgogne.fr/calandrahttp://biogeosciences.u-bourgogne.fr/calandra

 Le 25/01/13 10:00, R. Michael Weylandt a écrit :

 On Fri, Jan 25, 2013 at 6:11 AM, Ray Cheung
 ray1...@gmail.com mailto:ray1...@gmail.com wrote:

 Dear Michael,

 Thanks for your codes. However, lapply does not work
 in my case since I've
 some files missing in the data (say, the file
 data101.dat). Do you have any
 suggestions on this?? Thank you very much.

 You could simply add a test using file.exists() but I'm
 not sure what
 you want to do with the M matrix then -- omit the slice
 (so the others
 are all shifted down one) or fill it entirely with NA's.

 Michael

 __**
 R-help@r-project.org mailto:R-help@r-project.org

 mailing list
 
 https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 
 

Re: [R] importing data

2013-01-28 Thread Ivan Calandra
This code is indeed much shorter. About the speed, I guess it should be 
faster, but you should test it with system.time()


I'm glad that it helped.
Ivan


--
Ivan CALANDRA
Université de Bourgogne
UMR CNRS/uB 6282 Biogéosciences
6 Boulevard Gabriel
21000 Dijon, FRANCE
+33(0)3.80.39.63.06
ivan.calan...@u-bourgogne.fr
http://biogeosciences.u-bourgogne.fr/calandra

Le 28/01/13 16:38, Ray Cheung a écrit :

Dear Ivan,
It works perfectly fine now. I love this code more since I need not 
delete the NULL list myself (and it should be faster, right?). Thank 
you very much for your help!

cheers,
Ray

On Mon, Jan 28, 2013 at 5:32 PM, Ivan Calandra 
ivan.calan...@u-bourgogne.fr mailto:ivan.calan...@u-bourgogne.fr 
wrote:


What about this then:
list_of_datasets - lapply(file_names, read.table,
other_args_to_read.table)

Something that might then be useful is:
names(list_of_datasets) - file_names

Does it do it now?


Ivan

--
Ivan CALANDRA
Université de Bourgogne
UMR CNRS/uB 6282 Biogéosciences
6 Boulevard Gabriel
21000 Dijon, FRANCE
+33(0)3.80.39.63.06 tel:%2B33%280%293.80.39.63.06
ivan.calan...@u-bourgogne.fr mailto:ivan.calan...@u-bourgogne.fr
http://biogeosciences.u-bourgogne.fr/calandra

Le 28/01/13 07:34, Ray Cheung a écrit :

Thanks a million for all help provided!! I can do what I
intend to using the for loop. However, I'm still eager to
try the list.files approach. Here is the error message that I
got using Ivan's code:

 list_of_dataset - do.call(read.table, file_names)
Error in do.call(read.table, file_names) : second argument
must be a list

Please advise.

Ray

On Sun, Jan 27, 2013 at 10:57 PM, Ivan Calandra
ivan.calan...@u-bourgogne.fr
mailto:ivan.calan...@u-bourgogne.fr
mailto:ivan.calan...@u-bourgogne.fr
mailto:ivan.calan...@u-bourgogne.fr wrote:

Hi Ray!

I'm insisting with list.files...!

What about like this (untested)?
file_names - list.files(path=C:/.../data, pattern=.dat$,
full.names=TRUE)
list_of_dataset - do.call(read.table, file_names)

Let me know if this helps!
Ivan

-- Ivan CALANDRA Université de Bourgogne UMR CNRS/uB 6282
Biogéosciences 6 Boulevard Gabriel 21000 Dijon, FRANCE
+33(0)3.80.39.63.06 tel:%2B33%280%293.80.39.63.06
tel:%2B33%280%293.80.39.63.06
ivan.calan...@u-bourgogne.fr
mailto:ivan.calan...@u-bourgogne.fr
mailto:ivan.calan...@u-bourgogne.fr
mailto:ivan.calan...@u-bourgogne.fr

http://biogeosciences.u-bourgogne.fr/calandra

Le 26/01/13 10:03, Ray Cheung a écrit :

Thanks for your commands, Ivan and Michael! However, I
am still
not producing the right codes. Would you please help me on
this? I've written the following codes. Please
comment. Thank you
very much.
Task: Reading data1.dat to data1000.dat (with missing
files) into
R. Missing files can be omitted in the list.
###FUNCTION TO READ FILES
little_helpful - function(n) {
file_name - paste0(C:/.../data, n, .dat)
read.table(file_name)
}
###RETURN AN OBJECT WHICH CHECKS FOR THE EXISTENCE OF
FILES
check  - function(n) {
a - ifelse(file.exists(paste0(C:/.../data, n,
.dat)), 1, 0)
a
}
###Combining the functions
IMPORT - function(n) {
   L - check(1:n)
   for (i in 1:n) {
  if (L[i] == 1)
  list_of_datasets - lapply(i, little_helpful) else
list_of_datasets - 0
  }
   list_of_datasets
   }
Thanks for all comments.
Best Regards,
Ray

On Fri, Jan 25, 2013 at 5:48 PM, Ivan Calandra
ivan.calan...@u-bourgogne.fr
mailto:ivan.calan...@u-bourgogne.fr
mailto:ivan.calan...@u-bourgogne.fr
mailto:ivan.calan...@u-bourgogne.fr wrote:

Hi,

Not sure this is what you need, but what about
list.files()?
It can get you all the files from a given folder,
and you
could then work this list with regular expressions
for example.

HTH,
Ivan

--
Ivan CALANDRA
Université de Bourgogne
UMR CNRS/uB 6282 Biogéosciences
6 Boulevard Gabriel
 

Re: [R] importing data

2013-01-27 Thread Ivan Calandra
Hi Ray!

I'm insisting with list.files...!

What about like this (untested)?
file_names - list.files(path=C:/.../data, pattern=.dat$, 
full.names=TRUE)
list_of_dataset - do.call(read.table, file_names)

Let me know if this helps!
Ivan

--
Ivan CALANDRA
Université de Bourgogne
UMR CNRS/uB 6282 Biogéosciences
6 Boulevard Gabriel
21000 Dijon, FRANCE
+33(0)3.80.39.63.06
ivan.calan...@u-bourgogne.fr
http://biogeosciences.u-bourgogne.fr/calandra

Le 26/01/13 10:03, Ray Cheung a écrit :
 Thanks for your commands, Ivan and Michael! However, I am still not 
 producing the right codes. Would you please help me on this? I've 
 written the following codes. Please comment. Thank you very much.
 Task: Reading data1.dat to data1000.dat (with missing files) into R. 
 Missing files can be omitted in the list.
 ###FUNCTION TO READ FILES
 little_helpful - function(n) {
 file_name - paste0(C:/.../data, n, .dat)
 read.table(file_name)
 }
 ###RETURN AN OBJECT WHICH CHECKS FOR THE EXISTENCE OF FILES
 check  - function(n) {
 a - ifelse(file.exists(paste0(C:/.../data, n, .dat)), 1, 0)
 a
 }
 ###Combining the functions
 IMPORT - function(n) {
L - check(1:n)
for (i in 1:n) {
   if (L[i] == 1)
   list_of_datasets - lapply(i, little_helpful) else 
 list_of_datasets - 0
   }
list_of_datasets
}
 Thanks for all comments.
 Best Regards,
 Ray

 On Fri, Jan 25, 2013 at 5:48 PM, Ivan Calandra 
 ivan.calan...@u-bourgogne.fr mailto:ivan.calan...@u-bourgogne.fr 
 wrote:

 Hi,

 Not sure this is what you need, but what about list.files()?
 It can get you all the files from a given folder, and you could
 then work this list with regular expressions for example.

 HTH,
 Ivan

 --
 Ivan CALANDRA
 Université de Bourgogne
 UMR CNRS/uB 6282 Biogéosciences
 6 Boulevard Gabriel
 21000 Dijon, FRANCE
 +33(0)3.80.39.63.06 tel:%2B33%280%293.80.39.63.06
 ivan.calan...@u-bourgogne.fr mailto:ivan.calan...@u-bourgogne.fr
 http://biogeosciences.u-bourgogne.fr/calandra

 Le 25/01/13 10:00, R. Michael Weylandt a écrit :

 On Fri, Jan 25, 2013 at 6:11 AM, Ray Cheung ray1...@gmail.com
 mailto:ray1...@gmail.com wrote:

 Dear Michael,

 Thanks for your codes. However, lapply does not work in my
 case since I've
 some files missing in the data (say, the file
 data101.dat). Do you have any
 suggestions on this?? Thank you very much.

 You could simply add a test using file.exists() but I'm not
 sure what
 you want to do with the M matrix then -- omit the slice (so
 the others
 are all shifted down one) or fill it entirely with NA's.

 Michael

 __
 R-help@r-project.org mailto: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 mailto: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.



[[alternative HTML version deleted]]

__
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] importing data

2013-01-27 Thread Ray Cheung
Thanks a million for all help provided!! I can do what I intend to using
the for loop. However, I'm still eager to try the list.files approach.
Here is the error message that I got using Ivan's code:

 list_of_dataset - do.call(read.table, file_names)
Error in do.call(read.table, file_names) : second argument must be a list

Please advise.

Ray

On Sun, Jan 27, 2013 at 10:57 PM, Ivan Calandra 
ivan.calan...@u-bourgogne.fr wrote:

  Hi Ray!

 I'm insisting with list.files...!

 What about like this (untested)?
 file_names - list.files(path=C:/.../data, pattern=.dat$,
 full.names=TRUE)
 list_of_dataset - do.call(read.table, file_names)

 Let me know if this helps!
 Ivan

 --
 Ivan CALANDRA
 Université de Bourgogne
 UMR CNRS/uB 6282 Biogéosciences
 6 Boulevard Gabriel
 21000 Dijon, FRANCE+33(0)3.80.39.63.06ivan.calan...@u-bourgogne.fr
 http://biogeosciences.u-bourgogne.fr/calandra

 Le 26/01/13 10:03, Ray Cheung a écrit :

 Thanks for your commands, Ivan and Michael! However, I am still not
 producing the right codes. Would you please help me on this? I've written
 the following codes. Please comment. Thank you very much.

 Task: Reading data1.dat to data1000.dat (with missing files) into R.
 Missing files can be omitted in the list.

 ###FUNCTION TO READ FILES
 little_helpful - function(n) {
 file_name - paste0(C:/.../data, n, .dat)
 read.table(file_name)
 }

 ###RETURN AN OBJECT WHICH CHECKS FOR THE EXISTENCE OF FILES
 check  - function(n) {
 a - ifelse(file.exists(paste0(C:/.../data, n, .dat)), 1, 0)
 a
 }
  ###Combining the functions
 IMPORT - function(n) {
L - check(1:n)
for (i in 1:n) {
   if (L[i] == 1)
   list_of_datasets - lapply(i, little_helpful) else list_of_datasets
 - 0
   }
list_of_datasets
}

 Thanks for all comments.

 Best Regards,
 Ray

  On Fri, Jan 25, 2013 at 5:48 PM, Ivan Calandra 
 ivan.calan...@u-bourgogne.fr wrote:

 Hi,

 Not sure this is what you need, but what about list.files()?
 It can get you all the files from a given folder, and you could then work
 this list with regular expressions for example.

 HTH,
 Ivan

 --
 Ivan CALANDRA
 Université de Bourgogne
 UMR CNRS/uB 6282 Biogéosciences
 6 Boulevard Gabriel
 21000 Dijon, FRANCE
 +33(0)3.80.39.63.06
 ivan.calan...@u-bourgogne.fr
 http://biogeosciences.u-bourgogne.fr/calandra

 Le 25/01/13 10:00, R. Michael Weylandt a écrit :

  On Fri, Jan 25, 2013 at 6:11 AM, Ray Cheung ray1...@gmail.com wrote:

 Dear Michael,

 Thanks for your codes. However, lapply does not work in my case since
 I've
 some files missing in the data (say, the file data101.dat). Do you have
 any
 suggestions on this?? Thank you very much.

  You could simply add a test using file.exists() but I'm not sure what
 you want to do with the M matrix then -- omit the slice (so the others
 are all shifted down one) or fill it entirely with NA's.

 Michael

   __
 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.




[[alternative HTML version deleted]]

__
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] importing data

2013-01-26 Thread Ray Cheung
Thanks for your commands, Ivan and Michael! However, I am still not
producing the right codes. Would you please help me on this? I've written
the following codes. Please comment. Thank you very much.

Task: Reading data1.dat to data1000.dat (with missing files) into R.
Missing files can be omitted in the list.

###FUNCTION TO READ FILES
little_helpful - function(n) {
file_name - paste0(C:/.../data, n, .dat)
read.table(file_name)
}

###RETURN AN OBJECT WHICH CHECKS FOR THE EXISTENCE OF FILES
check  - function(n) {
a - ifelse(file.exists(paste0(C:/.../data, n, .dat)), 1, 0)
a
}
###Combining the functions
IMPORT - function(n) {
   L - check(1:n)
   for (i in 1:n) {
  if (L[i] == 1)
  list_of_datasets - lapply(i, little_helpful) else list_of_datasets
- 0
  }
   list_of_datasets
   }

Thanks for all comments.

Best Regards,
Ray

On Fri, Jan 25, 2013 at 5:48 PM, Ivan Calandra ivan.calan...@u-bourgogne.fr
 wrote:

 Hi,

 Not sure this is what you need, but what about list.files()?
 It can get you all the files from a given folder, and you could then work
 this list with regular expressions for example.

 HTH,
 Ivan

 --
 Ivan CALANDRA
 Université de Bourgogne
 UMR CNRS/uB 6282 Biogéosciences
 6 Boulevard Gabriel
 21000 Dijon, FRANCE
 +33(0)3.80.39.63.06
 ivan.calan...@u-bourgogne.fr
 http://biogeosciences.u-**bourgogne.fr/calandrahttp://biogeosciences.u-bourgogne.fr/calandra

 Le 25/01/13 10:00, R. Michael Weylandt a écrit :

 On Fri, Jan 25, 2013 at 6:11 AM, Ray Cheung ray1...@gmail.com wrote:

 Dear Michael,

 Thanks for your codes. However, lapply does not work in my case since
 I've
 some files missing in the data (say, the file data101.dat). Do you have
 any
 suggestions on this?? Thank you very much.

  You could simply add a test using file.exists() but I'm not sure what
 you want to do with the M matrix then -- omit the slice (so the others
 are all shifted down one) or fill it entirely with NA's.

 Michael

 __**
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/**
 posting-guide.html 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-helphttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/**
 posting-guide.html http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


[[alternative HTML version deleted]]

__
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] importing data

2013-01-26 Thread David Hugh-Jones
Hi Ray,
Comments below:

On 26 January 2013 09:03, Ray Cheung ray1...@gmail.com wrote:
[snip]
 ###FUNCTION TO READ FILES
 little_helpful - function(n) {
 file_name - paste0(C:/.../data, n, .dat)
 read.table(file_name)
 }

 ###RETURN AN OBJECT WHICH CHECKS FOR THE EXISTENCE OF FILES
 check  - function(n) {
 a - ifelse(file.exists(paste0(C:/.../data, n, .dat)), 1, 0)
 a
 }

Too complex. Why not just use file.exists directly?

 ###Combining the functions
 IMPORT - function(n) {
L - check(1:n)
for (i in 1:n) {
   if (L[i] == 1)
   list_of_datasets - lapply(i, little_helpful) else list_of_datasets
 - 0
   }
list_of_datasets
}


Too complex here too. I suggest something like:

M - list()
for (i in 1:n) {
 file_name - paste0(C:/.../data, n, .dat)
  if (file.exists(file_name)) M[i] - read.table(file_name)
}

R gurus don't like for() loops, but they are easy for humans to understand.
If this doesn't work, post the error message.


 Thanks for all comments.

 Best Regards,
 Ray

 On Fri, Jan 25, 2013 at 5:48 PM, Ivan Calandra ivan.calan...@u-bourgogne.fr
 wrote:

 Hi,

 Not sure this is what you need, but what about list.files()?
 It can get you all the files from a given folder, and you could then work
 this list with regular expressions for example.

 HTH,
 Ivan

 --
 Ivan CALANDRA
 Université de Bourgogne
 UMR CNRS/uB 6282 Biogéosciences
 6 Boulevard Gabriel
 21000 Dijon, FRANCE
 +33(0)3.80.39.63.06
 ivan.calan...@u-bourgogne.fr
 http://biogeosciences.u-**bourgogne.fr/calandrahttp://biogeosciences.u-bourgogne.fr/calandra

 Le 25/01/13 10:00, R. Michael Weylandt a écrit :

 On Fri, Jan 25, 2013 at 6:11 AM, Ray Cheung ray1...@gmail.com wrote:

 Dear Michael,

 Thanks for your codes. However, lapply does not work in my case since
 I've
 some files missing in the data (say, the file data101.dat). Do you have
 any
 suggestions on this?? Thank you very much.

  You could simply add a test using file.exists() but I'm not sure what
 you want to do with the M matrix then -- omit the slice (so the others
 are all shifted down one) or fill it entirely with NA's.

 Michael

 __**
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/**
 posting-guide.html 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-helphttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/**
 posting-guide.html http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


 [[alternative HTML version deleted]]


 __
 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] importing data

2013-01-25 Thread R. Michael Weylandt
On Fri, Jan 25, 2013 at 6:11 AM, Ray Cheung ray1...@gmail.com wrote:
 Dear Michael,

 Thanks for your codes. However, lapply does not work in my case since I've
 some files missing in the data (say, the file data101.dat). Do you have any
 suggestions on this?? Thank you very much.


You could simply add a test using file.exists() but I'm not sure what
you want to do with the M matrix then -- omit the slice (so the others
are all shifted down one) or fill it entirely with NA's.

Michael

__
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] importing data

2013-01-25 Thread Ivan Calandra

Hi,

Not sure this is what you need, but what about list.files()?
It can get you all the files from a given folder, and you could then 
work this list with regular expressions for example.


HTH,
Ivan

--
Ivan CALANDRA
Université de Bourgogne
UMR CNRS/uB 6282 Biogéosciences
6 Boulevard Gabriel
21000 Dijon, FRANCE
+33(0)3.80.39.63.06
ivan.calan...@u-bourgogne.fr
http://biogeosciences.u-bourgogne.fr/calandra

Le 25/01/13 10:00, R. Michael Weylandt a écrit :

On Fri, Jan 25, 2013 at 6:11 AM, Ray Cheung ray1...@gmail.com wrote:

Dear Michael,

Thanks for your codes. However, lapply does not work in my case since I've
some files missing in the data (say, the file data101.dat). Do you have any
suggestions on this?? Thank you very much.


You could simply add a test using file.exists() but I'm not sure what
you want to do with the M matrix then -- omit the slice (so the others
are all shifted down one) or fill it entirely with NA's.

Michael

__
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] importing data

2013-01-24 Thread Ray Cheung
Dear Michael,

Thanks for your codes. However, lapply does not work in my case since I've
some files missing in the data (say, the file data101.dat). Do you have any
suggestions on this?? Thank you very much.

Best Wishes,
Ray

On Wed, Jan 23, 2013 at 8:15 PM, R. Michael Weylandt 
michael.weyla...@gmail.com wrote:

 On Wed, Jan 23, 2013 at 9:16 AM, Ray Cheung ray1...@gmail.com wrote:
  Dear All,
 
  Sorry for asking a newbie question. I want to ask how to import 1000
  datasets whose file names are labelled from data1.dat to data1000.dat
 into
  R so that they are named M[1, , ] to M[1000, , ] accordingly. Thank you
  very much.
 ,

 Hi Ray,

 I'm pretty sure you don't mean named M[1,,] etc. but rather that
 there's only one object M and that's how the slices come into
 existence:

 What you'll want to do is something like this:

 little_helpful_function(n){
 file_name - paste(data, n, .dat, sep = )
 read.dta(file_name, ##OTHER PARAMETERS)
 }

 list_of_datasets - lapply(1:1000, little_helpful_function)

 output - do.call(c, list_of_datasets)

 dim(output) - c(dim(list_of_datasets[[1]]), 1000)

 Or something like that. Note that I'm not quite sure what a dta file
 is, so I'll leave it to you to find an appropriate read.dta function.

 Feel free to write back (cc'ing the list) if you don't understand all
 of the above.

 Cheers,
 Michael

  Best Regards,
  Ray
 
  [[alternative HTML version deleted]]
 
  __
  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.


[[alternative HTML version deleted]]

__
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] importing data

2013-01-23 Thread R. Michael Weylandt
On Wed, Jan 23, 2013 at 9:16 AM, Ray Cheung ray1...@gmail.com wrote:
 Dear All,

 Sorry for asking a newbie question. I want to ask how to import 1000
 datasets whose file names are labelled from data1.dat to data1000.dat into
 R so that they are named M[1, , ] to M[1000, , ] accordingly. Thank you
 very much.
,

Hi Ray,

I'm pretty sure you don't mean named M[1,,] etc. but rather that
there's only one object M and that's how the slices come into
existence:

What you'll want to do is something like this:

little_helpful_function(n){
file_name - paste(data, n, .dat, sep = )
read.dta(file_name, ##OTHER PARAMETERS)
}

list_of_datasets - lapply(1:1000, little_helpful_function)

output - do.call(c, list_of_datasets)

dim(output) - c(dim(list_of_datasets[[1]]), 1000)

Or something like that. Note that I'm not quite sure what a dta file
is, so I'll leave it to you to find an appropriate read.dta function.

Feel free to write back (cc'ing the list) if you don't understand all
of the above.

Cheers,
Michael

 Best Regards,
 Ray

 [[alternative HTML version deleted]]

 __
 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] Importing Data for a two sample t-test

2012-11-15 Thread Jeff Newmiller
?subset
---
Jeff NewmillerThe .   .  Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

nilsonern nilson...@gmail.com wrote:

I am trying to do a two sample t-test with data that i received in a
text
document.  one list has the slab weights and the second has the company
it
is associated with.  here is an example.

weights  company
1  A
2  A  
2  B
3  B

I was able to import the data but i cannot figure out how separate the
data. 
I want to put them in two separate sets, one being A and one being B. 
Any
help would be appreciated.  Thanks.



--
View this message in context:
http://r.789695.n4.nabble.com/Importing-Data-for-a-two-sample-t-test-tp4649565.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.

__
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] Importing Data for a two sample t-test

2012-11-15 Thread arun
HI,
If you need to separate into two datasets,


 dat1[dat1$company==A,]
#  weights company
#1   1   A
#2   2   A
#or

 dat1[dat1$company==B,]

#or split into a list
 split(dat1,dat1$company)



A.K.



- Original Message -
From: nilsonern nilson...@gmail.com
To: r-help@r-project.org
Cc: 
Sent: Wednesday, November 14, 2012 11:52 PM
Subject: [R] Importing Data for a two sample t-test

I am trying to do a two sample t-test with data that i received in a text
document.  one list has the slab weights and the second has the company it
is associated with.  here is an example.

weights  company
1                  A
2                  A  
2                  B
3                  B

I was able to import the data but i cannot figure out how separate the data. 
I want to put them in two separate sets, one being A and one being B.  Any
help would be appreciated.  Thanks.



--
View this message in context: 
http://r.789695.n4.nabble.com/Importing-Data-for-a-two-sample-t-test-tp4649565.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.


__
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] Importing Data for a two sample t-test

2012-11-15 Thread Peter Ehlers

On 2012-11-14 20:52, nilsonern wrote:

I am trying to do a two sample t-test with data that i received in a text
document.  one list has the slab weights and the second has the company it
is associated with.  here is an example.

weights  company
1  A
2  A
2  B
3  B

I was able to import the data but i cannot figure out how separate the data.
I want to put them in two separate sets, one being A and one being B.  Any
help would be appreciated.  Thanks.



Why separate? The 'long' form is generally preferred in
statistical analyses.
Just use the formula version of t.test().

Peter Ehlers




--
View this message in context: 
http://r.789695.n4.nabble.com/Importing-Data-for-a-two-sample-t-test-tp4649565.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.



__
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] Importing Data for a two sample t-test

2012-11-15 Thread arun
Hi,

Not sure why you wanted to separate A and B for a two sample t-test.
dat1-read.table(text=
weights  company
1  A
2  A 
2  B
3  B
,sep=,header=TRUE,stringsAsFactors=FALSE)
 t.test(weights~company,data=dat1)

#    Welch Two Sample t-test
#
#data:  weights by company 
#t = -1.4142, df = 2, p-value = 0.2929
#alternative hypothesis: true difference in means is not equal to 0 
#95 percent confidence interval:
 #-4.042435  2.042435 
#sample estimates:
#mean in group A mean in group B 
  #  1.5 2.5 

In case, you wanted to separate A and B:
library(reshape2)
dcast(dat1,weights~company,value.var=weights)
#  weights  A  B
#1   1  1 NA
#2   2  2  2
#3   3 NA  3

Hope it helps.

A.K.



- Original Message -
From: nilsonern nilson...@gmail.com
To: r-help@r-project.org
Cc: 
Sent: Wednesday, November 14, 2012 11:52 PM
Subject: [R] Importing Data for a two sample t-test

I am trying to do a two sample t-test with data that i received in a text
document.  one list has the slab weights and the second has the company it
is associated with.  here is an example.

weights  company
1                  A
2                  A  
2                  B
3                  B

I was able to import the data but i cannot figure out how separate the data. 
I want to put them in two separate sets, one being A and one being B.  Any
help would be appreciated.  Thanks.



--
View this message in context: 
http://r.789695.n4.nabble.com/Importing-Data-for-a-two-sample-t-test-tp4649565.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.


__
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] Importing data from stata.

2012-04-16 Thread Uwe Ligges



On 16.04.2012 12:56, Søren Andersen wrote:


Hi everyone!

I am very new at R. I am trying to import a data file from stata to R on a 
Macintosh system ? When I use the foreign function read.dta it says:






You forgot to load foreign:

library(foreign)


Uwe Ligges







Error: could not find function read.dta

p   
[[alternative HTML version deleted]]

__
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] Importing data from MS EXCEL (.xls) to R XXXX

2011-08-25 Thread Kathleen Rollet

Hi Dan,
 
You can save your .xls as .csv, set up your directory under the file where you 
saved it, then
 
widge= read.csv(WidgeOne.csv, header=T)
 
It should work.
 
Kathleen.

 

 From: jorgeivanve...@gmail.com
 Date: Wed, 24 Aug 2011 18:31:21 -0400
 To: dan.abne...@gmail.com
 CC: r-help@r-project.org
 Subject: Re: [R] Importing data from MS EXCEL (.xls) to R 
 
 Hi Dan,
 
 You might try
 
 require(gdata)
 ?read.xls
 
 HTH,
 Jorge
 
 
 On Wed, Aug 24, 2011 at 6:20 PM, Dan Abner  wrote:
 
  Hello everyone,
 
  What is the simplest, most RELIABLE way to import data from MS EXCEL (.xls)
  format to R? In the past I have used the read.xls() function from the
  xlsReadWrite package, however, I have been wrestling with it all afternoon
  long with no success. I continue to receive the following error message:
 
 
   {widge-read.xls(F:\\Classes\\Z1.Data\\stat.3010\\WidgeOne.xls,
  + colNames=TRUE,sheet=1)}
  Error in .Call(ReadXls, file, colNames, sheet, type, from, rowNames, :
  Incorrect number of arguments (11), expecting 10 for 'ReadXls'
 
  Any insight/suggestions/assistance is appreciated.
 
  Thank you,
 
  Dan
 
  [[alternative HTML version deleted]]
 
  __
  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.
 
 
 [[alternative HTML version deleted]]
 
 __
 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.
  
[[alternative HTML version deleted]]

__
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] Importing data from MS EXCEL (.xls) to R XXXX

2011-08-24 Thread Jorge I Velez
Hi Dan,

You might try

require(gdata)
?read.xls

HTH,
Jorge


On Wed, Aug 24, 2011 at 6:20 PM, Dan Abner  wrote:

 Hello everyone,

 What is the simplest, most RELIABLE way to import data from MS EXCEL (.xls)
 format to R? In the past I have used the read.xls() function from the
 xlsReadWrite package, however, I have been wrestling with it all afternoon
 long with no success. I continue to receive the following error message:


  {widge-read.xls(F:\\Classes\\Z1.Data\\stat.3010\\WidgeOne.xls,
 + colNames=TRUE,sheet=1)}
 Error in .Call(ReadXls, file, colNames, sheet, type, from, rowNames,  :
  Incorrect number of arguments (11), expecting 10 for 'ReadXls'

 Any insight/suggestions/assistance is appreciated.

 Thank you,

 Dan

[[alternative HTML version deleted]]

 __
 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.


[[alternative HTML version deleted]]

__
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] Importing data from MS EXCEL (.xls) to R XXXX

2011-08-24 Thread B77S
I agree with Ken.. if you can, save it as a CSV file.  But if you have a
bunch of these, then it isn't very efficient.  I use read.xlsx() from the
package xlsx.  

I notice that you are using the full path.. have you tried changing
directories?... I find it is best to compartmentalize my work and (with a
few exceptions) work within a folder.

good luck.

 


Dan Abner wrote:
 
 Hello everyone,
 
 What is the simplest, most RELIABLE way to import data from MS EXCEL
 (.xls)
 format to R? In the past I have used the read.xls() function from the
 xlsReadWrite package, however, I have been wrestling with it all afternoon
 long with no success. I continue to receive the following error message:
 
 
 {widge-read.xls(F:\\Classes\\Z1.Data\\stat.3010\\WidgeOne.xls,
 + colNames=TRUE,sheet=1)}
 Error in .Call(ReadXls, file, colNames, sheet, type, from, rowNames,  :
   Incorrect number of arguments (11), expecting 10 for 'ReadXls'
 
 Any insight/suggestions/assistance is appreciated.
 
 Thank you,
 
 Dan
 
   [[alternative HTML version deleted]]
 
 __
 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://r.789695.n4.nabble.com/Importing-data-from-MS-EXCEL-xls-to-R--tp3766864p3767063.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] Importing data coming from Splus into R.

2010-02-05 Thread RICHARD M. HEIBERGER
Have you tried  dput/dget or dump/source?
On the S-Plus side, you need to tell it to use the older format.

Rich

__
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] Importing data coming from Splus into R.

2010-02-05 Thread Uwe Ligges
1. I am stuck with a copy of S-PLUS 4.x. At that time I used dump() in 
S-PLUS and source() to get things into R afterwards ...


2. Why do you think that 32-bit vs. 64-bit issues matter? The file 
format does not change (well, this is guessed since I do not have any 
64-bit S-PLUS version available).


Best,
Uwe Ligges


On 05.02.2010 16:35, gerald.j...@dgag.ca wrote:


Hello there,

I spent all day yesterday trying to get a small data set from Splus into R,
no luck!  Both, Splus and R, are run on a 64-bit RedHat Linux machine, the
versions of the softwares are 64-bit and are as what follows:

Splus:
TIBCO Software Inc. Confidential Information
Copyright (c) 1988-2008 TIBCO Software Inc. ALL RIGHTS RESERVED.
TIBCO Spotfire S+ Version 8.1.1 for Linux 2.6.9-34.EL, 64-bit : 2008

R:
R version 2.8.0 (2008-10-20)
Copyright (C) 2008 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

I know that the foreign package has a function to directly import Splus
data sets into R, but I also know that it is working only for 32-bit
versions of the softwares, hence I didn't try that route.  Here is what I
have done:

In Splus:

ttt- exportData(data = FMD.CR.test,
   file = /home/jeg002/splus/R/Exemples/R/FMD-CR-test.csv,
   type = ASCII, delimiter = @, quote = T, na.string =
NA)
ttt.class- unlist(lapply(FMD.CR.test, class))

### I am using @ as delimiter since some factor levels contain both the
, and the ;.

In R:

FMD.CR.test.fields- count.fields(file =
/home/jeg002/splus/R/Exemples/R/FMD-CR-test.csv,
sep = @, quote = \, comment.char =
)
all(FMD.CR.test.fields == 327)
[1] TRUE  ## Hence all observations have the same number of fields, so far,
so good!

FMD.CR.test.classes- c(factor, character, factor, factor,
factor,
  factor, factor, factor, factor, factor,
  factor, numeric, character, and so on)
names(FMD.CR.test.classes)- c(RTA,police, mnt.rent.bnct,
  mnt.rent.boni, mnt.rent.cred.bnct,
  mnt.rent.epar.bnct, mnt.rent.snbn,
  mnt.rent.trxl, solde.eop, solde.nenr.es,
  solde.enr.es, num.enreg, trouve, and so on)
FMD.CR.test-
 read.table(file = /home/jeg002/splus/R/Exemples/R/FMD-CR-test.csv,
header = TRUE, sep = @, quote = \, as.is = FALSE,
strip.white = FALSE, comment.char = , na.strings = NA,
nrows = 65000, colClasses = FMD.CR.test.classes)
dim(FMD.CR.test)
[1] 64093   327  ## OK

### Testing if classes are the same as the Splus classes.

FMD.CR.test.R.classes- apply(FMD.CR.test, 2, FUN = class)
sum(FMD.CR.test.R.classes == FMD.CR.test.classes)
[1] 79  ## Not exactly what I was expecting!
all(FMD.CR.test.R.classes == character)
[1] TRUE

Hence all variables were imported as character, which I find very
inconvenient; since the data set has a few hundred factor variables
recoding them is a lot of work, this work has already been done in Splus;
furthermore, the numeric variables would need conversion as well.

I tried all combinations of the arguments as.is, stringsAsFactors and
colClasses to no avail.  I also tried to export the data set in SAS
transport format from Splus and read it through the foreign's read.xport
function, always the same result, everything is imported as character.  I
search the r-help archives, I found several messages relating this problem
but no satisfactory solution!

I am a long time user of Splus and I am planning to use R more often,
mainly due to its wealth of packages and the convenience of installing
them.  I hope to find a reliable and convivial way of transferring data
between the two cousins pieces of software.

Thanks for any insights,

Gérald Jean
Conseiller senior en statistiques,
VP Planification et Développement des Marchés,
Desjardins Groupe d'Assurances Générales
télephone: (418) 835-4900 poste (7639)
télecopieur  : (418) 835-6657
courrier électronique: gerald.j...@dgag.ca

In God we trust, all others must bring data  W. Edwards Deming





Le message ci-dessus, ainsi que les documents l'accompagnant, sont destinés
uniquement aux personnes identifiées et peuvent contenir des informations
privilégiées, confidentielles ou ne pouvant être divulguées. Si vous avez
reçu ce message par erreur, veuillez le détruire.

This communication ( and/or the attachments ) is intended for named
recipients only and may contain privileged or confidential information
which is not to be disclosed. If you received this communication by mistake
please destroy all copies.




Faites bonne impression et imprimez seulement au besoin !
Think green before you print !

Le message ci-dessus, ainsi que les documents l'accompagnant, sont destinés 
uniquement aux personnes identifiées et peuvent contenir des informations 
privilégiées, confidentielles ou ne pouvant être divulguées. Si vous avez reçu 
ce message par 

Re: [R] Importing data coming from Splus into R.

2010-02-05 Thread gerald . jean

Uwe Ligges lig...@statistik.tu-dortmund.de a écrit sur 2010/02/05
11:04:44 :

 1. I am stuck with a copy of S-PLUS 4.x. At that time I used dump() in
 S-PLUS and source() to get things into R afterwards ...

 2. Why do you think that 32-bit vs. 64-bit issues matter? The file
 format does not change (well, this is guessed since I do not have any
 64-bit S-PLUS version available).

The R-data_ImportExport manual says:

Function read.S which can read binary objects produced by S-PLUS 3.x, 4.x
or 2000 on
(32-bit) Unix or Windows (and can read them on a different OS). This is
able to read many but
not all S objects: in particular it can read vectors, matrices and data
frames and lists containing
those.

Function data.restore reads S-PLUS data dumps (created by data.dump) with
the same
restrictions (except that dumps from the Alpha platform can also be read).
It should be possible
to read data dumps from S-PLUS 5.x and later written with
data.dump(oldStyle=T).

Following  Richard Heiberger suggestion I also trie dput in Splus and
dget in R, works but all columns are imported as character, same thing
with dump from Splus and source from R.


If I get this right there is no easy way of going back and forth between
the cousins while preserving the structure of the data, too bad!

Thanks for your interest in my problem,

Gérald Jean
Conseiller senior en statistiques,
VP Planification et Développement des Marchés,
Desjardins Groupe d'Assurances Générales
télephone: (418) 835-4900 poste (7639)
télecopieur  : (418) 835-6657
courrier électronique: gerald.j...@dgag.ca

In God we trust, all others must bring data  W. Edwards Deming


 Best,
 Uwe Ligges


 On 05.02.2010 16:35, gerald.j...@dgag.ca wrote:
 
  Hello there,
 
  I spent all day yesterday trying to get a small data set from Splus
into R,
  no luck!  Both, Splus and R, are run on a 64-bit RedHat Linux machine,
the
  versions of the softwares are 64-bit and are as what follows:
 
  Splus:
  TIBCO Software Inc. Confidential Information
  Copyright (c) 1988-2008 TIBCO Software Inc. ALL RIGHTS RESERVED.
  TIBCO Spotfire S+ Version 8.1.1 for Linux 2.6.9-34.EL, 64-bit : 2008
 
  R:
  R version 2.8.0 (2008-10-20)
  Copyright (C) 2008 The R Foundation for Statistical Computing
  ISBN 3-900051-07-0
 
  I know that the foreign package has a function to directly import
Splus
  data sets into R, but I also know that it is working only for 32-bit
  versions of the softwares, hence I didn't try that route.  Here is what
I
  have done:
 
  In Splus:
 
  ttt- exportData(data = FMD.CR.test,
 file =
/home/jeg002/splus/R/Exemples/R/FMD-CR-test.csv,
 type = ASCII, delimiter = @, quote = T,
na.string =
  NA)
  ttt.class- unlist(lapply(FMD.CR.test, class))
 
  ### I am using @ as delimiter since some factor levels contain both
the
  , and the ;.
 
  In R:
 
  FMD.CR.test.fields- count.fields(file =
  /home/jeg002/splus/R/Exemples/R/FMD-CR-test.csv,
  sep = @, quote = \,
comment.char =
  )
  all(FMD.CR.test.fields == 327)
  [1] TRUE  ## Hence all observations have the same number of fields, so
far,
  so good!
 
  FMD.CR.test.classes- c(factor, character, factor, factor,
  factor,
factor, factor, factor, factor,
factor,
factor, numeric, character, and so on)
  names(FMD.CR.test.classes)- c(RTA,police, mnt.rent.bnct,
mnt.rent.boni, mnt.rent.cred.bnct,
mnt.rent.epar.bnct, mnt.rent.snbn,
mnt.rent.trxl, solde.eop,
solde.nenr.es,
solde.enr.es, num.enreg, trouve, and so
on)
  FMD.CR.test-
   read.table(file =
/home/jeg002/splus/R/Exemples/R/FMD-CR-test.csv,
  header = TRUE, sep = @, quote = \, as.is = FALSE,
  strip.white = FALSE, comment.char = , na.strings =
NA,
  nrows = 65000, colClasses = FMD.CR.test.classes)
  dim(FMD.CR.test)
  [1] 64093   327  ## OK
 
  ### Testing if classes are the same as the Splus classes.
 
  FMD.CR.test.R.classes- apply(FMD.CR.test, 2, FUN = class)
  sum(FMD.CR.test.R.classes == FMD.CR.test.classes)
  [1] 79  ## Not exactly what I was expecting!
  all(FMD.CR.test.R.classes == character)
  [1] TRUE
 
  Hence all variables were imported as character, which I find very
  inconvenient; since the data set has a few hundred factor variables
  recoding them is a lot of work, this work has already been done in
Splus;
  furthermore, the numeric variables would need conversion as well.
 
  I tried all combinations of the arguments as.is, stringsAsFactors
and
  colClasses to no avail.  I also tried to export the data set in SAS
  transport format from Splus and read it through the foreign's
read.xport
  function, always the same result, everything is imported as character.
I
  search the r-help archives, I found several messages relating this
problem
  but no 

Re: [R] Importing data coming from Splus into R.

2010-02-05 Thread William Dunlap
For a data.frame with only numeric and factor
columns using dump() on the S+ end and source()
on the R end ought to work.  If you have timeDate
columns you will need to convert them to character
data before exporting and convert them to your
favorite R time/date class after importing them.

If you could send me a fairly small sample of your
data that shows the incompatibility between S+'s
write.table and R's read.table I could try to fix
things up so they were more compatible.

Code that reads the S+ native binary format must
be 32/64 bit aware, since S+ integers are 32 bits
on 32-bit versions of S+ and 64 bits on 64-bit
versions.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com  

 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Uwe Ligges
 Sent: Friday, February 05, 2010 8:05 AM
 To: Gerald Jean
 Cc: r-help@r-project.org
 Subject: Re: [R] Importing data coming from Splus into R.
 
 1. I am stuck with a copy of S-PLUS 4.x. At that time I used 
 dump() in 
 S-PLUS and source() to get things into R afterwards ...
 
 2. Why do you think that 32-bit vs. 64-bit issues matter? The file 
 format does not change (well, this is guessed since I do not have any 
 64-bit S-PLUS version available).
 
 Best,
 Uwe Ligges
 
 
 On 05.02.2010 16:35, gerald.j...@dgag.ca wrote:
 
  Hello there,
 
  I spent all day yesterday trying to get a small data set 
 from Splus into R,
  no luck!  Both, Splus and R, are run on a 64-bit RedHat 
 Linux machine, the
  versions of the softwares are 64-bit and are as what follows:
 
  Splus:
  TIBCO Software Inc. Confidential Information
  Copyright (c) 1988-2008 TIBCO Software Inc. ALL RIGHTS RESERVED.
  TIBCO Spotfire S+ Version 8.1.1 for Linux 2.6.9-34.EL, 64-bit : 2008
 
  R:
  R version 2.8.0 (2008-10-20)
  Copyright (C) 2008 The R Foundation for Statistical Computing
  ISBN 3-900051-07-0
 
  I know that the foreign package has a function to 
 directly import Splus
  data sets into R, but I also know that it is working only for 32-bit
  versions of the softwares, hence I didn't try that route.  
 Here is what I
  have done:
 
  In Splus:
 
  ttt- exportData(data = FMD.CR.test,
 file = 
 /home/jeg002/splus/R/Exemples/R/FMD-CR-test.csv,
 type = ASCII, delimiter = @, quote = 
 T, na.string =
  NA)
  ttt.class- unlist(lapply(FMD.CR.test, class))
 
  ### I am using @ as delimiter since some factor levels 
 contain both the
  , and the ;.
 
  In R:
 
  FMD.CR.test.fields- count.fields(file =
  /home/jeg002/splus/R/Exemples/R/FMD-CR-test.csv,
  sep = @, quote = 
 \, comment.char =
  )
  all(FMD.CR.test.fields == 327)
  [1] TRUE  ## Hence all observations have the same number of 
 fields, so far,
  so good!
 
  FMD.CR.test.classes- c(factor, character, factor, factor,
  factor,
factor, factor, factor, 
 factor, factor,
factor, numeric, character, 
 and so on)
  names(FMD.CR.test.classes)- c(RTA,police, mnt.rent.bnct,
mnt.rent.boni, mnt.rent.cred.bnct,
mnt.rent.epar.bnct, mnt.rent.snbn,
mnt.rent.trxl, solde.eop, 
 solde.nenr.es,
solde.enr.es, num.enreg, 
 trouve, and so on)
  FMD.CR.test-
   read.table(file = 
 /home/jeg002/splus/R/Exemples/R/FMD-CR-test.csv,
  header = TRUE, sep = @, quote = \, 
 as.is = FALSE,
  strip.white = FALSE, comment.char = , 
 na.strings = NA,
  nrows = 65000, colClasses = FMD.CR.test.classes)
  dim(FMD.CR.test)
  [1] 64093   327  ## OK
 
  ### Testing if classes are the same as the Splus classes.
 
  FMD.CR.test.R.classes- apply(FMD.CR.test, 2, FUN = class)
  sum(FMD.CR.test.R.classes == FMD.CR.test.classes)
  [1] 79  ## Not exactly what I was expecting!
  all(FMD.CR.test.R.classes == character)
  [1] TRUE
 
  Hence all variables were imported as character, which I find very
  inconvenient; since the data set has a few hundred factor variables
  recoding them is a lot of work, this work has already been 
 done in Splus;
  furthermore, the numeric variables would need conversion as well.
 
  I tried all combinations of the arguments as.is, 
 stringsAsFactors and
  colClasses to no avail.  I also tried to export the data 
 set in SAS
  transport format from Splus and read it through the 
 foreign's read.xport
  function, always the same result, everything is imported as 
 character.  I
  search the r-help archives, I found several messages 
 relating this problem
  but no satisfactory solution!
 
  I am a long time user of Splus and I am planning to use R 
 more often,
  mainly due to its wealth of packages and the convenience of 
 installing
  them.  I hope to find a reliable and convivial way of 
 transferring data
  between the two cousins pieces of software.
 
  Thanks for any insights,
 
  Gérald

Re: [R] Importing data coming from Splus into R.

2010-02-05 Thread gerald . jean
Hello Bill,

here is what I tried with the Splus built-in data set claims.

In Splus:

apply(claims, 2, class)
   age   car.age type  costnumber
 ordered ordered factor numeric numeric
dump(list = claims,
 fileout = /home/jeg002/splus/R/Exemples/R/myclaims.txt,
 oldStyle = T)  ## I tried both, oldStyle = T and oldStyle = F, same
results.

In R:

claims - source(/home/jeg002/splus/R/Exemples/R/myclaims.txt)
apply(claims$value, 2, class)  ## oldStyle = T this time.
age car.agetypecost  number
character character character character character

I must admit I had not tried using write.table from Splus.  I did, now,
always with the claims data set.  On the first attempt R complained of no
method to change the character variables to the ordered class.  I made a
copy of the data set in Splus, changed the class of two variables from
ordered to factor and gave it another try.  Here are the results:

In Splus:

new.claims - claims
class(new.claims$age) - factor
class(new.claims$car.age) - factor
apply(new.claims, 2, class)
  age  car.age type  costnumber
 factor factor factor numeric numeric
write.table(data = new.claims,
file = /home/jeg002/splus/R/Exemples/R/myclaims.txt,
sep = @, append = F, quote.strings = T,
dimnames.write = T, na = NA, end.of.row = \n,
justify.format = decimal)

In R:

claims.classes - c(character, factor, factor, factor, numeric,
numeric)  ## The first character is for the
row.names
claims -
read.table(file = /home/jeg002/splus/R/Exemples/R/myclaims.txt,
   header = TRUE, sep = @, quote = \, as.is = FALSE,
   strip.white = FALSE, comment.char = , na.strings = NA,
   nrows = 200, colClasses = claims.classes)
apply(claims, 2, class)
  row.names age car.agetypecost  number
character character character character character character


I'd be more than happy to supply you a small sample of my data set if the
built-in claims doesn't do the job.

Thanks for your support,

Gérald Jean
Conseiller senior en statistiques,
VP Planification et Développement des Marchés,
Desjardins Groupe d'Assurances Générales
télephone: (418) 835-4900 poste (7639)
télecopieur  : (418) 835-6657
courrier électronique: gerald.j...@dgag.ca

In God we trust, all others must bring data  W. Edwards Deming


William Dunlap wdun...@tibco.com a écrit sur 2010/02/05 12:37:25 :

 For a data.frame with only numeric and factor
 columns using dump() on the S+ end and source()
 on the R end ought to work.  If you have timeDate
 columns you will need to convert them to character
 data before exporting and convert them to your
 favorite R time/date class after importing them.

 If you could send me a fairly small sample of your
 data that shows the incompatibility between S+'s
 write.table and R's read.table I could try to fix
 things up so they were more compatible.

 Code that reads the S+ native binary format must
 be 32/64 bit aware, since S+ integers are 32 bits
 on 32-bit versions of S+ and 64 bits on 64-bit
 versions.

 Bill Dunlap
 Spotfire, TIBCO Software
 wdunlap tibco.com

  -Original Message-
  From: r-help-boun...@r-project.org
  [mailto:r-help-boun...@r-project.org] On Behalf Of Uwe Ligges
  Sent: Friday, February 05, 2010 8:05 AM
  To: Gerald Jean
  Cc: r-help@r-project.org
  Subject: Re: [R] Importing data coming from Splus into R.
 
  1. I am stuck with a copy of S-PLUS 4.x. At that time I used
  dump() in
  S-PLUS and source() to get things into R afterwards ...
 
  2. Why do you think that 32-bit vs. 64-bit issues matter? The file
  format does not change (well, this is guessed since I do not have any
  64-bit S-PLUS version available).
 
  Best,
  Uwe Ligges
 
 
  On 05.02.2010 16:35, gerald.j...@dgag.ca wrote:
  
   Hello there,
  
   I spent all day yesterday trying to get a small data set
  from Splus into R,
   no luck!  Both, Splus and R, are run on a 64-bit RedHat
  Linux machine, the
   versions of the softwares are 64-bit and are as what follows:
  
   Splus:
   TIBCO Software Inc. Confidential Information
   Copyright (c) 1988-2008 TIBCO Software Inc. ALL RIGHTS RESERVED.
   TIBCO Spotfire S+ Version 8.1.1 for Linux 2.6.9-34.EL, 64-bit : 2008
  
   R:
   R version 2.8.0 (2008-10-20)
   Copyright (C) 2008 The R Foundation for Statistical Computing
   ISBN 3-900051-07-0
  
   I know that the foreign package has a function to
  directly import Splus
   data sets into R, but I also know that it is working only for 32-bit
   versions of the softwares, hence I didn't try that route.
  Here is what I
   have done:
  
   In Splus:
  
   ttt- exportData(data = FMD.CR.test,
  file =
  /home/jeg002/splus/R/Exemples/R/FMD-CR-test.csv,
  type = ASCII, delimiter = @, quote =
  T, na.string =
   NA)
   ttt.class- unlist(lapply(FMD.CR.test, class

Re: [R] Importing data coming from Splus into R.

2010-02-05 Thread William Dunlap

 -Original Message-
 From: gerald.j...@dgag.ca [mailto:gerald.j...@dgag.ca] 
 Sent: Friday, February 05, 2010 10:58 AM
 To: William Dunlap
 Cc: Uwe Ligges; r-help@r-project.org
 Subject: RE: [R] Importing data coming from Splus into R.
 
 Hello Bill,
 
 here is what I tried with the Splus built-in data set claims.
 
 In Splus:
 
 apply(claims, 2, class)
age   car.age type  costnumber
  ordered ordered factor numeric numeric
 dump(list = claims,
  fileout = /home/jeg002/splus/R/Exemples/R/myclaims.txt,
  oldStyle = T)  ## I tried both, oldStyle = T and 
 oldStyle = F, same
 results.
 
 In R:
 
 claims - source(/home/jeg002/splus/R/Exemples/R/myclaims.txt)
 apply(claims$value, 2, class)  ## oldStyle = T this time.
 age car.agetypecost  number
 character character character character character
 

Use lapply(claims$value, class) instead of
apply(claims$value, 2, class).  In R apply
converts its first argument into a matrix,
which will be a character matrix if any
columns are factors.  In recent versions of
S+ apply(data.frame, MARGIN=2,...) avoids
the convert-to-matrix step and works on the
columns of the data.frame.

In this example it looks like the Splus dump - R source
route works.

R lapply(claims$value, class)
$age
[1] ordered factor

$car.age
[1] ordered factor

$type
[1] factor

$cost
[1] numeric

$number
[1] numeric

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com  

 I must admit I had not tried using write.table from Splus.  
 I did, now,
 always with the claims data set.  On the first attempt R 
 complained of no
 method to change the character variables to the ordered 
 class.  I made a
 copy of the data set in Splus, changed the class of two variables from
 ordered to factor and gave it another try.  Here are the results:
 
 In Splus:
 
 new.claims - claims
 class(new.claims$age) - factor
 class(new.claims$car.age) - factor
 apply(new.claims, 2, class)
   age  car.age type  costnumber
  factor factor factor numeric numeric
 write.table(data = new.claims,
 file = /home/jeg002/splus/R/Exemples/R/myclaims.txt,
 sep = @, append = F, quote.strings = T,
 dimnames.write = T, na = NA, end.of.row = \n,
 justify.format = decimal)
 
 In R:
 
 claims.classes - c(character, factor, factor, 
 factor, numeric,
 numeric)  ## The first character is for the
 row.names
 claims -
 read.table(file = /home/jeg002/splus/R/Exemples/R/myclaims.txt,
header = TRUE, sep = @, quote = \, as.is = FALSE,
strip.white = FALSE, comment.char = , 
 na.strings = NA,
nrows = 200, colClasses = claims.classes)
 apply(claims, 2, class)
   row.names age car.agetypecost   
number
 character character character character character 
 character
 
 
 I'd be more than happy to supply you a small sample of my 
 data set if the
 built-in claims doesn't do the job.
 
 Thanks for your support,
 
 Gérald Jean
 Conseiller senior en statistiques,
 VP Planification et Développement des Marchés,
 Desjardins Groupe d'Assurances Générales
 télephone: (418) 835-4900 poste (7639)
 télecopieur  : (418) 835-6657
 courrier électronique: gerald.j...@dgag.ca
 
 In God we trust, all others must bring data  W. Edwards Deming
 
 
 William Dunlap wdun...@tibco.com a écrit sur 2010/02/05 12:37:25 :
 
  For a data.frame with only numeric and factor
  columns using dump() on the S+ end and source()
  on the R end ought to work.  If you have timeDate
  columns you will need to convert them to character
  data before exporting and convert them to your
  favorite R time/date class after importing them.
 
  If you could send me a fairly small sample of your
  data that shows the incompatibility between S+'s
  write.table and R's read.table I could try to fix
  things up so they were more compatible.
 
  Code that reads the S+ native binary format must
  be 32/64 bit aware, since S+ integers are 32 bits
  on 32-bit versions of S+ and 64 bits on 64-bit
  versions.
 
  Bill Dunlap
  Spotfire, TIBCO Software
  wdunlap tibco.com
 
   -Original Message-
   From: r-help-boun...@r-project.org
   [mailto:r-help-boun...@r-project.org] On Behalf Of Uwe Ligges
   Sent: Friday, February 05, 2010 8:05 AM
   To: Gerald Jean
   Cc: r-help@r-project.org
   Subject: Re: [R] Importing data coming from Splus into R.
  
   1. I am stuck with a copy of S-PLUS 4.x. At that time I used
   dump() in
   S-PLUS and source() to get things into R afterwards ...
  
   2. Why do you think that 32-bit vs. 64-bit issues matter? The file
   format does not change (well, this is guessed since I do 
 not have any
   64-bit S-PLUS version available).
  
   Best,
   Uwe Ligges
  
  
   On 05.02.2010 16:35, gerald.j...@dgag.ca wrote:
   
Hello there,
   
I spent all day yesterday trying to get a small data set
   from Splus into R

Re: [R] importing data from BUGS format to R?

2010-01-05 Thread Pseudomonas


Martyn Plummer-2 wrote:
 
 I wrote a function called bugs2jags, which you will find in the coda
 package, for converting WinBUGS data files into the data format used by
 JAGS which is, by no coincidence, the format used by the R function
 dump().
 

First of all excuse me for reviving this very old thread - if it is the
preferred way in this forum/ mailinglist, I will start a new one instead.
I'm a computational biologist programming in C++ and I'm actually not
familiar with R. But I wrote a small program to analyse Win-/OpenBugs output
(CODA) according to this paper:
http://dx.doi.org/10.1016/j.anbehav.2004.08.011 . As I'm working with Mac
and Linux (Kubuntu 9.10 „Karmic Koala“ at the moment) and WINbugs only runs
on Windows natively (as it's name says), I want to switch to JAGS instead.
Now I have the problem to change the WinBugs formatted model and data into
JAGS/R formatted ones, which is quite difficult without knowing the actual
differences between R and S(-PLUS) programming languages. (The latter one
seems to be the basis of WinBugs' format.) I'm not completely sure whether
bugs2jags can be applied to this case, but when I tried to execute it with
the main example from the above mentioned paper (see attachment), it showed
this error message:

 library(coda)
Lade nötiges Paket: lattice
 bugs2jags(WinBugs.txt,Jags.txt)
Fehler in parse(file = file) :
  WinBugs.txt:19:9: Unerwartetes Symbol
18: list(individuals = 5, dyads = 9)
19: ind1[ ] ind2
^


Thank you in anticipation
Sascha Siemann

http://n4.nabble.com/file/n998943/WinBugs.txt WinBugs.txt 
-- 
View this message in context: 
http://n4.nabble.com/importing-data-from-BUGS-format-to-R-tp794525p998943.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] Importing data from text file with mixed format

2009-10-26 Thread delnatan

All these have been really helpful. Once again I see that anything's possible
in R! 

Thank you for the suggestion Bill, I think arranging the data in one data
frame is a good idea.

-Daniel


William Dunlap wrote:
 
 
 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of delnatan
 Sent: Saturday, October 24, 2009 8:32 PM
 To: r-help@r-project.org
 Subject: [R] Importing data from text file with mixed format
 
 
 Hi,
 I'm having difficulty importing my textfile that looks 
 something like this:
 
 #begin text file
 Timepoint 1
 ObjectNumber Volume SurfaceArea
 1  5.3  9.7
 2  4.9  8.3
 3  5.0  9.1
 4  3.5  7.8
 
 Timepoint 2
 ObjectNumber Volume SurfaceArea
 1  5.1  9.0
 2  4.7  8.9
 3  4.3  8.3
 4  4.2  7.9
 
 ... #goes on to Timepoint 80
 
 How would I import this data into a list containing 
 data.frame for each
 timepoint?
 I'd like my data to be organized like this:
 
 myList
 [[1]]
ObjectNumber Volume SurfaceArea
 1  1  5.3  9.7
 2  2  4.9  8.3
 3  3  5.0  9.1
 4  4  3.5  7.8
 
 [[2]]
   ObjectNumber Volume SurfaceArea
 1 1  5.1  9.0
 2 2  4.7  8.9
 3 3  4.3  8.3
 4 4  4.2  7.9
 
 The following function reads that text file into one data.frame,
 which has a Timepoint column, which is a format I usually find
 more convenient.  You can use split(data, data$Timepoint)
 to get to the format you asked for.  If you use the one-data-frame
 format you can use the cast and melt functions from the reshape
 package to rearrange it.
 
 readMyData - function (file) {
 # read every line in the file
 lines - readLines(file)
 # drop empty lines
 lines - grep(^[[:space:]]*$, lines, value=TRUE, invert=TRUE)
 # find and check header lines
 isHeaderLine - regexpr(^ObjectNumber, lines)  0
 if (sum(isHeaderLine)==0)
 stop(No header lines of form 'ObjectNumber ...')
 if (length(u - unique(lines[isHeaderLine]))1)
 stop(Header lines vary: , paste(sQuote(head(u)), collapse=,
 ))
 col.names - strsplit(lines[which(isHeaderLine)[1]],
 [[:space:]]+)[[1]]
 # after making column names from header lines, drop header lines
 lines - lines[!isHeaderLine]
 # process Timepoint lines
 isTimepointLine - regexpr(^Timepoint, lines)  0
 if (sum(isTimepointLine)==0)
 stop(No lines of form 'Timepoint number')
 timepoints - sub(^Timepoint[[:space:]]*, ,
 lines[isTimepointLine])
 timepoints - as.integer(timepoints)
 if (any(is.na(timepoints)))
 stop(Non-integer found in a Timepoint line: ,
 sQuote(lines[isTimepointLine][which(is.na(timepoints))[1]]))
 nRowsPerTimepoint -
 diff(c(which(isTimepointLine),length(isTimepointLine)+1)) - 1
 # drop Timepoint lines.  Remaining lines should be data lines
 lines - lines[!isTimepointLine]
 # An error in read.table means there were lines we should have
 dropped
 result - read.table(header=FALSE,
 row.names=NULL,
 col.names=col.names,
 textConnection(lines))
 # Add Timepoint column
 result$Timepoint - rep(timepoints, nRowsPerTimepoint)
 result 
 }
 
 E.g.,
 data - readMyData(c:/temp/t.txt)
 data
   ObjectNumber Volume SurfaceArea Timepoint
 115.3 9.7 1
 224.9 8.3 1
 335.0 9.1 1
 443.5 7.8 1
 515.1 9.0 2
 624.7 8.9 2
 734.3 8.3 2
 844.2 7.9 2
 split(data, data$Timepoint)
 $`1`
   ObjectNumber Volume SurfaceArea Timepoint
 115.3 9.7 1
 224.9 8.3 1
 335.0 9.1 1
 443.5 7.8 1
 
 $`2`
   ObjectNumber Volume SurfaceArea Timepoint
 515.1 9.0 2
 624.7 8.9 2
 734.3 8.3 2
 844.2 7.9 2
 mdata - melt(data, id=c(ObjectNumber,Timepoint))
 cast(mdata, Timepoint~variable, fun.aggregate=c,
 subset=variable==SurfaceArea)
   Timepoint SurfaceArea_X1 SurfaceArea_X2 SurfaceArea_X3 SurfaceArea_X4
 1 19.78.39.17.8
 2 29.08.98.37.9
 cast(mdata, ObjectNumber~variable, fun.aggregate=c,
 subset=variable==SurfaceArea)
  

Re: [R] Importing data from text file with mixed format

2009-10-25 Thread jim holtman
try this:

 # read in the file
 x - readLines(textConnection(#begin text file
+ Timepoint 1
+ ObjectNumber Volume SurfaceArea
+ 1  5.3  9.7
+ 2  4.9  8.3
+ 3  5.0  9.1
+ 4  3.5  7.8
+
+ Timepoint 2
+ ObjectNumber Volume SurfaceArea
+ 1  5.1  9.0
+ 2  4.7  8.9
+ 3  4.3  8.3
+ 4  4.2  7.9))
 # delete blank lines
 blanks - grep(^\\s*$, x)
 if (length(blanks)  0) x - x[-blanks]
 # determine where Timepoint occurs in the text vector
 tp - grep(^Timepoint, x)
 # append length+1 to the result
 tp - c(tp, length(x) + 3)
 input - textConnection(x)
 # skip to the first Timepoint if not first line
 if (tp[1] != 1) readLines(input, n=tp[1] - 1)
[1] #begin text file
 result - list()
 # repeat for each Timepoint
 for (numLines in diff(tp)){  # repeat for number of lines to read
+ id - readLines(input, n=1)
+ result[[id]] - read.table(input, header=TRUE, nrows=numLines - 2)
+ }
 result
$`Timepoint 1`
  ObjectNumber Volume SurfaceArea
115.3 9.7
224.9 8.3
335.0 9.1
443.5 7.8

$`Timepoint 2`
  ObjectNumber Volume SurfaceArea
115.1 9.0
224.7 8.9
334.3 8.3
444.2 7.9

 closeAllConnections()


On Sat, Oct 24, 2009 at 11:31 PM, delnatan delna...@gmail.com wrote:

 Hi,
 I'm having difficulty importing my textfile that looks something like this:

 #begin text file
 Timepoint 1
 ObjectNumber     Volume     SurfaceArea
 1                      5.3          9.7
 2                      4.9          8.3
 3                      5.0          9.1
 4                      3.5          7.8

 Timepoint 2
 ObjectNumber     Volume     SurfaceArea
 1                      5.1          9.0
 2                      4.7          8.9
 3                      4.3          8.3
 4                      4.2          7.9

 ... #goes on to Timepoint 80

 How would I import this data into a list containing data.frame for each
 timepoint?
 I'd like my data to be organized like this:

myList
 [[1]]
   ObjectNumber     Volume     SurfaceArea
 1  1                      5.3          9.7
 2  2                      4.9          8.3
 3  3                      5.0          9.1
 4  4                      3.5          7.8

 [[2]]
  ObjectNumber     Volume     SurfaceArea
 1 1                      5.1          9.0
 2 2                      4.7          8.9
 3 3                      4.3          8.3
 4 4                      4.2          7.9

 -Daniel
 --
 View this message in context: 
 http://www.nabble.com/Importing-data-from-text-file-with-mixed-format-tp26045031p26045031.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.




-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

__
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] Importing data from text file with mixed format

2009-10-25 Thread William Dunlap

 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of delnatan
 Sent: Saturday, October 24, 2009 8:32 PM
 To: r-help@r-project.org
 Subject: [R] Importing data from text file with mixed format
 
 
 Hi,
 I'm having difficulty importing my textfile that looks 
 something like this:
 
 #begin text file
 Timepoint 1
 ObjectNumber Volume SurfaceArea
 1  5.3  9.7
 2  4.9  8.3
 3  5.0  9.1
 4  3.5  7.8
 
 Timepoint 2
 ObjectNumber Volume SurfaceArea
 1  5.1  9.0
 2  4.7  8.9
 3  4.3  8.3
 4  4.2  7.9
 
 ... #goes on to Timepoint 80
 
 How would I import this data into a list containing 
 data.frame for each
 timepoint?
 I'd like my data to be organized like this:
 
 myList
 [[1]]
ObjectNumber Volume SurfaceArea
 1  1  5.3  9.7
 2  2  4.9  8.3
 3  3  5.0  9.1
 4  4  3.5  7.8
 
 [[2]]
   ObjectNumber Volume SurfaceArea
 1 1  5.1  9.0
 2 2  4.7  8.9
 3 3  4.3  8.3
 4 4  4.2  7.9

The following function reads that text file into one data.frame,
which has a Timepoint column, which is a format I usually find
more convenient.  You can use split(data, data$Timepoint)
to get to the format you asked for.  If you use the one-data-frame
format you can use the cast and melt functions from the reshape
package to rearrange it.

readMyData - function (file) {
# read every line in the file
lines - readLines(file)
# drop empty lines
lines - grep(^[[:space:]]*$, lines, value=TRUE, invert=TRUE)
# find and check header lines
isHeaderLine - regexpr(^ObjectNumber, lines)  0
if (sum(isHeaderLine)==0)
stop(No header lines of form 'ObjectNumber ...')
if (length(u - unique(lines[isHeaderLine]))1)
stop(Header lines vary: , paste(sQuote(head(u)), collapse=,
))
col.names - strsplit(lines[which(isHeaderLine)[1]],
[[:space:]]+)[[1]]
# after making column names from header lines, drop header lines
lines - lines[!isHeaderLine]
# process Timepoint lines
isTimepointLine - regexpr(^Timepoint, lines)  0
if (sum(isTimepointLine)==0)
stop(No lines of form 'Timepoint number')
timepoints - sub(^Timepoint[[:space:]]*, ,
lines[isTimepointLine])
timepoints - as.integer(timepoints)
if (any(is.na(timepoints)))
stop(Non-integer found in a Timepoint line: ,
sQuote(lines[isTimepointLine][which(is.na(timepoints))[1]]))
nRowsPerTimepoint -
diff(c(which(isTimepointLine),length(isTimepointLine)+1)) - 1
# drop Timepoint lines.  Remaining lines should be data lines
lines - lines[!isTimepointLine]
# An error in read.table means there were lines we should have
dropped
result - read.table(header=FALSE,
row.names=NULL,
col.names=col.names,
textConnection(lines))
# Add Timepoint column
result$Timepoint - rep(timepoints, nRowsPerTimepoint)
result 
}

E.g.,
 data - readMyData(c:/temp/t.txt)
 data
  ObjectNumber Volume SurfaceArea Timepoint
115.3 9.7 1
224.9 8.3 1
335.0 9.1 1
443.5 7.8 1
515.1 9.0 2
624.7 8.9 2
734.3 8.3 2
844.2 7.9 2
 split(data, data$Timepoint)
$`1`
  ObjectNumber Volume SurfaceArea Timepoint
115.3 9.7 1
224.9 8.3 1
335.0 9.1 1
443.5 7.8 1

$`2`
  ObjectNumber Volume SurfaceArea Timepoint
515.1 9.0 2
624.7 8.9 2
734.3 8.3 2
844.2 7.9 2
 mdata - melt(data, id=c(ObjectNumber,Timepoint))
 cast(mdata, Timepoint~variable, fun.aggregate=c,
subset=variable==SurfaceArea)
  Timepoint SurfaceArea_X1 SurfaceArea_X2 SurfaceArea_X3 SurfaceArea_X4
1 19.78.39.17.8
2 29.08.98.37.9
 cast(mdata, ObjectNumber~variable, fun.aggregate=c,
subset=variable==SurfaceArea)
  ObjectNumber SurfaceArea_X1 SurfaceArea_X2
119.79.0
228.38.9
339.18.3
447.87.9

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

 
 -Daniel
 -- 

Re: [R] Importing data from text file with mixed format

2009-10-25 Thread Gabor Grothendieck
This solution uses strapply in gsubfn. It assumes the timepoints are
1, 2, 3, ... (although later we remove this restriction just in case).

The first line reads in myfile. The second line reads the numeric rows
into matrix s.  The third line reads in the column names.  The fourth
line converts to data frame and adds the Timepoint column numbering
the first data set 1, the second 2, etc.  (also known as long form)
and the fifth line is the result.


library(gsubfn)
L - readLines(myfile)
s - strapply(L, ^([0-9]+) +([0-9.]+) +([0-9.]+) *$, c, simplify = rbind)
colnames(s) - c(read.table(myfile, FALSE, nrow = 1, skip = 1, as.is = TRUE))
DF - transform(s, Timepoint = cumsum(DF$ObjectNumber == 1))
split(DF[-4], DF[4])


If the timepoints are not necessarily 1, 2, 3, ... then replace the
last line with this (which extracts the timepoints and assigns them):

Timepoint - c(strapply(L, Timepoint *([0-9]+), as.numeric, simplify = rbind))
DF$Timepoint - Timepoint[DF$Timepoint]
split(DF[-4], DF[4])


On Sat, Oct 24, 2009 at 11:31 PM, delnatan delna...@gmail.com wrote:

 Hi,
 I'm having difficulty importing my textfile that looks something like this:

 #begin text file
 Timepoint 1
 ObjectNumber     Volume     SurfaceArea
 1                      5.3          9.7
 2                      4.9          8.3
 3                      5.0          9.1
 4                      3.5          7.8

 Timepoint 2
 ObjectNumber     Volume     SurfaceArea
 1                      5.1          9.0
 2                      4.7          8.9
 3                      4.3          8.3
 4                      4.2          7.9

 ... #goes on to Timepoint 80

 How would I import this data into a list containing data.frame for each
 timepoint?
 I'd like my data to be organized like this:

myList
 [[1]]
   ObjectNumber     Volume     SurfaceArea
 1  1                      5.3          9.7
 2  2                      4.9          8.3
 3  3                      5.0          9.1
 4  4                      3.5          7.8

 [[2]]
  ObjectNumber     Volume     SurfaceArea
 1 1                      5.1          9.0
 2 2                      4.7          8.9
 3 3                      4.3          8.3
 4 4                      4.2          7.9

 -Daniel
 --
 View this message in context: 
 http://www.nabble.com/Importing-data-from-text-file-with-mixed-format-tp26045031p26045031.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.


__
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] Importing data into R and combining 2 files

2009-05-14 Thread jim holtman
What have you tried?  Check the Intro manual for hints.

?read.table   probably using sep='\t'

On Thu, May 14, 2009 at 1:30 PM, Sunita22 sunita...@gmail.com wrote:


 Hello

 I have to import 2 txt files into R. 1 file contains the data and the other
 contains the header, column headings, datatypes and labels for the data.

 I have 2 problems:

 1) my data file has mixed type of data e.g. 1 2 3 4 5 3-5 02/04/06 3 4 5
 and
 so on, the data file is tab separated. when I import it, the data is
 getting
 stored in one single variable say V1. I need to separate it into rows and
 columns. how do I this? Which commands in R would be useful for the same?

 2) The other file is also tab separated. the 6 lines contains header and
 introduction as in the name of the dataset, year, etc. and then column
 names
 its datatypes and labels. After importing the data in this file also gets
 stored in one single variable. I need to separate it into rows and columns.
 how do I this? Which commands in R would be useful for the same?

 Thank you in advance

 Regards
 Sunita
 --
 View this message in context:
 http://www.nabble.com/Importing-data-into-R-and-combining-2-files-tp23545291p23545291.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.htmlhttp://www.r-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

[[alternative HTML version deleted]]

__
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] Importing data into R and combining 2 files

2009-05-14 Thread Sunita Patil
Hello

Yes I have used read.table(file name, sep=\t) for reading the text file

Thank you

On Thu, May 14, 2009 at 11:07 PM, jim holtman jholt...@gmail.com wrote:

 What have you tried?  Check the Intro manual for hints.

 ?read.table   probably using sep='\t'

 On Thu, May 14, 2009 at 1:30 PM, Sunita22 sunita...@gmail.com wrote:


 Hello

 I have to import 2 txt files into R. 1 file contains the data and the
 other
 contains the header, column headings, datatypes and labels for the data.

 I have 2 problems:

 1) my data file has mixed type of data e.g. 1 2 3 4 5 3-5 02/04/06 3 4 5
 and
 so on, the data file is tab separated. when I import it, the data is
 getting
 stored in one single variable say V1. I need to separate it into rows and
 columns. how do I this? Which commands in R would be useful for the same?

 2) The other file is also tab separated. the 6 lines contains header and
 introduction as in the name of the dataset, year, etc. and then column
 names
 its datatypes and labels. After importing the data in this file also gets
 stored in one single variable. I need to separate it into rows and
 columns.
 how do I this? Which commands in R would be useful for the same?

 Thank you in advance

 Regards
 Sunita
 --
 View this message in context:
 http://www.nabble.com/Importing-data-into-R-and-combining-2-files-tp23545291p23545291.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.htmlhttp://www.r-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




 --
 Jim Holtman
 Cincinnati, OH
 +1 513 646 9390

 What is the problem that you are trying to solve?




-- 
Our Thoughts have the Power to Change our Destiny.
Sunita

[[alternative HTML version deleted]]

__
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] Importing data into R and combining 2 files

2009-05-14 Thread Andy Choens
On Thu, 2009-05-14 at 10:30 -0700, Sunita22 wrote:
 Hello
 
 I have to import 2 txt files into R. 1 file contains the data and the other
 contains the header, column headings, datatypes and labels for the data.
 

This is your first complicating factor.

 I have 2 problems:
 
 1) my data file has mixed type of data e.g. 1 2 3 4 5 3-5 02/04/06 3 4 5 and
 so on, the data file is tab separated. when I import it, the data is getting
 stored in one single variable say V1. I need to separate it into rows and
 columns. how do I this? Which commands in R would be useful for the same?
 

This shouldn't be too hard.

 2) The other file is also tab separated. the 6 lines contains header and
 introduction as in the name of the dataset, year, etc. and then column names
 its datatypes and labels. After importing the data in this file also gets
 stored in one single variable. I need to separate it into rows and columns.
 how do I this? Which commands in R would be useful for the same?
 

This isn't that hard either, but it's not all in the best place.


The following is my 2 cents on this. I don't know what platform you are
on, so it's possible that my reference to sed may be more trouble than
it's worth. You have it if you are running Linux or OS X. 

Your data structure is part of the problem. Where is this data set
coming from? That could be a key piece of information that could help
someone show you a short cut. 

I would start by rolling your two files together into one big happy tab
separated file. You can remove the header entirely. It's just going to
get in the way. I am assuming that the order of your variables
(horizontally) are in the same order in the two files. I would double
check that these are in the same horizontal oder before actually
proceeding any further.

Delete the header. It's not going to to import correctly with
read.table(). You could stick this in as a note in your .R code if you
would like. (#)

As for labels, it is often easier in R to drop the integer = factor
label structure found in programs like SPSS. Rather than 1=Yes 5=No I
use Yes and No in the actual data. For most categorical data, this makes
it easier to work with. For ordinal data it can be more of a problem
though. If it's all just categorical, I would use a tool such as sed
(Linux/Unix commandline) to go through and apply my labels. Or you can
pull the data into R first and then do this with R. It's your choice. If
you are on Windows and don't know what sed is, forget about sed and just
use R to reassign your variables. R may make your life easier here.

When you use read.table to import your text file, it will store it in a
single variable. This variable will be a data frame and should preserve
your individual columns and rows. If you aren't familiar with data
frames, you should really start with some introductory material. I will
assume that you are in a hurry. There are some really great texts such
as Introduction to R that you should read, but a quick primer can be
found at:

http://www.statmethods.net/index.html

This is an especially good link if you've ever used SPSS/PSPP before
trying to use R, since the author also started in SPSS and understands
how/why R is confusing to people making this switch. There are also some
good links to other introductory materials that you should read.

Since you have all of your labels in a separate

Note: You will get more help on this forum if your request for help
includes reproducible code/information. Thus, if you told us how to
reproduce a dummy example of your two text file, (although this may be
private/proprietary), examples of the code you have tried and what you
get as a result usually results in better answers.



-- 
This is the price and the promise of citizenship.
- Barack Obama

__
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] importing data to SQLite database with sqldf

2009-02-21 Thread Gabor Grothendieck
WARNING!!!

Not a good idea to post code that deletes every object
in your workspace!   Other people may blindly copy
and paste your code.

I've added some verbiage to Example 12 on the home
page:
http://sqldf.googlecode.com
that hopefully clarifies it a bit.

On Sat, Feb 21, 2009 at 2:36 AM, Stephen Tucker brown_...@yahoo.com wrote:
 Thanks yet another time, Gabor -
 I think I am slowly understanding - particularly I was confused by 
 persistence of connections.

 So starting with some parts of your example 12,

 ##

... deleted code which clears workspace ...

 sqldf(attach 'mydb' as new)
 irishead - file(irishead.dat)
 iristail - file(iristail.dat)

 If I just wanted to merge the two files within SQL and return some part of 
 the result, I would do

 sqldf('select count(*) from (select * from irishead
 union
 select * from iristail)',dbname=mydb)

 and the tables exist in mydb only for the duration of the computation
 sqldf(select * from sqlite_master,dbname=mydb)$name
 NULL
 (but why is the size of mydb  0 afterwards, if it contains no tables...?)

 ...is the above the same as
 sqldf('select count(*) from (select * from irishead
 union
 select * from iristail)',dbname=tempfile())

 except that I don't create 'mydb'?

Yes.  The third possibility is to omit dbname= entirely and then it uses
a temporary in memory database.


 If I wanted to save the merged table (for use in a later session):

 sqldf('create table fulliris as select * from irishead
 union
 select * from iristail',dbname=mydb)

 sqldf(select * from sqlite_master,dbname=mydb)$name
 [1] fulltable
 Levels: fulltable

 If I want copies of all three tables,
 sqldf(dbname=mydb)
 sqldf('create table fulltable as select * from irishead
 union
 select * from iristail')
 sqldf()

 sqldf(select * from sqlite_master,dbname=mydb)$name
 [1] irishead  iristail  fulltable
 Levels: fulltable irishead iristail

 ? ...I'll try to go figure a few more things out in the in the meantime (like 
 using sep=\t ?) and using connections with sqldf().

 But thanks for the help!

 Stephen

 - Original Message 
 From: Gabor Grothendieck ggrothendi...@gmail.com
 To: Stephen Tucker brown_...@yahoo.com
 Cc: R-help r-h...@stat.math.ethz.ch
 Sent: Friday, February 20, 2009 5:22:09 AM
 Subject: Re: [R] importing data to SQLite database with sqldf

 Have just added an example 12 on the home page:

 http://sqldf.googlecode.com

 that shows an example.  Note use of notation
 main.mytable to refer to an existing table in the
 main database (as opposed to a data frame in R).

 On Thu, Feb 19, 2009 at 11:55 PM, Stephen Tucker brown_...@yahoo.com wrote:
 Hi all,

 I am attempting to learn SQL through sqldf...

 One task I am particularly interested in is merging separate
 (presumably large) files into a single table without loading these
 files into R as an intermediate step (by loading them into SQLite and
 merging them there).

 Taking a step back, I've considered these alternatives:

 1) I know if I use straight SQLite commands I might use the 'IMPORT'
 or 'INSERT INTO' command, which is not terribly flexible...  (I can
 read large files line-by-line in Python and use the 'INSERT INTO'
 command, which is reasonably fast; I could do this in R as well but my
 experience with R's input/output is that it's much slower...? and
 sometimes setting up the table column definitions can be tedious if
 there are many variables).

 2) dbWriteTable() with append=TRUE is very convenient except that it
 requires I load the data into R first...

 3) sqldf's capability to put data directly into a database is
 something I'd like to work out.

 So in this case I have a series of tab-delimited text file with the
 first line being a header.

 For some reason I cannot seem to get it working.  Combining examples 6
 and 9 from the Google Code page (and R-help archives), I tried

 source(http://sqldf.googlecode.com/svn/trunk/R/sqldf.R;)
 (do I need it for SQLite?)
 ##
 sqldf(attach 'mydb.db' as new)
 f - file(myexample.txt)
 attr(f,file.format) - list(header=TRUE,sep=\t)
 sqldf(create table myexample as select * from f,
  stringsAsFactors=FALSE,
  dbname=mydb.db)
 ## or
 f - file(fi)
 sqldf(create table myexample as select * from f,
  stringsAsFactors=FALSE,file.format=list(header=TRUE,sep=\t),
  dbname=mydb.db)
 ##
 sqldf(select * from myexample,dbname=mydb.db)
 gives me tables with 0 rows and 0 columns...

 So in any case I have a few questions:

 === 1 
 Would this be scalable to files with few GBs of data in them (I guess
 I am uncertain of the underlying mechanism for transporting data from
 the .txt file to the .db file... I see there is a call the
 dbWriteTable() internally in sqldf but through the connection)?  And
 is there anything obviously doing wrong above?

 === 2 ===
 Since I cannot 'append' rows to existing tables in SQLite (or any SQL
 database), I think what I would have to do is to load each of the
 files into the database and then 'rbind' them into a new

Re: [R] importing data to SQLite database with sqldf

2009-02-20 Thread Gabor Grothendieck
Have just added an example 12 on the home page:

http://sqldf.googlecode.com

that shows an example.  Note use of notation
main.mytable to refer to an existing table in the
main database (as opposed to a data frame in R).

On Thu, Feb 19, 2009 at 11:55 PM, Stephen Tucker brown_...@yahoo.com wrote:
 Hi all,

 I am attempting to learn SQL through sqldf...

 One task I am particularly interested in is merging separate
 (presumably large) files into a single table without loading these
 files into R as an intermediate step (by loading them into SQLite and
 merging them there).

 Taking a step back, I've considered these alternatives:

 1) I know if I use straight SQLite commands I might use the 'IMPORT'
 or 'INSERT INTO' command, which is not terribly flexible...  (I can
 read large files line-by-line in Python and use the 'INSERT INTO'
 command, which is reasonably fast; I could do this in R as well but my
 experience with R's input/output is that it's much slower...? and
 sometimes setting up the table column definitions can be tedious if
 there are many variables).

 2) dbWriteTable() with append=TRUE is very convenient except that it
 requires I load the data into R first...

 3) sqldf's capability to put data directly into a database is
 something I'd like to work out.

 So in this case I have a series of tab-delimited text file with the
 first line being a header.

 For some reason I cannot seem to get it working.  Combining examples 6
 and 9 from the Google Code page (and R-help archives), I tried

 source(http://sqldf.googlecode.com/svn/trunk/R/sqldf.R;)
 (do I need it for SQLite?)
 ##
 sqldf(attach 'mydb.db' as new)
 f - file(myexample.txt)
 attr(f,file.format) - list(header=TRUE,sep=\t)
 sqldf(create table myexample as select * from f,
  stringsAsFactors=FALSE,
  dbname=mydb.db)
 ## or
 f - file(fi)
 sqldf(create table myexample as select * from f,
  stringsAsFactors=FALSE,file.format=list(header=TRUE,sep=\t),
  dbname=mydb.db)
 ##
 sqldf(select * from myexample,dbname=mydb.db)
 gives me tables with 0 rows and 0 columns...

 So in any case I have a few questions:

 === 1 
 Would this be scalable to files with few GBs of data in them (I guess
 I am uncertain of the underlying mechanism for transporting data from
 the .txt file to the .db file... I see there is a call the
 dbWriteTable() internally in sqldf but through the connection)?  And
 is there anything obviously doing wrong above?

 === 2 ===
 Since I cannot 'append' rows to existing tables in SQLite (or any SQL
 database), I think what I would have to do is to load each of the
 files into the database and then 'rbind' them into a new table using
 'union all'? The following code is what I have (the part where I read
 in each file before dumping into the database file would hopefully be
 replaced by the method above, if it can be made to work).

 ## (1) create a database file
 sqldf(attach 'alltables.db' as new)
 ## (2) convenience function
 sql - function(...) sqldf(...,dbname=alltables.db)
 ## (3) load data as separate tables
 for( fi in list.files(.,txt$) ) {
  mydata - read.delim(fi)
  sql(sprintf(create table %s as select * from mydata,sub(\\.txt,,fi)))
 }
 rm(fi,mydata)
 ## (4) merge tables
 tablenames - as.character(sql(select * from sqlite_master)$name)
 sql(paste(create table myfulltable as,
  paste(sprintf(select * from %s,tablenames),
collapse= union all )))
 ## (5) delete separate tables since we have a merged one
 for( nm in tablenames ) sql(sprintf(drop table %s,nm))

 === 3 ===
 The following command
 sqldf(attach 'mydb.db' as new)
 DF - read.delim(fi)
 sqldf(create table myexample as select * from DF,dbname=mydb.db)

 will usually create a .db file twice the size of the .txt file (for
 now I am playing with a files ~500KB so the .db files are around
 ~1MB). When I create a .db file using SQLite's 'import' command,
 RSQLite's dbWriteTable(), or inserting values from the same .txt file
 from Python's SQLite interface, I get .db files that are approximately
 the same size as the .txt file (~500KB). Is the larger file size for
 sqldf's method expected?

 Many thanks in advance!

 Stephen Tucker

 __
 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] importing data from a disc or HDD [SEC=UNCLASSIFIED]

2009-02-02 Thread Paul Hiemstra

Kisch, Joe wrote:

I hope this is not a stupid question, but I am having difficulty
importing data from sources like CDs, HDD, or flashcards.  Can anyone
help ?

 


Joe


[[alternative HTML version deleted]]

__
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.
  

Hi Joe,

If you are not specific about your system and about the exact problem 
you have (please read the posting guide), it is very hard for us to give 
advice.


cheers,
Paul

--
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone:  +31302535773
Fax:+31302531145
http://intamap.geo.uu.nl/~paul

__
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] Importing data from clipboard on Mac OSX

2009-01-29 Thread Charles C. Berry

On Thu, 29 Jan 2009, Christian Anderson wrote:


Hello R-Help,

I noticed that there is a thread about importing data from the clipboard
that is very poorly answered in the forum. One user suggests giving up, the
other gives a solution that echoes the clipboard, but that's exactly the
same as just ctrl-p. As I am asked this question at least once a week in my
very small home institution, I'm sure many people want to know. If you could
post somewhere that for most Macs you can

read.table(pipe(pbpaste)) will work for almost all applications, that
would be very helpful.



?pipe says:


 Clipboard:

 ...

 MacOS X users can use 'pipe(pbpaste)' and 'pipe(pbcopy, w)'
 to read from and write to that system's clipboard.


HTH,

Chuck




Thank you,
Christian Anderson




[[alternative HTML version deleted]]

__
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.



Charles C. Berry(858) 534-2098
Dept of Family/Preventive Medicine
E mailto:cbe...@tajo.ucsd.edu   UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

__
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] Importing data from SPSS with Arabic encoding

2009-01-07 Thread Prof Brian Ripley

On Wed, 7 Jan 2009, Florent Bresson wrote:


Dear R-users,

I'm facing a problem with the import of data in R. I have a sav file that, I 
presume, uses some Arabic encoding (but I don't know which one) and I would 
like to read it with R. When I use the function read.spss (I also tried 
spss.get(Hmisc)), I get the following message:

read.spss(Hhld.sav)

Erreur dans read.spss(Hhld.sav) :
 erreur à la lecture de l'entête du fichier système
De plus : Warning message:
In read.spss(Hhld.sav) :
 Hhld.sav : position 0 : le nom de la variable commence avec un caractère non 
autorisé

The second and last lines can be translated into error reading 
system-file header and Hhld.sav: position 0: Variable name begins with 
invalid character. That's why I suppose it is a problem with the 
encoding. Does someone has an idea of the solution to my problem?


1) Please read the posting guide and supply the details you were asked to 
supply. E.g. what OS, what locale, what version of foreigh?


2) Read the help for read.spss, especially its 'reencode' argument. You 
will need to know what the encoding was, but most likely the output before 
the error which (you did not show us) told you (and would have told us).


BTW, if you start R with LANGUAGE=en set, you will get English messages to 
quote here.



PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595__
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] Importing data to a multidimensional array

2008-11-05 Thread Uwe Ligges



Jon Wong wrote:

Hi,
I was wondering if I could get some help on importing data into a
three-dimensional array?

I am importing data from several text files:

dsdir-c:/documents and settings/desktop/07082008/ # path to files
dsfb1-07082008-DI4129b.dat # file base name

firsthour-13 # first hour of observation which changes from 6am to 1pm from
day to day
lasthour-20 # last hour of observation which also changes from 6 - 8pm

for(i in firsthour:lasthour)
assign(paste(ds,i,a,sep=),read.delim(file=paste(dsdir,i,dsfb1,sep=),
header=F, sep=\t, skip=5))



Always a bad idea to make such assignment, better assign into a list 
ds with elements called a13...a20, for example.
You can easily make it 3D by unlist() it and assigning new dim() 
attributes afterwards, for example.


Or perhaps even better, read each data.frame, coerce to a matrix which 
you insert into the correct position of a pre-defined array().


Uwe Ligges



This code generates matrices from ds13a:ds20a containing data from the
respective text files, but I need this in a three-dimensional array for
further processing.  The observation counts in the imported files vary from
one to another, and there is never a set number of files to be imported.
 Any help is greatly appreciated.  Thanks

Sincerely,
Jon

[[alternative HTML version deleted]]

__
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] Importing data with different delimters

2008-06-16 Thread Greg Snow
It looks like your original data may be tab seperated, if that is the case then 
just use read.delim or use sep='\t' in read.table or scan.

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111



 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of David Arnold
 Sent: Friday, June 13, 2008 5:15 PM
 To: r-help@r-project.org
 Subject: [R] Importing data with different delimters

 All,

 I have a data file with 56 entries that looks like this:

 City State  JanTemp Lat Long
 Mobile, AL  44  31.288.5
 Montgomery, AL  38  32.986.8
 Phoenix, AZ 35  33.6112.5
 Little Rock, AR 31  35.492.8
 Los Angeles, CA 47  34.3118.7
 San Francisco, CA   42  38.4123.0

 I would like to read this data into a dataframe. Is it
 possible to do without editing the datafile?

 D.

 __
 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] Importing data with different delimters

2008-06-16 Thread milton ruser
Hi David,

If the delimier is tab try this.

my.df-read.table(my_file.txt, head=T, sep=\t)

Cheers,
Miltinho
Brazil





  -Original Message-
  From: [EMAIL PROTECTED]
  [mailto:[EMAIL PROTECTED] On Behalf Of David Arnold
  Sent: Friday, June 13, 2008 5:15 PM
  To: r-help@r-project.org
  Subject: [R] Importing data with different delimters
 
  All,
 
  I have a data file with 56 entries that looks like this:
 
  City State  JanTemp Lat Long
  Mobile, AL  44  31.288.5
  Montgomery, AL  38  32.986.8
  Phoenix, AZ 35  33.6112.5
  Little Rock, AR 31  35.492.8
  Los Angeles, CA 47  34.3118.7
  San Francisco, CA   42  38.4123.0
 
  I would like to read this data into a dataframe. Is it
  possible to do without editing the datafile?
 
  D.
 
  __
  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.


[[alternative HTML version deleted]]

__
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] Importing data with different delimters

2008-06-16 Thread Peter Dalgaard
Greg Snow wrote:
 It looks like your original data may be tab seperated, if that is the case 
 then just use read.delim or use sep='\t' in read.table or scan.
   
I think that was only half the problem. If you do that, you end up with
one column containing both City and State, comma-separated. Presumably,
the path of least resistance is just to do this and then use string
processing with sub()  or strsplit() to split the City, State strings.

-pd
   
 I have a data file with 56 entries that looks like this:

 City State  JanTemp Lat Long
 Mobile, AL  44  31.288.5
 Montgomery, AL  38  32.986.8
 Phoenix, AZ 35  33.6112.5
 Little Rock, AR 31  35.492.8
 Los Angeles, CA 47  34.3118.7
 San Francisco, CA   42  38.4123.0

 I would like to read this data into a dataframe. Is it
 possible to do without editing the datafile?

 D.
 

-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
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] Importing data with different delimters

2008-06-13 Thread jim holtman
Assuming that the only problem is the blank in the city names, here is
one way of doing it:

 inFile - textConnection(City State  JanTemp Lat Long
+ Mobile, AL  44  31.288.5
+ Montgomery, AL  38  32.986.8
+ Phoenix, AZ 35  33.6112.5
+ Little Rock, AR 31  35.492.8
+ Los Angeles, CA 47  34.3118.7
+ San Francisco, CA   42  38.4123.0)
 lines - readLines(inFile)
 # get rid of blanks in city names
 newLines - sub((.*?) +(.*),, \\1_\\2,, lines)

 x - read.table(textConnection(newLines), header=TRUE)
 closeAllConnections()
 x
City State JanTemp  Lat  Long
1Mobile,AL  44 31.2  88.5
2Montgomery,AL  38 32.9  86.8
3   Phoenix,AZ  35 33.6 112.5
4   Little_Rock,AR  31 35.4  92.8
5   Los_Angeles,CA  47 34.3 118.7
6 San_Francisco,CA  42 38.4 123.0



If you want, you can then go back and replace the _ with a blank in
the city name.

On Fri, Jun 13, 2008 at 7:14 PM, David Arnold [EMAIL PROTECTED] wrote:
 All,

 I have a data file with 56 entries that looks like this:

 City State  JanTemp Lat Long
 Mobile, AL  44  31.288.5
 Montgomery, AL  38  32.986.8
 Phoenix, AZ 35  33.6112.5
 Little Rock, AR 31  35.492.8
 Los Angeles, CA 47  34.3118.7
 San Francisco, CA   42  38.4123.0

 I would like to read this data into a dataframe. Is it possible to do
 without editing the datafile?

 D.

 __
 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.




-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

__
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] Importing data in text file into R

2008-05-23 Thread John Fox

Dear AJSS,

The problem is that the way you've read the data, the first column of  
the data frame is a factor, not a numerical variable, and thus is not  
suitable for computing correlations.


You could use the command cor(idt[,-1]) to compute correlations on all  
but the first column, but your intention was probably to use the first  
column of the input file for row names, not as a variable. One way to  
do this is simply to omit the variable name Year in the first row of  
the input data file.


I hope this helps,
 John

On 23-May-08, at 11:40 PM, amarjit singh sethi wrote:


Dear all,
I am quite new to R; facing certain problems:
Say, I have a text file( named as try):
YearC1  C2  C3  C4  C5  C6
Y1  3.5 13.89.5 6.8 0.4 24.2
Y2  3.8 13.99.9 7.6 0.7 12.8
Y3  4.5 14.514.29.2 0.6 14.5
Y4  5.9 16.224.612.70.2 24.3
Y5  7.2 20.440.618.20.8 28.2
Y6  5.9 18.637.414.50.3 36.9
Y7  8.0 16.188.624.10.1 34.6
Y8  13.621.156.319.00.7 33.3

I wish to import the file into R and make certain
computations, like intercorrelation matrix. I tried
the following syntax:

# Inputting the data file (saved in text format)
df=trial.txt
idt=read.table(df,header=T, sep=\t)
idt
# To generate intercorrelatio matrix
r = cor(idt)
r=round(r, 4)
r

The seems to have been read, but further computations
not made, with the following output:


# Inputting the data file (saved in text format)
df=trial.txt
idt=read.table(df,header=T, sep=\t)
idt

 Year   C1   C2   C3   C4  C5   C6
1   Y1  3.5 13.8  9.5  6.8 0.4 24.2
2   Y2  3.8 13.9  9.9  7.6 0.7 12.8
3   Y3  4.5 14.5 14.2  9.2 0.6 14.5
4   Y4  5.9 16.2 24.6 12.7 0.2 24.3
5   Y5  7.2 20.4 40.6 18.2 0.8 28.2
6   Y6  5.9 18.6 37.4 14.5 0.3 36.9
7   Y7  8.0 16.1 88.6 24.1 0.1 34.6
8   Y8 13.6 21.1 56.3 19.0 0.7 33.3

# To generate intercorrelatio matrix
r = cor(idt)

Error in cor(idt) : missing observations in cov/cor
In addition: Warning message:
In cor(idt) : NAs introduced by coercion

r=round(r, 4)

Error: object r not found

r

Error: object r not found

Kindly advise me as to how to get rid of the error
message.

AJSS

__
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] Importing data in text file into R

2008-05-23 Thread Patrick Connolly
On Fri, 23-May-2008 at 08:40PM -0700, amarjit singh sethi wrote:

| Dear all,
| I am quite new to R; facing certain problems:
| Say, I have a text file( named as try):


|  idt=read.table(df,header=T, sep=\t)
|  idt
|   Year   C1   C2   C3   C4  C5   C6
| 1   Y1  3.5 13.8  9.5  6.8 0.4 24.2
| 2   Y2  3.8 13.9  9.9  7.6 0.7 12.8
| 3   Y3  4.5 14.5 14.2  9.2 0.6 14.5
| 4   Y4  5.9 16.2 24.6 12.7 0.2 24.3
| 5   Y5  7.2 20.4 40.6 18.2 0.8 28.2
| 6   Y6  5.9 18.6 37.4 14.5 0.3 36.9
| 7   Y7  8.0 16.1 88.6 24.1 0.1 34.6
| 8   Y8 13.6 21.1 56.3 19.0 0.7 33.3
|  # To generate intercorrelatio matrix
|  r = cor(idt)
| Error in cor(idt) : missing observations in cov/cor
| In addition: Warning message:
| In cor(idt) : NAs introduced by coercion


The help file for cor says this about x and y:

   x: a numeric vector, matrix or data frame.

   y: 'NULL' (default) or a vector, matrix or data frame with
  compatible dimensions to 'x'.  The default is equivalent to
  'y = x' (but more efficient).

Your x isn't a numeric vector, matrix or data frame.

x[,-1] is, and that might give what you want, but read the rest of the
help file to determine if that's what you want it to do.  Having
rownames on your dataframe might help seeing what is happening.  The
easiest way I can see to get row names is in your read.table line.
Add row.names = 1.

HTH

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~} Great minds discuss ideas
 _( Y )_Middle minds discuss events 
(:_~*~_:)Small minds discuss people  
 (_)-(_)   . Anon
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

__
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] Importing data

2008-05-07 Thread John Kane
First step would be to read the manual on the R site
R Data Import/Export describes the import and export
facilities available either in R itself or via
packages which are available from CRAN

Then if that does not solve the problem you need to
explain in detail what the problems are, preferably
with the code that you are using.  See the
instructions at the bottom of the post.
--- Yemi Oyeyemi [EMAIL PROTECTED] wrote:

 Hi everyone, please I'm having problem importing
 data from Stata and excel. Help me out.
   Thanks
 

 -
 [[elided Yahoo spam]]
   [[alternative HTML version deleted]]
 
 __
 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] Importing data

2008-05-07 Thread Juan Manuel Barreneche
i usually import data from exel, using read.table or read.csv (which implies 
that i have to save exel files as .txt or .csv)

JM

El Miércoles, 7 de Mayo de 2008 11:25, John Kane escribió:
 First step would be to read the manual on the R site
 R Data Import/Export describes the import and export
 facilities available either in R itself or via
 packages which are available from CRAN

 Then if that does not solve the problem you need to
 explain in detail what the problems are, preferably
 with the code that you are using.  See the
 instructions at the bottom of the post.

 --- Yemi Oyeyemi [EMAIL PROTECTED] wrote:
  Hi everyone, please I'm having problem importing
  data from Stata and excel. Help me out.
Thanks
 
 
  -
  [[elided Yahoo spam]]
  [[alternative HTML version deleted]]
 
  __
  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.

__
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] Importing data

2008-05-07 Thread Neil Shephard



Yemi Oyeyemi wrote:
 
 Hi everyone, please I'm having problem importing data from Stata and
 excel. Help me out.
   Thanks
 
 

You don't provide...

a) the code that you've tried

b) the error message that relates to the problem you are having

...without these people have little information on what _exactly_  your
problem is.  Please read the R-help posting guide as advised in the
signature of every mail that appears on the list.  For clarity its...
 
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code. 

In this instance you would also do well to read the R Data Import/Export
manual at http://cran.r-project.org/doc/manuals/R-data.html and pay
particular attention to section 3 titled Importing from other Statistical
Systems
(http://cran.r-project.org/doc/manuals/R-data.html#Importing-from-other-statistical-systems).

This would lead you to the read.dta() and write.dta() functions for
respectively reading and writing Stata formatted data sets.

Neil
-- 
View this message in context: 
http://www.nabble.com/Importing-data-tp17104951p17106184.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] Importing data

2008-05-07 Thread Wensui Liu
import stata data should be straight. take a look at foreign package


On Wed, May 7, 2008 at 9:30 AM, Yemi Oyeyemi [EMAIL PROTECTED] wrote:
 Hi everyone, please I'm having problem importing data from Stata and excel. 
 Help me out.
   Thanks


  -
  [[elided Yahoo spam]]
 [[alternative HTML version deleted]]

  __
  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.




-- 
===
WenSui Liu
ChoicePoint Precision Marketing
Phone: 678-893-9457
Email : [EMAIL PROTECTED]
Blog : statcompute.spaces.live.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] Importing data

2008-01-08 Thread Michael Dewey
At 11:46 06/01/2008, Simo Vundla wrote:
Hi,
I'm trying to import categorical data from SPSS to R using the script:
xxx -spss.get(xxx.por, use.value.labels=TRUE) but unfortunately 
am getting an error message 'error reading portable-file dictionary'.

I have successfully imported data in the past.

In my experience there is quite a high failure rate with files which 
people send me and which they claim to be in SPSS save format or SPSS 
portable format. If they have a reasonably recent version of SPSS 
then ask them to save it in Stata format which at least in my 
experience is a more robust process.


What could be the problem with this data?

Thanks

Simo







 

Be a better friend, newshound, and


 [[alternative HTML version deleted]]

Michael Dewey
http://www.aghmed.fsnet.co.uk

__
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] Importing data

2008-01-06 Thread Frank E Harrell Jr
Simo Vundla wrote:
 Hi,
 I'm trying to import categorical data from SPSS to R using the script:
 xxx -spss.get(xxx.por, use.value.labels=TRUE) but unfortunately am getting 
 an error message 'error reading portable-file dictionary'.
 
 I have successfully imported data in the past. 
 
 What could be the problem with this data?
 
 Thanks
 
 Simo

First of all, follow the posting guide.  Second, state which package you 
are using (in this case Hmisc).

spss.get in Hmisc uses read.spss in the foreign package.  See the 
documentation of read.spss for more details. You will find there:

'read.spss' reads a file stored by the SPSS 'save' and 'export'
  commands and returns a list.

read.spss does not claim to be able to read SPSS .por files.

Frank
-- 
Frank E Harrell Jr   Professor and Chair   School of Medicine
  Department of Biostatistics   Vanderbilt University

__
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] Importing data

2008-01-06 Thread Rense Nieuwenhuis
Hi,

you might try to use the foreign-package, which contains the function  
read.spss. This works fine most of the time,

For a description of its usage, see the help-files or my own website:  
http://www.rensenieuwenhuis.nl/r-project/manual/basics/getting-data- 
into-r-2/

Remember, you'll need to install the foreign-package first.

Hope this helps,

Rense Nieuwenhuis
On Jan 6, 2008, at 12:46 , Simo Vundla wrote:

 Hi,
 I'm trying to import categorical data from SPSS to R using the script:
 xxx -spss.get(xxx.por, use.value.labels=TRUE) but unfortunately  
 am getting an error message 'error reading portable-file dictionary'.

 I have successfully imported data in the past.

 What could be the problem with this data?

 Thanks

 Simo








 __ 
 __
 Be a better friend, newshound, and


   [[alternative HTML version deleted]]

 __
 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] Importing data

2008-01-06 Thread Prof Brian Ripley
On Sun, 6 Jan 2008, Rense Nieuwenhuis wrote:

 Hi,

 you might try to use the foreign-package, which contains the function
 read.spss. This works fine most of the time,

 For a description of its usage, see the help-files or my own website:
 http://www.rensenieuwenhuis.nl/r-project/manual/basics/getting-data-
 into-r-2/

 Remember, you'll need to install the foreign-package first.

You shouldn't have to: it is supposed to come with every installation of 
R, and be installed unless you specifically opt out.

Perhaps you meant 'first load the foreign package via library(foreign)'?

[Re: Frank Harrell's comment, many people use .por for SPSS export 
files; that is the extension used in package foreign's tests directory.
But the issue may well be that xxx.por is not an SPSS export file.]


 Hope this helps,

 Rense Nieuwenhuis
 On Jan 6, 2008, at 12:46 , Simo Vundla wrote:

 Hi,
 I'm trying to import categorical data from SPSS to R using the script:
 xxx -spss.get(xxx.por, use.value.labels=TRUE) but unfortunately
 am getting an error message 'error reading portable-file dictionary'.

 I have successfully imported data in the past.

 What could be the problem with this data?

 Thanks

 Simo


-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
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.