[R] Problem in generating any model with my dataset in R

2015-10-19 Thread Bhawana Sahu
Dear all,

I am using kernlab function for analysis of dataset containing 8000 rows
and 171 column, but getting an error saying cannot allocate the memory, It
is running properly with the dataset having 3000 rows and 251 column,

Also when I tried this with dataset having 7000 rows and 171 column getting
error saying that "Error in terms.formula(formula, data = data) : '.' in
formula and no 'data' argument"

What can be done with this dataset, how can I use this for analysis. Is
there any limitation ? please suggest me some solution.

Thanks for your help,

regards
Bhawana Sahu

[[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-es] FW: Acentos en tcltk

2015-10-19 Thread miguel.angel.rodriguez.muinos
Hola Jesús.

Parece que el problema no lo sienes solo en el tcltk al fichero adjunto me 
remito.

Un Saludo,
Miguel.



El 19/10/2015 a las 9:12, Jesús Para Fernández escribió:

Buenas,

Esoty desarrollando mi primer paquete, un entorno gr�fico sencillo usando la 
libreria tcltk, y tengo problemas con los acentos y caracteres especiales.

Para ello he creado la funci�n:

mostrar<-function(){

tt<-tktoplevel()
tktitle(tt)<-"�Hola mundo!"


}

El problema es que el � no lo reconoce y aparece como un conjunto de letras 
"raras". C�mo puedo hacer para que se vean los acentos?

Gracias

[[alternative HTML version deleted]]





___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es



--
Miguel Ángel Rodríguez Muíños
Asesoramento en Informática
Servizo de Epidemioloxía
Dirección Xeral de Innovación e Xestión da Saúde Pública
Consellería de Sanidade
Xunta de Galicia
http://dxsp.sergas.es








Nota: A información contida nesta mensaxe e os seus posibles documentos 
adxuntos é privada e confidencial e está dirixida únicamente ó seu 
destinatario/a. Se vostede non é o/a destinatario/a orixinal desta mensaxe, por 
favor elimínea. A distribución ou copia desta mensaxe non está autorizada.

Nota: La información contenida en este mensaje y sus posibles documentos 
adjuntos es privada y confidencial y está dirigida únicamente a su 
destinatario/a. Si usted no es el/la destinatario/a original de este mensaje, 
por favor elimínelo. La distribución o copia de este mensaje no está autorizada.

See more languages: http://www.sergas.es/aviso-confidencialidad
___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es


Re: [R] No speed up using the parallel package and ncpus > 1 with boot() on linux machines

2015-10-19 Thread Jeff Newmiller
Regarding cores... The only reliable way I have found so far is to look up the 
processor specs. In your case I found [1] which says 4 cores.

[1] 
http://ark.intel.com/m/products/64900/Intel-Core-i7-3615QM-Processor-6M-Cache-up-to-3_30-GHz#@product/specifications
---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  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.

On October 18, 2015 2:31:13 AM PDT, Chris Evans  wrote:
>As with Milan's answer: perfect explanation and hugely appreciated.  A
>few follow up questions/comments below.
>
>- Original Message -
>> From: "Jeff Newmiller" 
>> To: "Chris Evans" 
>> Cc: r-help@r-project.org
>> Sent: Saturday, 17 October, 2015 18:28:12
>> Subject: Re: [R] No speed up using the parallel package and ncpus > 1
>with boot() on linux machines
>
>> None of this is surprising. If the calculations you divide your work
>up
>> into are small, then the overhead of communicating between parallel
>> processes will be a relatively large penalty to pay.  You have to
>break
>> your problem up into larger chunks and depend on vector processing
>within
>> processes to keep the cpu busy doing useful work.
>
>Aha.  Got it!
> 
>> Also, I am not aware of any model of Mac Mini that has 8 physical
>cores...
>> 4 is the max. Virtual cores gain a logical simplification of
>> multiprocessing but do not offer actual improved performance because
>> there are only as many physical data paths and registers as there are
>> cores.
>
>Ah.  Hadn't thought of that.  It's a machine I rent, I thought it was a
>mac mini.  detectCores() reports 8 but perhaps they are virtual cores.
>/proc/cpuinfo says the processor is an Intel(R) Core(TM) i7-3615QM CPU
>@ 2.30GHz and shows 8 cores but again ... perhaps they are virtual. 
>What's the best way to get a true core count?
> 
>> Note that your problems are with long-running simulations... your
>examples
>> are too small to demonstrate the actual balance of processing vs.
>> communication overhead. Before you draw conclusions, try upping
>bootReps
>> by a few orders of magnitude, and run your test code a couple
>> of times to stabilize the memory conditions and obtain some
>consistency
>> in timings.
>
>OK.  Good advice again but what you are saying, and the findings I had
>there, are pretty consistent with what I was seeing with long running
>things with bootReps up at 10k and I think you've told me what I really
>want to know.  I think the simplest way to parallelise may actually be
>fine for me: I'll run four (or maybe eight) separate R jobs (having a
>look at swapping to make sure I'm not pushing beyond physical RAM,
>don't think these simulations will.
>
>> I have never used the parallel option in the boot package before... I
>have
>> always rolled my own to allow me to decide how much work to do within
>the
>> worker processes before returning from them. (This is particularly
>severe
>> when using snow, but not necessarily something you can neglect with
>> multicore.)
>
>That sounds like an impressive and obviously pertinent approach.  I
>think, as I say, I may be able to get away with a very simple approach
>that runs parallel simulations and then aggregates the data from each
>and analyses that.
>
>Many thanks Jeff.  Brilliant help.
>
>Chris
>
> 
>> On Sat, 17 Oct 2015, Chris Evans wrote:
>> 
>>> I think I am failing to understand how boot() uses the parallel
>package on linux
>
>... rest of my original post deleted to save space ...
>
> 
>>
>---
>> Jeff NewmillerThe .   .  Go
>Live...
>> DCN:Basics: ##.#.   ##.#.  Live
>Go...
>>   Live:   OO#.. Dead: OO#.. 
>Playing
>> Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
>> /Software/Embedded Controllers)   .OO#.   .OO#. 
>rocks...1k
>>
>---
>
>__
>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

Re: [R] Problem in generating any model with my dataset in R

2015-10-19 Thread PIKAL Petr
Hi

Why do you replace NA with meaningless „-„? NA for R means Not Available and R 
can handle it properly. „-„ means „-„ for R and is treated as character 
together with rest of the column. If somebody aviced it to you, do not trust 
him any more.

Anyway, you still do not provide info about data. If you have so many rows 
maybe the best way would be

dput(head(yourdata[1:50,])

or something like that.

Cheers
Petr



From: Bhawana Sahu [mailto:bhawanasahu...@gmail.com]
Sent: Monday, October 19, 2015 12:14 PM
To: PIKAL Petr
Subject: Re: [R] Problem in generating any model with my dataset in R

Thank you very much for your suggestion,
I am running this on windows using R 3.2.2 and also I tried on linux as well.

In my data, some of the rows having "NA" and before using my dataset I am 
replacing this NA with "-", can this create a problem?

On Mon, Oct 19, 2015 at 3:26 PM, PIKAL Petr 
> wrote:
Hi

Your objects are not so big, therefore I assume that something is wrong with 
their stucture, especially when one object gives you results.

I wonder if you get more precise answer without providing some basic facts 
(structure of data, code, OS, R version).

Cheers
Petr

> -Original Message-
> From: R-help 
> [mailto:r-help-boun...@r-project.org] On 
> Behalf Of Bhawana
> Sahu
> Sent: Monday, October 19, 2015 9:04 AM
> To: r-help@r-project.org
> Subject: [R] Problem in generating any model with my dataset in R
>
> Dear all,
>
> I am using kernlab function for analysis of dataset containing 8000
> rows and 171 column, but getting an error saying cannot allocate the
> memory, It is running properly with the dataset having 3000 rows and
> 251 column,
>
> Also when I tried this with dataset having 7000 rows and 171 column
> getting error saying that "Error in terms.formula(formula, data = data)
> : '.' in formula and no 'data' argument"
>
> What can be done with this dataset, how can I use this for analysis. Is
> there any limitation ? please suggest me some solution.
>
> Thanks for your help,
>
> regards
> Bhawana Sahu
>
>   [[alternative HTML version deleted]]
>




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 this e-mail shall not be liable for any possible damage caused by 
modifications of the e-mail or by delay with transfer of the email.

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately 
accept such offer; The sender of this e-mail (offer) excludes any acceptance of 
the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an 
express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into 
any contracts on behalf of the company except for cases in which he/she is 
expressly authorized to do so in writing, and such authorization or power of 
attorney 

Re: [R-es] Error con tabla

2015-10-19 Thread Carlos Ortega
Hola,

El error que obtienes también tiene que ver con que no puedes calcular la
varianza (y luego las correlaciones) cuando tus datos tienen "NA". Esos NAs
pueden ser debidos a que tengas alguna celda vacía o a que al cambiar el
tipo de dato, se haya introducido como te comentaba Miguel.

Si ves que tienees alguna celda vacía (en la columna sobre la que quieres
calcular la varianza), tendrás que usar un parámetro "na.rm=TRUE" en la
función "var()" que permite ignorar esos NA.

Saludos,
Carlos Ortega
www.qualityexcellence.es

El 19 de octubre de 2015, 13:26, Valentina Aguilera 
escribió:

> Hola Miguel A.
> Muchas gracias por tu colaboración...pues bien en realidad son nueva con r
> y no sé aún muchas cosas "básicas". En la primera columna tenía los nombres
> de las empresas (en letras) y eliminé esa columna, pero me siguen saliendo
> los mismos errores.
> Este es un análisis que debo hacer en primera instancia, pero el fin
> último es realizar un análisis factorial qué aún no se como empezar así que
> también agradecería si me pueden colaborar con bibliografía y ejemplos al
> respecto, como también del tratamiento que se de deben dar a los datos.
> Muchas gracias!!!
> > From: miguel.angel.rodriguez.mui...@sergas.es
> > To: r-help-es@r-project.org
> > Date: Mon, 19 Oct 2015 11:12:26 +
> > Subject: Re: [R-es] Error con tabla
> >
> > Hola Valentina.
> >
> > Los tipos de datos que tienes en el data.frame "variables" no se
> corresponden con los cálculos que pretendes realizar.
> > Seguramente tienes campos de texto que pretendes usar como numéricos.
> >
> > Una manera rápida de comprobarlo es con un >fix(variables)
> >
> > Un Saludo,
> > Miguel.
> >
> >
> >
> > El 19/10/2015 a las 13:03, Valentina Aguilera escribió:
> >
> > Hola a todos,
> > Tengo el siguiente problema:
> > Tengo un archivo de excel que lo convert� a csv y tiene la siguiente
> estructura:La primera columna con el nombre de las empresas (48 empresas)
> y 17 columnas m�s (variables) con informaci�n sobre esas empresas.
> > Cargo el archivo en r de la siguiente manera para poder trabajar con el:
> > library(xtable)variables <-
> read.csv("C:/Users/usuario/Documents/Investigacion.csv", header=TRUE,
> sep=";")
> > Cuando intento calcular algunos estad�sticos genera los siguientes
> errores: 1) Al tratar de calcular la desviaci�n est�ndar:sd(variables)
> > Error in is.data.frame(x) :   (list) object cannot be coerced to type
> 'double'
> > 2) Al tratar de calcular la varianza: var(variables)
> > Warning message:In var(variables) : NAs introduced by coercion
> > 3) Al tratar de calcular la matriz de correlaciones: cor(variables)
> > Error in cor(variables) : 'x' must be numeric
> > Por lo anterior no s� como hay que cargar y leer los datos o qu�
> tratamiento hay que darle para poder trabajar con ello, pues lo primero es
> poder calcular esos estad�sticos .
> > Muchas gracias.
> > Saludos,
> > Valentina A.
> > [[alternative HTML version deleted]]
> >
> >
> >
> >
> >
> > ___
> > R-help-es mailing list
> > R-help-es@r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-help-es
> >
> >
> > --
> > Miguel Ángel Rodríguez Muíños
> > Dirección Xeral de Innovación e Xestión da Saúde Pública
> > Consellería de Sanidade
> > Xunta de Galicia
> > http://dxsp.sergas.es
> >
> >
> >
> >
> >
> >
> > 
> >
> > Nota: A información contida nesta mensaxe e os seus posibles documentos
> adxuntos é privada e confidencial e está dirixida únicamente ó seu
> destinatario/a. Se vostede non é o/a destinatario/a orixinal desta mensaxe,
> por favor elimínea. A distribución ou copia desta mensaxe non está
> autorizada.
> >
> > Nota: La información contenida en este mensaje y sus posibles documentos
> adjuntos es privada y confidencial y está dirigida únicamente a su
> destinatario/a. Si usted no es el/la destinatario/a original de este
> mensaje, por favor elimínelo. La distribución o copia de este mensaje no
> está autorizada.
> >
> > See more languages: http://www.sergas.es/aviso-confidencialidad
> >
> >   [[alternative HTML version deleted]]
> >
> > ___
> > R-help-es mailing list
> > R-help-es@r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-help-es
>
> [[alternative HTML version deleted]]
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>



-- 
Saludos,
Carlos Ortega
www.qualityexcellence.es

[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es

Re: [R] Problem in generating any model with my dataset in R

2015-10-19 Thread Bhawana Sahu
I got the solution,

Problem was due to replacement of NA

Thank you so much

On Mon, Oct 19, 2015 at 5:13 PM, Fox, John  wrote:

> Dear Bhawana Sahu,
>
> You don't show any of the commands that you used to produce this error, so
> one can only guess at its source, but the error message you quote seems
> reasonably clear -- apparently, you failed to specify the data argument to
> the function(s) you called.
>
> For example, with a data frame named D containing a variable y among
> others, lm(y ~ .) will fail but lm(y ~ ., data=D) will work.
>
> If you *did* specify the data argument, then you'll have to provide more
> information about what you did, ideally including a small reproducible
> example.
>
> I hope this helps,
>  John
>
> -
> John Fox, Professor
> McMaster University
> Hamilton, Ontario
> Canada L8S 4M4
> Web: socserv.mcmaster.ca/jfox
>
>
>
> > -Original Message-
> > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Bhawana
> > Sahu
> > Sent: October 19, 2015 3:04 AM
> > To: r-help@r-project.org
> > Subject: [R] Problem in generating any model with my dataset in R
> >
> > Dear all,
> >
> > I am using kernlab function for analysis of dataset containing 8000 rows
> and
> > 171 column, but getting an error saying cannot allocate the memory, It is
> > running properly with the dataset having 3000 rows and 251 column,
> >
> > Also when I tried this with dataset having 7000 rows and 171 column
> getting
> > error saying that "Error in terms.formula(formula, data = data) : '.' in
> formula
> > and no 'data' argument"
> >
> > What can be done with this dataset, how can I use this for analysis. Is
> there
> > any limitation ? please suggest me some solution.
> >
> > Thanks for your help,
> >
> > regards
> > Bhawana Sahu
> >
> >   [[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-es] Error con tabla

2015-10-19 Thread Valentina Aguilera
Hola Miguel A.
Muchas gracias por tu colaboración...pues bien en realidad son nueva con r y no 
sé aún muchas cosas "básicas". En la primera columna tenía los nombres de las 
empresas (en letras) y eliminé esa columna, pero me siguen saliendo los mismos 
errores. 
Este es un análisis que debo hacer en primera instancia, pero el fin último es 
realizar un análisis factorial qué aún no se como empezar así que también 
agradecería si me pueden colaborar con bibliografía y ejemplos al respecto, 
como también del tratamiento que se de deben dar a los datos.
Muchas gracias!!!
> From: miguel.angel.rodriguez.mui...@sergas.es
> To: r-help-es@r-project.org
> Date: Mon, 19 Oct 2015 11:12:26 +
> Subject: Re: [R-es] Error con tabla
> 
> Hola Valentina.
> 
> Los tipos de datos que tienes en el data.frame "variables" no se corresponden 
> con los cálculos que pretendes realizar.
> Seguramente tienes campos de texto que pretendes usar como numéricos.
> 
> Una manera rápida de comprobarlo es con un >fix(variables)
> 
> Un Saludo,
> Miguel.
> 
> 
> 
> El 19/10/2015 a las 13:03, Valentina Aguilera escribió:
> 
> Hola a todos,
> Tengo el siguiente problema:
> Tengo un archivo de excel que lo convert� a csv y tiene la siguiente 
> estructura:La primera columna con el nombre de las empresas (48 empresas)  y 
> 17 columnas m�s (variables) con informaci�n sobre esas empresas.
> Cargo el archivo en r de la siguiente manera para poder trabajar con el:
> library(xtable)variables <- 
> read.csv("C:/Users/usuario/Documents/Investigacion.csv", header=TRUE, sep=";")
> Cuando intento calcular algunos estad�sticos genera los siguientes errores: 
> 1) Al tratar de calcular la desviaci�n est�ndar:sd(variables)
> Error in is.data.frame(x) :   (list) object cannot be coerced to type 'double'
> 2) Al tratar de calcular la varianza: var(variables)
> Warning message:In var(variables) : NAs introduced by coercion
> 3) Al tratar de calcular la matriz de correlaciones: cor(variables)
> Error in cor(variables) : 'x' must be numeric
> Por lo anterior no s� como hay que cargar y leer los datos o qu� tratamiento 
> hay que darle para poder trabajar con ello, pues lo primero es poder calcular 
> esos estad�sticos .
> Muchas gracias.
> Saludos,
> Valentina A.
> [[alternative HTML version deleted]]
> 
> 
> 
> 
> 
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
> 
> 
> --
> Miguel Ángel Rodríguez Muíños
> Dirección Xeral de Innovación e Xestión da Saúde Pública
> Consellería de Sanidade
> Xunta de Galicia
> http://dxsp.sergas.es
> 
> 
> 
> 
> 
> 
> 
> 
> Nota: A información contida nesta mensaxe e os seus posibles documentos 
> adxuntos é privada e confidencial e está dirixida únicamente ó seu 
> destinatario/a. Se vostede non é o/a destinatario/a orixinal desta mensaxe, 
> por favor elimínea. A distribución ou copia desta mensaxe non está autorizada.
> 
> Nota: La información contenida en este mensaje y sus posibles documentos 
> adjuntos es privada y confidencial y está dirigida únicamente a su 
> destinatario/a. Si usted no es el/la destinatario/a original de este mensaje, 
> por favor elimínelo. La distribución o copia de este mensaje no está 
> autorizada.
> 
> See more languages: http://www.sergas.es/aviso-confidencialidad
> 
>   [[alternative HTML version deleted]]
> 
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
  
[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es

Re: [R-es] Error con tabla

2015-10-19 Thread miguel.angel.rodriguez.muinos
No consiste en "cargarse" las variables tipo texto, si no en que cada variable 
sea del tipo adecuado. Igual tiene sentido que exista una variable que te 
permita discernir por las distintas empresas

A lo que me refería es a que debes dominar la conversión de tipos.
Échale un ojo a esto 
http://www.r-bloggers.com/type-conversion-and-you-or-and-r/ y a esto otro 
http://www.statmethods.net/management/typeconversion.html y luego prueba a 
poner >methods(as) en la consola de R... y luego ampliar los que te 
interesen... por ejemplo >??as.numeric()

Es decir: Primero debes saber qué tipo tiene que tener cada variable (eso es 
trabajo tuyo dependiendo de lo que pretendas hacer) y luego ser capaz de 
cambiarlo (de ahí las lecturas de antes).

Yo empezaría por ahí.

Un Saludo,
Miguel.





El 19/10/2015 a las 13:26, Valentina Aguilera escribió:
Hola Miguel A.

Muchas gracias por tu colaboración...pues bien en realidad son nueva con r y no 
sé aún muchas cosas "básicas".
En la primera columna tenía los nombres de las empresas (en letras) y eliminé 
esa columna, pero me siguen saliendo los mismos errores.

Este es un análisis que debo hacer en primera instancia, pero el fin último es 
realizar un análisis factorial qué aún no se como empezar así que también 
agradecería si me pueden colaborar con bibliografía y ejemplos al respecto, 
como también del tratamiento que se de deben dar a los datos.

Muchas gracias!!!

> From: 
> miguel.angel.rodriguez.mui...@sergas.es
> To: r-help-es@r-project.org
> Date: Mon, 19 Oct 2015 11:12:26 +
> Subject: Re: [R-es] Error con tabla
>
> Hola Valentina.
>
> Los tipos de datos que tienes en el data.frame "variables" no se corresponden 
> con los cálculos que pretendes realizar.
> Seguramente tienes campos de texto que pretendes usar como numéricos.
>
> Una manera rápida de comprobarlo es con un >fix(variables)
>
> Un Saludo,
> Miguel.
>
>
>
> El 19/10/2015 a las 13:03, Valentina Aguilera escribió:
>
> Hola a todos,
> Tengo el siguiente problema:
> Tengo un archivo de excel que lo convert� a csv y tiene la siguiente 
> estructura:La primera columna con el nombre de las empresas (48 empresas) y 
> 17 columnas m�s (variables) con informaci�n sobre esas empresas.
> Cargo el archivo en r de la siguiente manera para poder trabajar con el:
> library(xtable)variables <- 
> read.csv("C:/Users/usuario/Documents/Investigacion.csv", header=TRUE, sep=";")
> Cuando intento calcular algunos estad�sticos genera los siguientes errores: 
> 1) Al tratar de calcular la desviaci�n est�ndar:sd(variables)
> Error in is.data.frame(x) : (list) object cannot be coerced to type 'double'
> 2) Al tratar de calcular la varianza: var(variables)
> Warning message:In var(variables) : NAs introduced by coercion
> 3) Al tratar de calcular la matriz de correlaciones: cor(variables)
> Error in cor(variables) : 'x' must be numeric
> Por lo anterior no s� como hay que cargar y leer los datos o qu� tratamiento 
> hay que darle para poder trabajar con ello, pues lo primero es poder calcular 
> esos estad�sticos .
> Muchas gracias.
> Saludos,
> Valentina A.
> [[alternative HTML version deleted]]
>
>
>
>
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>
>
> --
> Miguel Ángel Rodríguez Muíños
> Dirección Xeral de Innovación e Xestión da Saúde Pública
> Consellería de Sanidade
> Xunta de Galicia
> http://dxsp.sergas.es
>
>
>
>
>
>
> 
>
> Nota: A información contida nesta mensaxe e os seus posibles documentos 
> adxuntos é privada e confidencial e está dirixida únicamente ó seu 
> destinatario/a. Se vostede non é o/a destinatario/a orixinal desta mensaxe, 
> por favor elimínea. A distribución ou copia desta mensaxe non está autorizada.
>
> Nota: La información contenida en este mensaje y sus posibles documentos 
> adjuntos es privada y confidencial y está dirigida únicamente a su 
> destinatario/a. Si usted no es el/la destinatario/a original de este mensaje, 
> por favor elimínelo. La distribución o copia de este mensaje no está 
> autorizada.
>
> See more languages: http://www.sergas.es/aviso-confidencialidad
>
> [[alternative HTML version deleted]]
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es


--
Miguel Ángel Rodríguez Muíños
Asesoramento en Informática
Servizo de Epidemioloxía
Dirección Xeral de Innovación e Xestión da Saúde Pública
Consellería de Sanidade
Xunta de Galicia
http://dxsp.sergas.es








Nota: A información contida nesta mensaxe e os seus posibles documentos 
adxuntos é privada e confidencial e está dirixida únicamente ó seu 

[R] Plotting EEG signals as a "head" using R

2015-10-19 Thread Charles Novaes de Santana
Dear all,

I have .csv file with the evoked potential of different electrodes of a
human subject and I would like to plot a head figure representing the
evoked potentials. My csv file has 1000 lines (from 1ms to 1000 ms) and 12
columns (each column for an electrode I am studying).

Do you know a way to use this csv files to plot a head representing the
evoked potential at specific points (like P300, N100, etc) using R? (I know
a way to plot it in Matlab using ERPLAB and EEGLAB, but Matlab is not an
option in our Lab).

The idea is to have a head figure similar to the one in the following
picture:
http://d2avczb82rh8fa.cloudfront.net/content/jn/113/3/740/F3.large.jpg

Thanks for any help, sorry for not having a reproducible example.

Best,

Charles


-- 
Um axé! :)

--
Charles Novaes de Santana, PhD
http://www.imedea.uib-csic.es/~charles

[[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-es] Error con tabla

2015-10-19 Thread Valentina Aguilera
Hola a todos, 
Tengo el siguiente problema:
Tengo un archivo de excel que lo convert� a csv y tiene la siguiente 
estructura:La primera columna con el nombre de las empresas (48 empresas)  y 17 
columnas m�s (variables) con informaci�n sobre esas empresas. 
Cargo el archivo en r de la siguiente manera para poder trabajar con el:
library(xtable)variables <- 
read.csv("C:/Users/usuario/Documents/Investigacion.csv", header=TRUE, sep=";")
Cuando intento calcular algunos estad�sticos genera los siguientes errores: 1) 
Al tratar de calcular la desviaci�n est�ndar:sd(variables)
Error in is.data.frame(x) :   (list) object cannot be coerced to type 'double'
2) Al tratar de calcular la varianza: var(variables)
Warning message:In var(variables) : NAs introduced by coercion
3) Al tratar de calcular la matriz de correlaciones: cor(variables)
Error in cor(variables) : 'x' must be numeric
Por lo anterior no s� como hay que cargar y leer los datos o qu� tratamiento 
hay que darle para poder trabajar con ello, pues lo primero es poder calcular 
esos estad�sticos .
Muchas gracias.
Saludos, 
Valentina A.  
[[alternative HTML version deleted]]

___
R-help-es mailing list
R-help-es@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-help-es

Re: [R] Problem in generating any model with my dataset in R

2015-10-19 Thread Fox, John
Dear Bhawana Sahu,

You don't show any of the commands that you used to produce this error, so one 
can only guess at its source, but the error message you quote seems reasonably 
clear -- apparently, you failed to specify the data argument to the function(s) 
you called.

For example, with a data frame named D containing a variable y among others, 
lm(y ~ .) will fail but lm(y ~ ., data=D) will work.

If you *did* specify the data argument, then you'll have to provide more 
information about what you did, ideally including a small reproducible example.

I hope this helps,
 John

-
John Fox, Professor
McMaster University
Hamilton, Ontario
Canada L8S 4M4
Web: socserv.mcmaster.ca/jfox



> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Bhawana
> Sahu
> Sent: October 19, 2015 3:04 AM
> To: r-help@r-project.org
> Subject: [R] Problem in generating any model with my dataset in R
> 
> Dear all,
> 
> I am using kernlab function for analysis of dataset containing 8000 rows and
> 171 column, but getting an error saying cannot allocate the memory, It is
> running properly with the dataset having 3000 rows and 251 column,
> 
> Also when I tried this with dataset having 7000 rows and 171 column getting
> error saying that "Error in terms.formula(formula, data = data) : '.' in 
> formula
> and no 'data' argument"
> 
> What can be done with this dataset, how can I use this for analysis. Is there
> any limitation ? please suggest me some solution.
> 
> Thanks for your help,
> 
> regards
> Bhawana Sahu
> 
>   [[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] sub-sample my data in R from two different tables

2015-10-19 Thread John Wasige
​Hi, I need help on how to sub-sample my data in R. I have two tables, one
table with global dataset and another with a list of codes for sub sample
the global dataset.

​
Download link
​

https://www.wetransfer.com/downloads/a53aa3f722b2d2887b60b09239f7c4e620151018152100/ad852e

​

​All these tables have a column called: alloc_key. I want to use the list
of codes in reg6id_subsample_key.csv to extract all raws from
reg6idGlobal.csv for matching/ similar codes in column alloc_key of
reg6idGlobal.csv file.


​Somebody with an idea on how I can go about doing this?

Thanks for your help

John​




​

[[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] sub-sample my data in R from two different tables

2015-10-19 Thread Michael Dewey

Dear John

I suspect
?merge
will help here.

You would need to tidy up afterwards (or before) if you do not want the 
other columns in your dataframe of keys to be included in the result.


On 19/10/2015 11:19, John Wasige wrote:

​Hi, I need help on how to sub-sample my data in R. I have two tables, one
table with global dataset and another with a list of codes for sub sample
the global dataset.

​
Download link
​

https://www.wetransfer.com/downloads/a53aa3f722b2d2887b60b09239f7c4e620151018152100/ad852e

​

​All these tables have a column called: alloc_key. I want to use the list
of codes in reg6id_subsample_key.csv to extract all raws from
reg6idGlobal.csv for matching/ similar codes in column alloc_key of
reg6idGlobal.csv file.


​Somebody with an idea on how I can go about doing this?

Thanks for your help

John​




​

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



--
Michael
http://www.dewey.myzen.co.uk/home.html

__
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] Problem in generating any model with my dataset in R

2015-10-19 Thread PIKAL Petr
Hi

Your objects are not so big, therefore I assume that something is wrong with 
their stucture, especially when one object gives you results.

I wonder if you get more precise answer without providing some basic facts 
(structure of data, code, OS, R version).

Cheers
Petr

> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Bhawana
> Sahu
> Sent: Monday, October 19, 2015 9:04 AM
> To: r-help@r-project.org
> Subject: [R] Problem in generating any model with my dataset in R
>
> Dear all,
>
> I am using kernlab function for analysis of dataset containing 8000
> rows and 171 column, but getting an error saying cannot allocate the
> memory, It is running properly with the dataset having 3000 rows and
> 251 column,
>
> Also when I tried this with dataset having 7000 rows and 171 column
> getting error saying that "Error in terms.formula(formula, data = data)
> : '.' in formula and no 'data' argument"
>
> What can be done with this dataset, how can I use this for analysis. Is
> there any limitation ? please suggest me some solution.
>
> Thanks for your help,
>
> regards
> Bhawana Sahu
>
>   [[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.


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 this e-mail shall not be liable for any possible damage caused by 
modifications of the e-mail or by delay with transfer of the email.

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately 
accept such offer; The sender of this e-mail (offer) excludes any acceptance of 
the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an 
express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into 
any contracts on behalf of the company except for cases in which he/she is 
expressly authorized to do so in writing, and such authorization or power of 
attorney is submitted to the recipient or the person represented by the 
recipient, or the existence of such authorization is known to the recipient of 
the person represented by the recipient.
__
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] library(nlme) groupedData question‏

2015-10-19 Thread Andre Mikulec


All,

Some trial and error follows ( for anyone who cares ).


The case seems that groupedData does not like 
to have both "a grouping" and "an outher" defined at the same time.


library(nlme)


d.x <- read.table(header=TRUE, text="
o g h i d
A C E G 1.0
A C E H 2
A C F G 4
A C F H 8

A D E G 16
A D E H 32
A D F G 64
A D F H 128

B C E G 256
B C E H 1024
B C F G 2048
B C F H 4096

B D E G 8192
B D E H 16384
B D F G 32768
B D F H 65536
", stringsAsFactors = FALSE)


# desirable 'outer' ommitted ( but I want 'outer' )


gd <- groupedData(formula = d ~ h | g  
  , data  = d.x 
  , inner = ~ i
)


# best (available) solution


gd <- groupedData(formula = d ~ h | o/g
  , data  = d.x 
  , inner = ~ i
)


> str(gd, vec.len = 16)
Classes 'nmGroupedData', 'groupedData' and 'data.frame':16 obs. of  5 
variables:
 $ o: chr  "A" "A" "A" "A" "A" "A" "A" "A" "B" "B" "B" "B" "B" "B" "B" "B"
 $ g: chr  "C" "C" "C" "C" "D" "D" "D" "D" "C" "C" "C" "C" "D" "D" "D" "D"
 $ h: chr  "E" "E" "F" "F" "E" "E" "F" "F" "E" "E" "F" "F" "E" "E" "F" "F"
 $ i: chr  "G" "H" "G" "H" "G" "H" "G" "H" "G" "H" "G" "H" "G" "H" "G" "H"
 $ d: num  1 2 4 8 16 32 64 128 256 1024 2048 4096 8192 16384 32768 65536
 - attr(*, "formula")=Class 'formula' length 3 d ~ h | o/g
  .. ..- attr(*, ".Environment")=
 - attr(*, "formulaList")=List of 2
  ..$ o:Class 'formula' length 2 ~o
  .. .. ..- attr(*, ".Environment")=
  ..$ g:Class 'formula' length 2 ~g
  .. .. ..- attr(*, ".Environment")=
 - attr(*, "inner")=List of 1
  ..$ g:Class 'formula' length 2 ~i
  .. .. ..- attr(*, ".Environment")=
 - attr(*, "order.groups")=List of 2
  ..$ o: logi TRUE
  ..$ g: logi TRUE
 - attr(*, "FUN")=function (x)




Andre Mikulec
andre_miku...@hotmail.com



> From: andre_miku...@hotmail.com
> To: r-help@r-project.org
> Subject: library(nlme) groupedData question‏
> Date: Mon, 12 Oct 2015 08:53:53 -0400
>
>
> SUMMARY
> ---
>
> Using package nlme, I am getting the following warning
> when I try to create a grouped data object using groupedData().
>
> I believe that my logic is faulty.
>
> Warning message:
> In `levels<-`(`*tmp*`, value = if (nl == nL) as.character(labels) else 
> paste0(labels, :
> duplicated levels in factors are deprecated
>
> What am I doing wrong? How do I adjust?
>
> Thanks,
> Andre Mikulec
> andre_miku...@hotmail.com
>
>
> DETAILS ( the following R code can be copied and pasted to the R console and 
> ran )
> ---
>
> library(nlme)
>
> d.x <- read.table(header=TRUE, text="
> o g h i d
> A C E G 1.0
> A C E H 2
> A C F G 4
> A C F H 8
>
> A D E G 16
> A D E H 32
> A D F G 64
> A D F H 128
>
> B C E G 256
> B C E H 1024
> B C F G 2048
> B C F H 4096
>
> B D E G 8192
> B D E H 16384
> B D F G 32768
> B D F H 65536
> ", stringsAsFactors = FALSE)
>
> str(d.x, vec.len = 16)
> # 'data.frame': 16 obs. of 5 variables:
> # $ o: chr "A" "A" "A" "A" "A" "A" "A" "A" "B" "B" "B" "B" "B" "B" "B" "B"
> # $ g: chr "C" "C" "C" "C" "D" "D" "D" "D" "C" "C" "C" "C" "D" "D" "D" "D"
> # $ h: chr "E" "E" "F" "F" "E" "E" "F" "F" "E" "E" "F" "F" "E" "E" "F" "F"
> # $ i: chr "G" "H" "G" "H" "G" "H" "G" "H" "G" "H" "G" "H" "G" "H" "G" "H"
> # $ d: num 1 2 4 8 16 32 64 128 256 1024 2048 4096 8192 16384 32768 65536
>
> gd <- groupedData(formula = d ~ h | g
> , data = d.x
> , outer = ~ o
> , inner = ~ i
> )
>
> # Warning message:
> # In `levels<-`(`*tmp*`, value = if (nl == nL) as.character(labels) else 
> paste0(labels, :
> # duplicated levels in factors are deprecated
>
>
> str(gd, vec.len = 16)
> # Classes 'nffGroupedData', 'nfGroupedData', 'groupedData' and 'data.frame': 
> 16 obs. of 5 variables:
> # $ o: chr "A" "A" "A" "A" "A" "A" "A" "A" "B" "B" "B" "B" "B" "B" "B" "B"
> # $ g: Ord.factor w/ 4 levels "C"<"D"<"C"<"D": 1 1 1 1 2 2 2 2 1 1 1 1 2 2 2 2
> # $ h: chr "E" "E" "F" "F" "E" "E" "F" "F" "E" "E" "F" "F" "E" "E" "F" "F"
> # $ i: chr "G" "H" "G" "H" "G" "H" "G" "H" "G" "H" "G" "H" "G" "H" "G" "H"
> # $ d: num 1 2 4 8 16 32 64 128 256 1024 2048 4096 8192 16384 32768 65536
> # - attr(*, "formula")=Class 'formula' length 3 d ~ h | g
> # .. ..- attr(*, ".Environment")=
> # - attr(*, "outer")=Class 'formula' length 2 ~o
> # .. ..- attr(*, ".Environment")=
> # - attr(*, "inner")=Class 'formula' length 2 ~i
> # .. ..- attr(*, ".Environment")=
> # - attr(*, "FUN")=function (x)
> # - attr(*, "order.groups")= logi TRUE
>
>
> SOFTWARE INFORMATION
> 
>
>> sessionInfo()
> R version 3.2.2 (2015-08-14)
> Platform: x86_64-w64-mingw32/x64 (64-bit)
> Running under: Windows 7 x64 (build 7601) Service Pack 1
>
> locale:
> [1] LC_COLLATE=English_United States.1252
> [2] LC_CTYPE=English_United States.1252
> [3] LC_MONETARY=English_United States.1252
> [4] LC_NUMERIC=C
> [5] LC_TIME=English_United States.1252
>
> attached base packages:
> [1] stats graphics grDevices utils datasets methods 

Re: [R] Plotting EEG signals as a "head" using R

2015-10-19 Thread Dénes Tóth

Hi,

the eegkit package 
(https://cran.r-project.org/web/packages/eegkit/index.html) might help 
you if you happen to work with a standard electrode cap.


Best,
  Denes



On 10/19/2015 02:41 PM, Charles Novaes de Santana wrote:

Dear all,

I have .csv file with the evoked potential of different electrodes of a
human subject and I would like to plot a head figure representing the
evoked potentials. My csv file has 1000 lines (from 1ms to 1000 ms) and 12
columns (each column for an electrode I am studying).

Do you know a way to use this csv files to plot a head representing the
evoked potential at specific points (like P300, N100, etc) using R? (I know
a way to plot it in Matlab using ERPLAB and EEGLAB, but Matlab is not an
option in our Lab).

The idea is to have a head figure similar to the one in the following
picture:
http://d2avczb82rh8fa.cloudfront.net/content/jn/113/3/740/F3.large.jpg

Thanks for any help, sorry for not having a reproducible example.

Best,

Charles




__
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] condition in triple summation

2015-10-19 Thread Sherouk Moawad via R-help
If I'm summing over (i,j,k) each from 1 to 3

And I have �condition that (i>j>k)

But I want to restrict this condition to only cases where i,j,k>1

Sent from Yahoo Mail on Android

From:"Jeff Newmiller" 
Date:Mon, Oct 19, 2015 at 1:24 AM
Subject:Re: [R] condition in triple summation

Learn to post using plain text format. We are seeing garbage on the screen.

---
Jeff Newmiller� � � � � � � � � � � � The� � .� � � .� Go Live...
DCN:� � � � Basics: ##.#.� � � ##.#.� Live Go...
� � � � � � � � � � � � � � � � � � � Live:� OO#.. Dead: OO#..� Playing
Research Engineer (Solar/Batteries� � � � � � O.O#.� � � #.O#.� with
/Software/Embedded Controllers)� � � � � � � .OO#.� � � .OO#.� rocks...1k
---
Sent from my phone. Please excuse my brevity.


On October 18, 2015 2:03:34 PM PDT, Sherouk Moawad via R-help 
 wrote:
>Dear R-Expertsx=c(0,0.3, 0.5,0.6)sum(sapply(1:4, function(i)
>{sum(sapply(1:3, function(j){sum(sapply(1:2, function(k)
>{(i>j)*(j>k)*exp(x[i]+x[j]+x[k])}))}))}))
>I want to restrict the condition (i>j>k) to only those cases where
>i>1>1>1In other words'if i=1 then i>=jif j=1 then j>=kother wise
>i>j>kcan this be done using coding or notThank you 
>��� [[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] condition in triple summation

2015-10-19 Thread jim holtman
Not sure I understand what your condition 'i > j > k' means in the context
of where each of the values is 1:3.  The only value that meets that
condition is i =3, j=2 & k=1, but you said exclude any cases where the
values were equal to 1.

Can you clarify with an example what you mean.


Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

On Mon, Oct 19, 2015 at 3:53 AM, Sherouk Moawad via R-help <
r-help@r-project.org> wrote:

> If I'm summing over (i,j,k) each from 1 to 3
>
> And I have  condition that (i>j>k)
>
> But I want to restrict this condition to only cases where i,j,k>1
>
> Sent from Yahoo Mail on Android
>
> From:"Jeff Newmiller" 
> Date:Mon, Oct 19, 2015 at 1:24 AM
> Subject:Re: [R] condition in triple summation
>
> Learn to post using plain text format. We are seeing garbage on the screen.
>
> ---
> Jeff NewmillerThe.  .  Go Live...
> DCN:Basics: ##.#.  ##.#.  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.
>
>
> On October 18, 2015 2:03:34 PM PDT, Sherouk Moawad via R-help <
> r-help@r-project.org> wrote:
> >Dear R-Expertsx=c(0,0.3, 0.5,0.6)sum(sapply(1:4, function(i)
> >{sum(sapply(1:3, function(j){sum(sapply(1:2, function(k)
> >{(i>j)*(j>k)*exp(x[i]+x[j]+x[k])}))}))}))
> >I want to restrict the condition (i>j>k) to only those cases where
> >i>1>1>1In other words'if i=1 then i>=jif j=1 then j>=kother wise
> >i>j>kcan this be done using coding or notThank you
> >[[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.
>

[[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] sub-sample my data in R from two different tables

2015-10-19 Thread jim holtman
I all  you are doing is matching a single column and then extracting rows
that match, then the '%in%' operator should work:

indx <- reg6idGlobal$alloc_key %in% req6id_subsample_key$alloc_key
my_subset <- reg6idGlobal[indx, ]


Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

On Mon, Oct 19, 2015 at 6:19 AM, John Wasige  wrote:

> ​Hi, I need help on how to sub-sample my data in R. I have two tables, one
> table with global dataset and another with a list of codes for sub sample
> the global dataset.
>
> ​
> Download link
> ​
>
>
> https://www.wetransfer.com/downloads/a53aa3f722b2d2887b60b09239f7c4e620151018152100/ad852e
>
> ​
>
> ​All these tables have a column called: alloc_key. I want to use the list
> of codes in reg6id_subsample_key.csv to extract all raws from
> reg6idGlobal.csv for matching/ similar codes in column alloc_key of
> reg6idGlobal.csv file.
>
>
> ​Somebody with an idea on how I can go about doing this?
>
> Thanks for your help
>
> John​
>
>
>
>
> ​
>
> [[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.

[R] leveneTest between 2-levels of 3-level factor in R?

2015-10-19 Thread Dr. Leigh S. Sutherland
Still feeling my way around using R...

What I have done so far:

I have a data.frame 'results' with response 'Fail', and three factors
'PREP', 'CLEAN' & 'ADHES'. ADHES has 3 levels: Crest Cryst Poly

I calculated the variances:

sigma..k=tapply(Fail,ADHES,var)
print(sqrt(sigma..k)):

CrestCryst Poly 17.56668 41.64679 39.42669

then used leveneTest to test for constance of variance:

print(leveneTest(Fail~ADHES))

Levene's Test for Homogeneity of Variance (center = median)
  Df F value  Pr(>F)
group  2   3.929 0.02588 *
  51

The Question:
Now I want to use Levene's to test for constance of variance between only
the Cryst & Poly levels of the factor ADHES, but I cant work out the syntax
to do this in R.

Could anyone help, please?
​

[[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] value of variable in ls()

2015-10-19 Thread James Toll

> On Oct 18, 2015, at 10:51 AM, Christian Hoffmann  
> wrote:
> 
> How can I do e.g. print("unknown"(ls())) and get the variable values in my 
> current environment?

>From your example, it sounds like what you want is simply this:

sapply(ls(), get)


James

__
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] value of variable in ls()

2015-10-19 Thread peter dalgaard

On 19 Oct 2015, at 16:16 , James Toll  wrote:

> 
>> On Oct 18, 2015, at 10:51 AM, Christian Hoffmann  
>> wrote:
>> 
>> How can I do e.g. print("unknown"(ls())) and get the variable values in my 
>> current environment?
> 
> From your example, it sounds like what you want is simply this:
> 
> sapply(ls(), get)
> 

Perhaps lapply rather than sapply; I don't think the simplification step of the 
latter is desirable. Incidentally, both variations are effectively crossing the 
creek to fetch as.list(GlobalEnv).

If your environment contains large objects, you will get what you asked for, 
but that might well be more than you expected.

> 
> James
> 
> __
> 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] optimization problem

2015-10-19 Thread Hector Villalobos
Thanks to all who responded,

I've found a very useful code here:

http://courses.washington.edu/fish507/notes.html

In particular the Lecture 3...

Héctor


2015-10-17 7:05 GMT+00:00 Berend Hasselman :

>
> Your model is producing -Inf entries in the vector Be (in function modl
> and LL) at some stage during the optimization process.
> You should first do something about that before anything else.
>
> Berend
>
>
> > On 17 Oct 2015, at 03:01, Bert Gunter  wrote:
> >
> > I made no attempt to examine your details for problems, but in general,
> >
> > My problem
> >> is that the results change a lot depending on the initial values... I
> can't
> >> see what I am doing wrong...
> >>
> >> This is a symptom of an overparameterized model: The parameter estimates
> >> are unstable even though the predictions may not change much. In other
> >> words, your model may be too complex for your data.
> >
> >
> > Whether that is true here, you or others will have to determine. Try
> > simplifying your model as a start.
> >
> > -- Bert
> >
> >
> >
> >>
> >>
> >> # Data
> >> x <- 1995:2010
> >> B <- c(3500, 3200, 3000, 2800, 2600, 3000, 3200, 3800, 4200, 4300, 4400,
> >> 4400, 4500, 4600, 5000, 4300)
> >> Ct <- c(912, 767, 642, 482, 353, 331, 332, 309, 366, 402, 392, 478, 408,
> >> 434, 407, 637)
> >> a <- c(0.539, 0.603, -0.948, 0.166, 1.895, 0.786, 0.901, 0.844, 0.337,
> >> 0.429, 0.304, 0.230, 1.001, 0.750, 0.507, 1.502)
> >> Ag <- 0.55
> >>
> >> # Function with quantity to minimize
> >> modl <- function(par) {
> >>  ro <- par[1]
> >>  ko <- par[2]
> >>  n <- length(B)
> >>  Be <- rep(NA, n)
> >>  Be[1] <- ko * Ag
> >>  for ( k in 2:n)
> >>Be[k] <- Be[k-1] + ro * a[k-1] * Be[k-1] * (1 - Be[k-1]/ko) - Ct[k-1]
> >>  err <- (log(B) - log(Be))^2
> >>  ee <- sqrt( sum(err)/(n-2) )
> >>  LL <- (1/(sqrt(2*pi)*ee)) * exp( -(err/(2*ee^2) ) )
> >>  -crossprod(LL)
> >> }
> >>
> >> # Using function optim()
> >> par.optim <- optim(par = list(ro=0.4, ko=8000), modl, method = "BFGS")
> >> ro <- par.optim$par[1]
> >> ko <- par.optim$par[2]
> >>
> >> # estimated values of "B"
> >> n <- length(B)
> >> Be <- rep(NA, n)
> >> Be[1] <- ko * Ag
> >> for ( k in 2:n)
> >>  Be[k] <- Be[k-1] + ro * a[k-1] * Be[k-1] * (1 - Be[k-1]/ko) - Ct[k-1]
> >>
> >> # Plot, estimation of "B" seems reasonable
> >> plot(x, B, ylim=c(1000, 7000))
> >> lines(x, Be, col="blue", lwd=2)
> >>
> >>
> >> # ... but it is very sensible to initial values...
> >> par.optim2 <- optim(par = list(ro=0.4, ko=1), modl, method = "BFGS")
> >> ro2 <- par.optim2$par[1]
> >> ko2 <- par.optim2$par[2]
> >>
> >> Be2 <- rep(NA, n)
> >> Be2[1] <- ko2 * Ag
> >> for ( k in 2:n)
> >>  Be2[k] <- Be2[k-1] + ro2 * a[k-1] * Be2[k-1] * (1 - Be2[k-1]/ko2) -
> >> Ct[k-1]
> >>
> >> lines(x, Be2, col="blue", lwd=2, lty=3)
> >>
> >>
> >>
> >> # Uing mle2 function
> >> library(bbmle)
> >> LL <- function(ro, ko, mu, sigma) {
> >>  n <- length(B)
> >>  Be <- rep(NA, n)
> >>  Be[1] <- ko * Ag
> >>  for ( k in 2:n)
> >>Be[k] <- Be[k-1] + ro * a[k-1] * Be[k-1] * (1 - Be[k-1]/ko) - Ct[k-1]
> >>  err <- log(B) - log(Be)
> >>  R <- (dnorm(err, mu, sigma, log=TRUE))
> >>  -sum(R)
> >> }
> >>
> >> Bc.mle <- mle2(LL, start = list(ro=0.4, ko=8000, mu=0, sigma=1))
> >> summary(Bc.mle)
> >>
> >> ro3 <- coef(Bc.mle)[1]
> >> ko3 <- coef(Bc.mle)[2]
> >>
> >> Be3 <- rep(NA, n)
> >> Be3[1] <- ko3 * Ag
> >> for ( k in 2:n)
> >>  Be3[k] <- Be3[k-1] + ro3 * a[k-1] * Be3[k-1] * (1 - Be3[k-1]/ko3) -
> >> Ct[k-1]
> >>
> >> lines(x, Be3, col="red", lwd=2)
> >>
> >>
> >> --
> >>
> >> Héctor Villalobos >
> >>
> >> Depto. de Pesquerías y Biología Marina
> >>
> >> Centro Interdisciplinario de Ciencias Marinas-Instituto Politécnico
> >> Nacional
> >>
> >> CICIMAR-I.P.N.
> >>
> >> A.P. 592. Colonia Centro
> >>
> >> La Paz, Baja California Sur, MÉXICO. 23000
> >>
> >> Tels.: (+52 612) 122 53 44; 123 46 58; 123 47 34 ext.: 81602
> >>
> >> Fax: (+52 612) 122 53 22
> >>
> >>[[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.
> >
> >
> >
> > --
> > Bert Gunter
> >
> > "Data is not information. Information is not knowledge. And knowledge is
> > certainly not wisdom."
> >   -- Clifford Stoll
> >
> >   [[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.
>
>


-- 

Dr. Héctor Villalobos 

Re: [R] warning on generic function when building R package

2015-10-19 Thread Duncan Murdoch
On 19/10/2015 3:50 PM, carol white wrote:
> Thanks Murdoch.
> 
> defining
> plot.func<- function(x=x.init, y=y.init, arg3, arg4, "title", col, arg5)
> 
> and if plot doesn't take the exact parameters of plot.func but modified
> of these parameters
> plot(x=x.pt,y=y.pt,xlim = c(0, 10), ylim = c(0,1), xlab= "xlab",
> ylab="ylab", main = "title", col = col,type = "l")
> 
> then, how to define and invoke to be consisent?

I don't really understand your question, but this is all about the
function header for plot.func, not the call you make to plot().  You
need to name the first argument as "x", you need to include "..." as an
open argument, and you need a legal header.  So this would be okay:


plot.func<- function(x=x.init, y=y.init, arg3, arg4,
 main = "title", # can't skip the arg name
 col, arg5,
 ...)  {  # can't skip the dots

Duncan Murdoch

> 
> Regards,
> 
> On Monday, October 19, 2015 7:45 PM, Duncan Murdoch
>  wrote:
> 
> 
> On 19/10/2015 1:29 PM, carol white via R-help wrote:
> 
>> Hi,I have invoked plot in a function (plot.func) as follows but when I
> check the built package, I get a warning:
>> plot(x.pt,y.pt,xlim = c(0, 10), ylim = c(0,1), xlab= "xlab",
> ylab="ylab", main = "title", col = col,type = "l")
>> R CMD check my.package
>> checking S3 generic/method consistency ... WARNING
>> plot:
>>  function(x, ...)
>> plot.func:
>>  function(x.pt, y.pt, arg3, arg4, "title", col, arg5)
>>
>> See section ‘Generic functions and methods’ in the ‘Writing R
>> Extensions’ manual.
>> Which plot argument is illegitimate or missing and how to eliminate
> the warning?
> 
> 
> The first argument to plot.func needs to be called "x" if you want to
> use it as a method.  Method signatures need to be consistent with the
> generic signature.
> 
> Duncan Murdoch
> 
> 
> 
>

__
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] Plotting EEG signals as a "head" using R

2015-10-19 Thread Charles Novaes de Santana
Thanks a lot, Dénes!!

This library is very good! I can plot the head even in 3D using the command
"eegspace(space,voltage)", in which "space" defines the position of the
electrodes and voltage is the voltage of my EEG signal :)

Simple and elegant! :)

Thanks!

Best,

Charles



On 19 October 2015 at 15:10, Dénes Tóth  wrote:

> Hi,
>
> the eegkit package (
> https://cran.r-project.org/web/packages/eegkit/index.html) might help you
> if you happen to work with a standard electrode cap.
>
> Best,
>   Denes
>
>
>
> On 10/19/2015 02:41 PM, Charles Novaes de Santana wrote:
>
>> Dear all,
>>
>> I have .csv file with the evoked potential of different electrodes of a
>> human subject and I would like to plot a head figure representing the
>> evoked potentials. My csv file has 1000 lines (from 1ms to 1000 ms) and 12
>> columns (each column for an electrode I am studying).
>>
>> Do you know a way to use this csv files to plot a head representing the
>> evoked potential at specific points (like P300, N100, etc) using R? (I
>> know
>> a way to plot it in Matlab using ERPLAB and EEGLAB, but Matlab is not an
>> option in our Lab).
>>
>> The idea is to have a head figure similar to the one in the following
>> picture:
>> http://d2avczb82rh8fa.cloudfront.net/content/jn/113/3/740/F3.large.jpg
>>
>> Thanks for any help, sorry for not having a reproducible example.
>>
>> Best,
>>
>> Charles
>>
>>
>>


-- 
Um axé! :)

--
Charles Novaes de Santana, PhD
http://www.imedea.uib-csic.es/~charles

[[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] warning on generic function when building R package

2015-10-19 Thread carol white via R-help
In effect, this works
but whether I use x or x.init, y or y.init in plot.func, I get
 
no visible binding for global variable ‘x.init’no visible binding for global 
variable ‘y.init’
Regards,

 On Monday, October 19, 2015 9:59 PM, Duncan Murdoch 
 wrote:
   

 On 19/10/2015 3:50 PM, carol white wrote:
> Thanks Murdoch.
> 
> defining
> plot.func<- function(x=x.init, y=y.init, arg3, arg4, "title", col, arg5)
> 
> and if plot doesn't take the exact parameters of plot.func but modified
> of these parameters
> plot(x=x.pt,y=y.pt,xlim = c(0, 10), ylim = c(0,1), xlab= "xlab",
> ylab="ylab", main = "title", col = col,type = "l")
> 
> then, how to define and invoke to be consisent?

I don't really understand your question, but this is all about the
function header for plot.func, not the call you make to plot().  You
need to name the first argument as "x", you need to include "..." as an
open argument, and you need a legal header.  So this would be okay:


plot.func<- function(x=x.init, y=y.init, arg3, arg4,
                    main = "title", # can't skip the arg name
                    col, arg5,
                    ...)  {          # can't skip the dots

Duncan Murdoch

> 
> Regards,
> 
> On Monday, October 19, 2015 7:45 PM, Duncan Murdoch
>  wrote:
> 
> 
> On 19/10/2015 1:29 PM, carol white via R-help wrote:
> 
>> Hi,I have invoked plot in a function (plot.func) as follows but when I
> check the built package, I get a warning:
>> plot(x.pt,y.pt,xlim = c(0, 10), ylim = c(0,1), xlab= "xlab",
> ylab="ylab", main = "title", col = col,type = "l")
>> R CMD check my.package
>> checking S3 generic/method consistency ... WARNING
>> plot:
>>  function(x, ...)
>> plot.func:
>>  function(x.pt, y.pt, arg3, arg4, "title", col, arg5)
>>
>> See section ‘Generic functions and methods’ in the ‘Writing R
>> Extensions’ manual.
>> Which plot argument is illegitimate or missing and how to eliminate
> the warning?
> 
> 
> The first argument to plot.func needs to be called "x" if you want to
> use it as a method.  Method signatures need to be consistent with the
> generic signature.
> 
> Duncan Murdoch
> 
> 
> 
> 



  
[[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] leveneTest between 2-levels of 3-level factor in R?

2015-10-19 Thread Rolf Turner

On 20/10/15 01:02, Dr. Leigh S. Sutherland wrote:

Still feeling my way around using R...

What I have done so far:

I have a data.frame 'results' with response 'Fail', and three factors
'PREP', 'CLEAN' & 'ADHES'. ADHES has 3 levels: Crest Cryst Poly

I calculated the variances:

sigma..k=tapply(Fail,ADHES,var)
print(sqrt(sigma..k)):

CrestCryst Poly 17.56668 41.64679 39.42669

then used leveneTest to test for constance of variance:

print(leveneTest(Fail~ADHES))


How does leveneTest() find the variables "Fail" and "ADHES" given that 
you do not provide it with a "data" argument?



Levene's Test for Homogeneity of Variance (center = median)
   Df F value  Pr(>F)
group  2   3.929 0.02588 *
   51

The Question:
Now I want to use Levene's to test for constance of variance between only
the Cryst & Poly levels of the factor ADHES, but I cant work out the syntax
to do this in R.

Could anyone help, please?


I am not at all sure that I understand your somewhat incoherently 
expressed question, but I *think* that what you want to do might be done 
by setting


   ok <- with(results,ADHES%in%c("Cryst","Poly"))
   leveneTest(Fail ~ ADHES, data=results[ok,])

It's hard to say, since you do not provide a reproducible example.

cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
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] warning on generic function when building R package

2015-10-19 Thread Bert Gunter
Have you read the manual as requested?
It will answer your question.

Bert
On Oct 19, 2015 6:31 PM, "carol white via R-help" 
wrote:

> Hi,I have invoked plot in a function (plot.func) as follows but when I
> check the built package, I get a warning:
> plot(x.pt,y.pt,xlim = c(0, 10), ylim = c(0,1), xlab= "xlab", ylab="ylab",
> main = "title", col = col,type = "l")
> R CMD check my.package
> checking S3 generic/method consistency ... WARNING
> plot:
>   function(x, ...)
> plot.func:
>   function(x.pt, y.pt, arg3, arg4, "title", col, arg5)
>
> See section ‘Generic functions and methods’ in the ‘Writing R
> Extensions’ manual.
> Which plot argument is illegitimate or missing and how to eliminate the
> warning?
> Thanks
> Carol
>
> [[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] (no subject)

2015-10-19 Thread FERNANDO MANSITO CABALLERO
Hi,

I am very grateful to you all, because (as you well know) if you make the
database flat,

> Empl1 <- list(employee="Anna",spouse="Fred",children=3,
+ child.ages=c(4,7,9),employee="John",spouse="Mary",children=2,
+ child.ages=c(14,17))

adding a record with the same status as the first ones is feasible:

> Empl1 <- c(Empl1,employee="Liz",spouse="Paul",children=1,child.ages=8)

and once, thanks to you all, one learns how to obtain a first sample,

> unlist(Empl1[c(2,6,10)])
  spouse spouse spouse
  "Fred" "Mary" "Paul"

it would seem that one has broken the bad spell:

>  unlist(Empl1[c(2,6,10)][Empl1[c(1,5,9)]==c("Anna","John","Pete")])
   spouse spouse
   "Fred" "Mary"

However, one gets more correct matches but not everywhere (Anna Liz, John
Liz give incorrect
results, Fred and named character(0) respectively). I have read ?"[" but I
have not found where
my mistake is (1).

(1)In particular, the help says "Recursive (list-like) objects: indexing by
[ is similar to
atomic vectors and selects a list of the specified element(s)." More
generally, "] can select
more than one element" (as opposed to [[, $). I have tested with no added
packages and with all
my normally loaded packages and get the same problems in R3.2.2 Windows.

Fernando

On Mon, Oct 5, 2015 at 5:58 PM, FERNANDO MANSITO CABALLERO <
fernando.mans...@gmail.com> wrote:

> Hi
>
> Thanks a lot to all of you for your solutions and explanations.
>
> On Sun, Oct 4, 2015 at 10:34 PM, David Winsemius 
> wrote:
>
>>
>> On Oct 4, 2015, at 11:31 AM, FERNANDO MANSITO CABALLERO wrote:
>>
>> > Dear Madam/Sir,
>> >
>> > I  am   trying to understand  R and I have come to a stumbling block. i
>> > have written:
>> >
>> >> Empl <- list(employee="Anna",family=list(spouse="Fred",children=3,
>> >
>> +child.ages=c(4,7,9)),employee="John",family=list(spouse="Mary",children=2,
>> > +child.ages=c(14,17)))
>> >> $family$spouse
>> > [1] "Fred"
>> >> #instead of [1] "Fred" "Mary"
>> >
>> > Where am I wrong?
>>
>> The $ function is short-hand for "[[" (with an unevaluated argument). The
>> "[[" function is not able to deliver multiple values. You might think you
>> needed to use:
>>
>> sapply( Empl[c(2,4)], function(x){ x$family$spouse )
>>
>>
>> And you cannot use that construction or its equivalent, because sapply
>> and lapply do not pass the names of their arguments:
>>
>> > sapply( Empl[c(2,4)], function(x){ x[['family']]['spouse']} )
>> $family
>> NULL
>>
>> $family
>> NULL
>>
>> #---
>>
>>
>> This succeeds:
>>
>> > sapply( Empl[grepl('family', names(Empl)) ], function(x){x$spouse})
>> family family
>> "Fred" "Mary"
>>
>>
>> --
>>
>> David Winsemius
>> Alameda, CA, USA
>>
>>
>

[[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] (no subject)

2015-10-19 Thread William Dunlap
You are making a long list with multiple components with the same name.
You probably want to make list of lists, with each component list
representing one employee.E.g.,
  > Empl1 <- list(employee="Anna",spouse="Fred",children=3,
  + child.ages=c(4,7,9),employee="John",spouse="Mary",children=2,
  + child.ages=c(14,17))
  > Empl2 <- list(employee="Liz",spouse="Paul",children=1,child.ages=8)
  > Employees <- list(Empl1, Empl2)
  > vapply(Employees, function(x)x[["spouse"]], "")
  [1] "Fred" "Paul"
  > sapply(Employees, function(x)x[["children"]])
  [1] 3 1
  > lapply(Employees, function(x)x[["child.ages"]])
  [[1]]
  [1] 4 7 9

  [[2]]
  [1] 8

Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Mon, Oct 19, 2015 at 9:44 AM, FERNANDO MANSITO CABALLERO
 wrote:
> Hi,
>
> I am very grateful to you all, because (as you well know) if you make the
> database flat,
>
>> Empl1 <- list(employee="Anna",spouse="Fred",children=3,
> + child.ages=c(4,7,9),employee="John",spouse="Mary",children=2,
> + child.ages=c(14,17))
>
> adding a record with the same status as the first ones is feasible:
>
>> Empl1 <- c(Empl1,employee="Liz",spouse="Paul",children=1,child.ages=8)
>
> and once, thanks to you all, one learns how to obtain a first sample,
>
>> unlist(Empl1[c(2,6,10)])
>   spouse spouse spouse
>   "Fred" "Mary" "Paul"
>
> it would seem that one has broken the bad spell:
>
>>  unlist(Empl1[c(2,6,10)][Empl1[c(1,5,9)]==c("Anna","John","Pete")])
>spouse spouse
>"Fred" "Mary"
>
> However, one gets more correct matches but not everywhere (Anna Liz, John
> Liz give incorrect
> results, Fred and named character(0) respectively). I have read ?"[" but I
> have not found where
> my mistake is (1).
>
> (1)In particular, the help says "Recursive (list-like) objects: indexing by
> [ is similar to
> atomic vectors and selects a list of the specified element(s)." More
> generally, "] can select
> more than one element" (as opposed to [[, $). I have tested with no added
> packages and with all
> my normally loaded packages and get the same problems in R3.2.2 Windows.
>
> Fernando
>
> On Mon, Oct 5, 2015 at 5:58 PM, FERNANDO MANSITO CABALLERO <
> fernando.mans...@gmail.com> wrote:
>
>> Hi
>>
>> Thanks a lot to all of you for your solutions and explanations.
>>
>> On Sun, Oct 4, 2015 at 10:34 PM, David Winsemius 
>> wrote:
>>
>>>
>>> On Oct 4, 2015, at 11:31 AM, FERNANDO MANSITO CABALLERO wrote:
>>>
>>> > Dear Madam/Sir,
>>> >
>>> > I  am   trying to understand  R and I have come to a stumbling block. i
>>> > have written:
>>> >
>>> >> Empl <- list(employee="Anna",family=list(spouse="Fred",children=3,
>>> >
>>> +child.ages=c(4,7,9)),employee="John",family=list(spouse="Mary",children=2,
>>> > +child.ages=c(14,17)))
>>> >> $family$spouse
>>> > [1] "Fred"
>>> >> #instead of [1] "Fred" "Mary"
>>> >
>>> > Where am I wrong?
>>>
>>> The $ function is short-hand for "[[" (with an unevaluated argument). The
>>> "[[" function is not able to deliver multiple values. You might think you
>>> needed to use:
>>>
>>> sapply( Empl[c(2,4)], function(x){ x$family$spouse )
>>>
>>>
>>> And you cannot use that construction or its equivalent, because sapply
>>> and lapply do not pass the names of their arguments:
>>>
>>> > sapply( Empl[c(2,4)], function(x){ x[['family']]['spouse']} )
>>> $family
>>> NULL
>>>
>>> $family
>>> NULL
>>>
>>> #---
>>>
>>>
>>> This succeeds:
>>>
>>> > sapply( Empl[grepl('family', names(Empl)) ], function(x){x$spouse})
>>> family family
>>> "Fred" "Mary"
>>>
>>>
>>> --
>>>
>>> David Winsemius
>>> Alameda, CA, USA
>>>
>>>
>>
>
> [[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] warning on generic function when building R package

2015-10-19 Thread carol white via R-help
Thanks Murdoch.
defining
plot.func<- function(x=x.init, y=y.init, arg3, arg4, "title", col, arg5)
and if plot doesn't take the exact parameters of plot.func but modified of 
these parametersplot(x=x.pt,y=y.pt,xlim = c(0, 10), ylim = c(0,1), xlab= 
"xlab", ylab="ylab", main = "title", col = col,type = "l")  
then, how to define and invoke to be consisent?
Regards,

 On Monday, October 19, 2015 7:45 PM, Duncan Murdoch 
 wrote:
   

 On 19/10/2015 1:29 PM, carol white via R-help wrote:
> Hi,I have invoked plot in a function (plot.func) as follows but when I check 
> the built package, I get a warning:
> plot(x.pt,y.pt,xlim = c(0, 10), ylim = c(0,1), xlab= "xlab", ylab="ylab", 
> main = "title", col = col,type = "l") 
> R CMD check my.package
> checking S3 generic/method consistency ... WARNING
> plot:
>  function(x, ...)
> plot.func:
>  function(x.pt, y.pt, arg3, arg4, "title", col, arg5)
> 
> See section ‘Generic functions and methods’ in the ‘Writing R
> Extensions’ manual.
> Which plot argument is illegitimate or missing and how to eliminate the 
> warning?

The first argument to plot.func needs to be called "x" if you want to
use it as a method.  Method signatures need to be consistent with the
generic signature.

Duncan Murdoch



  
[[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] warning on generic function when building R package

2015-10-19 Thread Duncan Murdoch
On 19/10/2015 1:29 PM, carol white via R-help wrote:
> Hi,I have invoked plot in a function (plot.func) as follows but when I check 
> the built package, I get a warning:
> plot(x.pt,y.pt,xlim = c(0, 10), ylim = c(0,1), xlab= "xlab", ylab="ylab", 
> main = "title", col = col,type = "l") 
> R CMD check my.package
> checking S3 generic/method consistency ... WARNING
> plot:
>   function(x, ...)
> plot.func:
>   function(x.pt, y.pt, arg3, arg4, "title", col, arg5)
> 
> See section ‘Generic functions and methods’ in the ‘Writing R
> Extensions’ manual.
> Which plot argument is illegitimate or missing and how to eliminate the 
> warning?

The first argument to plot.func needs to be called "x" if you want to
use it as a method.  Method signatures need to be consistent with the
generic signature.

Duncan Murdoch

__
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] warning on generic function when building R package

2015-10-19 Thread Bert Gunter
... (Following up on Duncan)
and see also ?plot and ?plot.default for argument details.

Bert

On Monday, October 19, 2015, Duncan Murdoch 
wrote:

> On 19/10/2015 1:29 PM, carol white via R-help wrote:
> > Hi,I have invoked plot in a function (plot.func) as follows but when I
> check the built package, I get a warning:
> > plot(x.pt,y.pt,xlim = c(0, 10), ylim = c(0,1), xlab= "xlab",
> ylab="ylab", main = "title", col = col,type = "l")
> > R CMD check my.package
> > checking S3 generic/method consistency ... WARNING
> > plot:
> >   function(x, ...)
> > plot.func:
> >   function(x.pt, y.pt, arg3, arg4, "title", col, arg5)
> >
> > See section ‘Generic functions and methods’ in the ‘Writing R
> > Extensions’ manual.
> > Which plot argument is illegitimate or missing and how to eliminate the
> warning?
>
> The first argument to plot.func needs to be called "x" if you want to
> use it as a method.  Method signatures need to be consistent with the
> generic signature.
>
> Duncan Murdoch
>
> __
> 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.



-- 
Bert Gunter

"Data is not information. Information is not knowledge. And knowledge is
certainly not wisdom."
   -- Clifford Stoll

[[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] warning on generic function when building R package

2015-10-19 Thread carol white via R-help
Hi,I have invoked plot in a function (plot.func) as follows but when I check 
the built package, I get a warning:
plot(x.pt,y.pt,xlim = c(0, 10), ylim = c(0,1), xlab= "xlab", ylab="ylab", main 
= "title", col = col,type = "l") 
R CMD check my.package
checking S3 generic/method consistency ... WARNING
plot:
  function(x, ...)
plot.func:
  function(x.pt, y.pt, arg3, arg4, "title", col, arg5)

See section ‘Generic functions and methods’ in the ‘Writing R
Extensions’ manual.
Which plot argument is illegitimate or missing and how to eliminate the warning?
Thanks
Carol

[[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] warning on generic function when building R package

2015-10-19 Thread Jeff Newmiller
I would guess that x.pt does not have class "func", whatever that is. You 
really ought to read the manual section indicated in the error.
---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  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.

On October 19, 2015 10:29:54 AM PDT, carol white via R-help 
 wrote:
>Hi,I have invoked plot in a function (plot.func) as follows but when I
>check the built package, I get a warning:
>plot(x.pt,y.pt,xlim = c(0, 10), ylim = c(0,1), xlab= "xlab",
>ylab="ylab", main = "title", col = col,type = "l") 
>R CMD check my.package
>checking S3 generic/method consistency ... WARNING
>plot:
>  function(x, ...)
>plot.func:
>  function(x.pt, y.pt, arg3, arg4, "title", col, arg5)
>
>See section ‘Generic functions and methods’ in the ‘Writing R
>Extensions’ manual.
>Which plot argument is illegitimate or missing and how to eliminate the
>warning?
>Thanks
>Carol
>
>   [[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] condition in triple summation

2015-10-19 Thread Sherouk Moawad via R-help

| If for example I have a double sammation on (xj+xi)The first summation from 1 
to 3 And second summation is from 1 to 2If I put the condition of (i>j ) then 
the term (x1+x1) will not be included I need to cut the condition into tow 
parts If i>1 then i>jWhile if i=1 then i>=jSo that the term (x1+x1) is 
includedCan this be done or it's an imaginary casePlease help |

 


 On Monday, October 19, 2015 4:00 PM, jim holtman  
wrote:
   

 Not sure I understand what your condition 'i > j > k' means in the context of 
where each of the values is 1:3.  The only value that meets that condition is i 
=3, j=2 & k=1, but you said exclude any cases where the values were equal to 1.
Can you clarify with an example what you mean.

Jim Holtman
Data Munger Guru
 
What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.
On Mon, Oct 19, 2015 at 3:53 AM, Sherouk Moawad via R-help 
 wrote:

If I'm summing over (i,j,k) each from 1 to 3

And I have  condition that (i>j>k)

But I want to restrict this condition to only cases where i,j,k>1

Sent from Yahoo Mail on Android

From:"Jeff Newmiller" 
Date:Mon, Oct 19, 2015 at 1:24 AM
Subject:Re: [R] condition in triple summation

Learn to post using plain text format. We are seeing garbage on the screen.

---
Jeff Newmiller                        The    .      .  Go Live...
DCN:        Basics: ##.#.      ##.#.  Live Go...
                                      Live:  OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.      #.O#.  with
/Software/Embedded Controllers)              .OO#.      .OO#.  rocks...1k
---
Sent from my phone. Please excuse my brevity.


On October 18, 2015 2:03:34 PM PDT, Sherouk Moawad via R-help 
 wrote:
>Dear R-Expertsx=c(0,0.3, 0.5,0.6)sum(sapply(1:4, function(i)
>{sum(sapply(1:3, function(j){sum(sapply(1:2, function(k)
>{(i>j)*(j>k)*exp(x[i]+x[j]+x[k])}))}))}))
>I want to restrict the condition (i>j>k) to only those cases where
>i>1>1>1In other words'if i=1 then i>=jif j=1 then j>=kother wise
>i>j>kcan this be done using coding or notThank you
>    [[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.




  
[[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] Bollinger Band quantmod

2015-10-19 Thread bgnumis bgnum
Hi all,

When I plot Bollinger bands  with

chartSeries(
IBEX,theme="white",
  TA = c(addBBands(50,2))

)

There is a "no" shadow area that it is used to obtain the levels. How can I
plot with charSeries so that the plot start on the shadow area? I mean,
¿How can I say to de axis start plotting f.i. 50 steps forward on the chart
Series?

[[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] warning on generic function when building R package

2015-10-19 Thread Jim Lemon
I think what you may have done is simply changed x.init= to x=x.init.
x.init may or may not be there when the function is called, and that is
what the warning is saying. While you have satisfied the restriction that
the first argument must be "x", but then set the default value to something
that R is unable to resolve to a value. What you may want to do is
something like this:

plot.func<-function(x,y,...) {
 if(missing(x)) stop("Must have an x value")
 if(missing(y)) stop("Must have a y value")
 ...
}

Jim


On Tue, Oct 20, 2015 at 7:32 AM, carol white via R-help <
r-help@r-project.org> wrote:

> In effect, this works
> but whether I use x or x.init, y or y.init in plot.func, I get
>
> no visible binding for global variable ‘x.init’no visible binding for
> global variable ‘y.init’
> Regards,
>
>  On Monday, October 19, 2015 9:59 PM, Duncan Murdoch <
> murdoch.dun...@gmail.com> wrote:
>
>
>  On 19/10/2015 3:50 PM, carol white wrote:
> > Thanks Murdoch.
> >
> > defining
> > plot.func<- function(x=x.init, y=y.init, arg3, arg4, "title", col, arg5)
> >
> > and if plot doesn't take the exact parameters of plot.func but modified
> > of these parameters
> > plot(x=x.pt,y=y.pt,xlim = c(0, 10), ylim = c(0,1), xlab= "xlab",
> > ylab="ylab", main = "title", col = col,type = "l")
> >
> > then, how to define and invoke to be consisent?
>
> I don't really understand your question, but this is all about the
> function header for plot.func, not the call you make to plot().  You
> need to name the first argument as "x", you need to include "..." as an
> open argument, and you need a legal header.  So this would be okay:
>
>
> plot.func<- function(x=x.init, y=y.init, arg3, arg4,
> main = "title", # can't skip the arg name
> col, arg5,
> ...)  {  # can't skip the dots
>
> Duncan Murdoch
>
> >
> > Regards,
> >
> > On Monday, October 19, 2015 7:45 PM, Duncan Murdoch
> >  wrote:
> >
> >
> > On 19/10/2015 1:29 PM, carol white via R-help wrote:
> >
> >> Hi,I have invoked plot in a function (plot.func) as follows but when I
> > check the built package, I get a warning:
> >> plot(x.pt,y.pt,xlim = c(0, 10), ylim = c(0,1), xlab= "xlab",
> > ylab="ylab", main = "title", col = col,type = "l")
> >> R CMD check my.package
> >> checking S3 generic/method consistency ... WARNING
> >> plot:
> >>  function(x, ...)
> >> plot.func:
> >>  function(x.pt, y.pt, arg3, arg4, "title", col, arg5)
> >>
> >> See section ‘Generic functions and methods’ in the ‘Writing R
> >> Extensions’ manual.
> >> Which plot argument is illegitimate or missing and how to eliminate
> > the warning?
> >
> >
> > The first argument to plot.func needs to be called "x" if you want to
> > use it as a method.  Method signatures need to be consistent with the
> > generic signature.
> >
> > Duncan Murdoch
> >
> >
> >
> >
>
>
>
>
> [[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] warning on generic function when building R package

2015-10-19 Thread Bert Gunter
What is the class attribute of your (misnamed) x.pt argument? If it does
not inherit from class "func" then your plot.func method will not be used
when you call plot(). You would need to explicitly call plot.func()
instead.  If this question/comment makes no sense to you, then you have
some serious homework to do before you post further. Otherwise, follow the
advice you have been given.

Bert

On Monday, October 19, 2015, carol white via R-help 
wrote:

> Thanks Murdoch.
> defining
> plot.func<- function(x=x.init, y=y.init, arg3, arg4, "title", col, arg5)
> and if plot doesn't take the exact parameters of plot.func but modified of
> these parametersplot(x=x.pt,y=y.pt,xlim = c(0, 10), ylim = c(0,1), xlab=
> "xlab", ylab="ylab", main = "title", col = col,type = "l")
> then, how to define and invoke to be consisent?
> Regards,
>
>  On Monday, October 19, 2015 7:45 PM, Duncan Murdoch <
> murdoch.dun...@gmail.com > wrote:
>
>
>  On 19/10/2015 1:29 PM, carol white via R-help wrote:
> > Hi,I have invoked plot in a function (plot.func) as follows but when I
> check the built package, I get a warning:
> > plot(x.pt,y.pt,xlim = c(0, 10), ylim = c(0,1), xlab= "xlab",
> ylab="ylab", main = "title", col = col,type = "l")
> > R CMD check my.package
> > checking S3 generic/method consistency ... WARNING
> > plot:
> >  function(x, ...)
> > plot.func:
> >  function(x.pt, y.pt, arg3, arg4, "title", col, arg5)
> >
> > See section ‘Generic functions and methods’ in the ‘Writing R
> > Extensions’ manual.
> > Which plot argument is illegitimate or missing and how to eliminate the
> warning?
>
> The first argument to plot.func needs to be called "x" if you want to
> use it as a method.  Method signatures need to be consistent with the
> generic signature.
>
> Duncan Murdoch
>
>
>
>
> [[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.



-- 
Bert Gunter

"Data is not information. Information is not knowledge. And knowledge is
certainly not wisdom."
   -- Clifford Stoll

[[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] Can scan() detect end-of-file?

2015-10-19 Thread William Dunlap
> I would like to read a connection line by line with scan but
> don't know how to tell when to quit trying.  Is there any
> way that you can ask the connection object if it is at the end?

I found that adding the argument blank.lines.skip=FALSE to the
scan command will do the trick when nlines=1.  If the line is
empty it returns a vector of one empty character string;
at end-of-file it returns a zero-long character vector.  E.g.,
> cat(t <- "OneA OneB\n\n\"Third\nLine A\" \"Line3B\" Line3C\n", file= tf <- 
> tempfile())
> str({tcon <- file(tf, "r"); lapply(1:5, function(i)scan(tcon, nlines=1, 
> what=list(""), blank.lines.skip=FALSE, quiet=TRUE))})
List of 5
 $ :List of 1
  ..$ : chr [1:2] "OneA" "OneB"
 $ :List of 1
  ..$ : chr ""
 $ :List of 1
  ..$ : chr [1:3] "Third\nLine A" "Line3B" "Line3C"
 $ :List of 1
  ..$ : chr(0)
 $ :List of 1
  ..$ : chr(0)
> str({tcon <- file(tf, "r"); lapply(1:5, function(i)scan(tcon, nlines=1, 
> what=list(""), blank.lines.skip=TRUE, quiet=TRUE))})
List of 5
 $ :List of 1
  ..$ : chr [1:2] "OneA" "OneB"
 $ :List of 1
  ..$ : chr(0)
 $ :List of 1
  ..$ : chr [1:3] "Third\nLine A" "Line3B" "Line3C"
 $ :List of 1
  ..$ : chr(0)
 $ :List of 1
  ..$ : chr(0)
> str({tcon <- file(tf, "r"); lapply(1:5, function(i)scan(tcon, nlines=1, 
> what="", blank.lines.skip=FALSE, quiet=TRUE))})
List of 5
 $ : chr [1:2] "OneA" "OneB"
 $ : chr ""
 $ : chr [1:3] "Third\nLine A" "Line3B" "Line3C"
 $ : chr(0)
 $ : chr(0)
> str({tcon <- file(tf, "r"); lapply(1:5, function(i)scan(tcon, nlines=1, 
> what="", blank.lines.skip=TRUE, quiet=TRUE))})
List of 5
 $ : chr [1:2] "OneA" "OneB"
 $ : chr(0)
 $ : chr [1:3] "Third\nLine A" "Line3B" "Line3C"
 $ : chr(0)
 $ : chr(0)

Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Thu, Oct 15, 2015 at 1:16 PM, William Dunlap  wrote:
> I would like to read a connection line by line with scan but
> don't know how to tell when to quit trying.  Is there any
> way that you can ask the connection object if it is at the end?
>
> E.g.,
>
> t <- 'A "Two line\nentry"\n\n"Three\nline\nentry" D E\n'
> tfile <- tempfile()
> cat(t, file=tfile)
> tcon <- file(tfile, "r") # or tcon <- textConnection(t)
> scan(tcon, what="", nlines=1)
> #Read 2 items
> #[1] "A"   "Two line\nentry"
>> scan(tcon, what="", nlines=1)  # empty line
> #Read 0 items
> #character(0)
> scan(tcon, what="", nlines=1)
> #Read 3 items
> #[1] "Three\nline\nentry" "D"  "E"
> scan(tcon, what="", nlines=1) # end of file
> #Read 0 items
> #character(0)
> scan(tcon, what="", nlines=1) # end of file
> #Read 0 items
> #character(0)
>
> I am reading virtual line by virtual line because the lines
> may have different numbers of fields.
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.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.