[R] mlogit.optim start values problem

2015-11-12 Thread Alaa Sindi
Hello All,

I received the following message and I think it is regarding start values or 
the method.

semsem = mlogit.optim ( LL=LL*Prob[i,1] , start = c(1,1,1), method = c("bfgs"), 
iterlim = 2000, tol = 1E-05, ftol = 1e-08, steptol = 1e-10, print.level = 2)
+ 
+ }

Error in as.name(f[[2]]) : 
  'pairlist' object cannot be coerced to type ‘symbol'

Do you have an idea how to fix this?

Thanks in advance

__
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] Una ayudita

2015-11-12 Thread daniel
Heber,

Agrego:

http://kbroman.org/pkg_primer/
http://hilaryparker.com/2014/04/29/writing-an-r-package-from-scratch/
(comenzaría por éste por lo resumido)
Si usas RStudio fíjate en su sitio el tutorial para Build / Project build
tools: Package.
https://support.rstudio.com/hc/en-us/articles/200486488?version=0.99.441=desktop

Recuerdo haber leído buenos tutoriales en castellano hace al menos un par
de años (googlea: como crear un paquete en r).

Daniel Merino

El 12 de noviembre de 2015, 14:49, Francisco Rodriguez Sanchez <
f.rodriguez.s...@gmail.com> escribió:

> Hola Heber,
>
> Sin dudar, el libro de Hadley Wickham: http://r-pkgs.had.co.nz/ (acceso
> gratis online)
>
> Suerte
>
> Paco
>
>
> El 12/11/2015 a las 18:11, heber sarmiento via R-help-es escribió:
>
>> Quisiera saber si alguien me puede ayudar con documentación o el lugar
>> donde encontrarla, relacionada con la elaboración de paquetes en R, tengo
>> algunos script programados y quiero convertirlos en paquetes; he leído el
>> manual para hacer extensiones pero quiero algo más sintético y practico,
>> Agradezco cualquier colaboración al respecto
>> Heber
>> [[alternative HTML version deleted]]
>>
>> ___
>> R-help-es mailing list
>> R-help-es@r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-help-es
>>
>
> --
> Dr Francisco Rodriguez-Sanchez
> Integrative Ecology Group
> Estacion Biologica de Doñana - CSIC
> Avda. Americo Vespucio s/n
> 41092 Sevilla (Spain)
> http://bit.ly/frod_san
>
>
> ___
> R-help-es mailing list
> R-help-es@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-help-es
>



-- 
Daniel

[[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] Problema con la lectura de datos

2015-11-12 Thread Isidro Hidalgo
Completando lo que ya te han dicho, si grabas un CSV desde Excel, 3 cosas más:
- Selecciona todas las columnas vacías a la derecha de tus datos y elimínalas 
(no vale con borrar el contenido, usa el botón derecho y "Eliminar...")
- Selecciona todas las filas vacías abajo de tus datos y elimínalas (tampoco 
vale con borrar el contenido, usa el botón derecho y "Eliminar...")
- cuidado con el formato de los datos en Excel. Los decimales que veas son los 
que te llevarás al fichero CSV, perdiendo el resto...
En general, si puedes evitar usar Excel para manipular datos posteriormente en 
R (o en otro sitio), MEJOR. Si no tienes más remedio, comprueba 
exhaustivamente los datos que tienes en R, asegurándote de que son correctos. 
Uso Excel para muchas cosas y me encanta, es probablemente el mejor software 
de Office, pero tiene su PARTICULAR forma de guardar la información, y hay que 
conocerla.
Suerte

Isidro Hidalgo Arellano
Observatorio del Mercado de Trabajo
Consejería de Economía, Empresas y Empleo
http://www.castillalamancha.es/


> -Mensaje original-
> De: R-help-es [mailto:r-help-es-boun...@r-project.org] En nombre de
> Antonio Punzon
> Enviado el: miércoles, 11 de noviembre de 2015 16:35
> Para: r-help-es@r-project.org
> Asunto: Re: [R-es] Problema con la lectura de datos
>
> Si lo has guardado como csv separado por comas:
> Abre con cualquier editor el fichero: mira separador de listas y separador 
> de
> decimal, supongamos que sea "; " para las listas (esto depende de tu
> configuración regional)  y "." para los decimales (es como lo tienes en tu
> fichero) entonces
>
> dat<-read.csv("Variables.csv", header=T, sep=";", dec=".")
>
> cor(dat[, 2:ncol(dat)])
>
> # no tienes en cuenta la primera columna porque es de texto #Ten cuidado
> porque en ocasiones cuando salvas un fichero excel como csv te guarda
> columnas extras, así que asegurate que las últimas columnas corresponden
> con columnas con datos, igual para filas
>
> La verdad es que todo esto ya casi te lo han dicho todo. es un poco raro que
> no te fuuncione alguna de las soluciones que te han dado
>
> Un saludo
> Antonio
>
> __
> Antonio Punzón Merino
> Instituto Español de Oceanografía
> CO Santander
> Promontorio de San Martín s/n
> PO BOX 240
> 39080-Santander (Spain)
> Tel: +34 942 29 17 16 (Direct: 55)
> Fax: +34 942 275 072
> Email: antonio.pun...@st.ieo.es
> Web: www.ieo.es
> __
>
> El 11/11/2015 a las 16:22, Valentina Aguilera escribió:
> > Lo acabo de intentar y sigue apareciendo:  'x' must be numeric
> >
> >
> > From: j.para.fernan...@hotmail.com
> > To: valea...@outlook.es; c...@qualityexcellence.es;
> > r-help-es@r-project.org
> > Subject: RE: [R-es] Problema con la lectura de datos
> > Date: Wed, 11 Nov 2015 16:17:58 +0100
> >
> >
> >
> >
> > Has probado con
> >
> > cor(datos,use="pairwise.complete.obs")
> >
> >
> > ???
> >
> >> From: valea...@outlook.es
> >> To: c...@qualityexcellence.es; r-help-es@r-project.org
> >> Date: Wed, 11 Nov 2015 15:13:55 +
> >> Subject: Re: [R-es] Problema con la lectura de datos
> >>
> >> Hola Carlos, muchas graciaspero hago exactamente lo mismo que tu..y
> al intentar de hacer la matriz de correlaciones sigue generando error:
> >> 'x' must be numeric
> >> se podrá deber a algo relacionado con la configuración de mi equipo, o
> qué más podría hacer para que funcione!
> >> Muchas gracias!
> >>
> >> Date: Wed, 11 Nov 2015 15:53:44 +0100
> >> Subject: Re: [R-es] Problema con la lectura de datos
> >> From: c...@qualityexcellence.es
> >> To: valea...@outlook.es
> >> CC: r-help-es@r-project.org
> >>
> >> ?Hola,
> >>
> >> A mí me funciona la importación directa. Previamente he guardado la hoja
> de Excel en .csv (separado por ";").
> >> Y hago sin problemas la correlación entre dos variables (las dos 
> >> primeras).
> >>
> >>
> >>> datIn <- read.csv("Variables.csv", header=T, as.is=T, sep=";",
> >>> dec=",")
> >>> head(datIn)
> >>  EMPRESAS  AA   AB   AC   AD   AE  AF  AG  AH   AI  AJ 
> >> BA  BB
> BCDA   DB  DCDD   DE   EA   EB   EE
> >> 1 A.AUDITOR\xcdA 200  350   90 2000  500  30  59  24  5937586 2644207
> 13.47170  588.00  834  0.00  0.0  0.  0.00  477  763 57.19424 
> 62.51638
> >> 2 A.JUR\xcdDICAS   0  499  120  825  358  81  82  27  5012257 2666411
> 15.69663  891.00 1655 29.00  0.0  0. 43.03  738 1400 44.59592 
> 52.71429
> >> 3A.SERVICIOS 2190   62 1411  743 112  71  45 11461538 5190688 
> >> 21.10714
> 855.04 1222 21.00 80.01000 65.5527 69.00  694 1098 56.79214 63.20583
> >> 4B.M\xc1LAGA 776 1796 1590 1888 2381 392 168 107 21441999   0
> 12.54286 2768.00 3677 58.00 82.0 68. 55.00 2206 3332 59.99456
> 66.20648
> >> 5  B.SEVILLA 143  3940  5020  30  30  18  2966295 1173798 
> >> 15.85185
> 355.00  894  0.00 56.49913  0. 32.92  444  779 49.66443 56.99615
> >> 6   CONSULTORIAS 481  701  238 1259  713  46 125   0 12984728 

Re: [R-es] Problema con la lectura de datos

2015-11-12 Thread miguel.angel.rodriguez.muinos
Otra opción es importar directamente los datos que necesites usando
XLConnect (sin llevarlos a CSV).
Ese paquete permite hacer cosas muy potentes desde el propio fichero de
Excel.
https://cran.r-project.org/web/packages/XLConnect/index.html

Recomiendo, encarecidamente, la lectura de sus dos vignettes.


Un Saludo,

--
Miguel Ángel Rodríguez Muíños
Dirección Xeral de Saúde Pública
Consellería de Sanidade
Xunta de Galicia
http://dxsp.sergas.es




El 12/11/2015 a las 9:14, Isidro Hidalgo escribió:
> Completando lo que ya te han dicho, si grabas un CSV desde Excel, 3 cosas más:
> - Selecciona todas las columnas vacías a la derecha de tus datos y elimínalas
> (no vale con borrar el contenido, usa el botón derecho y "Eliminar...")
> - Selecciona todas las filas vacías abajo de tus datos y elimínalas (tampoco
> vale con borrar el contenido, usa el botón derecho y "Eliminar...")
> - cuidado con el formato de los datos en Excel. Los decimales que veas son los
> que te llevarás al fichero CSV, perdiendo el resto...
> En general, si puedes evitar usar Excel para manipular datos posteriormente en
> R (o en otro sitio), MEJOR. Si no tienes más remedio, comprueba
> exhaustivamente los datos que tienes en R, asegurándote de que son correctos.
> Uso Excel para muchas cosas y me encanta, es probablemente el mejor software
> de Office, pero tiene su PARTICULAR forma de guardar la información, y hay que
> conocerla.
> Suerte
>
> Isidro Hidalgo Arellano
> Observatorio del Mercado de Trabajo
> Consejería de Economía, Empresas y Empleo
> http://www.castillalamancha.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] "haven" - read_spss: How to avoid extracting value labels instead of long labels?

2015-11-12 Thread Dimitri Liakhovitski
Looks like a little bug in 'haven':

When I actually look at the attributes of one variable that has no
long label in SPSS but has Value Labels, I am getting:
attr(spss1$WAVE, "label")
NULL

But when I sapply my function longlabels to my data frame and ask it
to print the long labels for each column, for the same column "WAVE" I
am getting - instead of NULL:
NULL
VERY/SOMEWHAT FAMILIARNOT AT ALL FAMILIAR
 1  2

This is, of course, incorrect, because it grabs the next attribute
(which one? And replaces NULL with it).
Any suggestions?
Thanks!




On Thu, Nov 12, 2015 at 11:56 AM, Dimitri Liakhovitski
 wrote:
> Hello!
>
> I don't have an example file, but I think my question should be clear
> without it.
> I have an SPSS file. I read it in using 'haven':
>
> library(haven)
> spss1 <- read_spss("SPSS_Example.sav")
>
> I created a function that extracts the long labels (in SPSS - "Label"):
>
> fix_labels <- function(x, TextIfMissing) {
>   val <- attr(x, "label")
>   if (is.null(val)) TextIfMissing else val
> }
> longlabels <- sapply(spss1, fix_labels, TextIfMissing = "NO LABLE IN SPSS")
>
> This function is supposed to create a vector of long labels and
> usually it does, e.g.:
>
> str(longlabels)
>  Named chr [1:64] "Serial number" ...
>  - attr(*, "names")= chr [1:64] "Respondent_Serial" "weight" "r7_1" "r7_2" ...
>
> However, I just got an SPSS file with 92 columns and ran exactly the
> same function on it. Now, I am getting not a vector, but a list
>
> str(longlabels)
> List of 92
>  $ VEHRATED  : chr "VEHICLE RATED"
>  $ RESPID: chr "RESPONDENT ID"
>  $ RESPID8   : chr "8 DIGIT RESPONDENT NUMBER"
>
> An observation about the structure of longlabels here: those columns
> that do NOT have a long lable in SPSS but DO have Values (value
> labels) - for them my function grabs their value labels, so that now
> my long label is recorded as a numeric vector with names, e.g.:
>
>  $ AWARE2: Named num [1:2] 1 2
>   ..- attr(*, "names")= chr [1:2] "VERY/SOMEWHAT FAMILIAR" "NOT AT ALL 
> FAMILIAR"
>
> Question: How could I avoid the extraction of the Value Labels for the
> columns that have no long labels?
>
> Thank you very much!
> --
> Dimitri Liakhovitski



-- 
Dimitri Liakhovitski

__
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] "haven" - read_spss: How to avoid extracting value labels instead of long labels?

2015-11-12 Thread Dimitri Liakhovitski
I have to rephrase my question again - it's clearly a small bug in
haven. Here is what it is about:

If I have a column in SPSS that has BOTH a long label and value
labels, then everything works fine - I access one with 'label' and
another with 'labels':

attr(spss1$MYVAR, "label")
[1] "LONG LABEL"
attr(spss1$MYVAR, "labels")
DEFINITELY CONSIDER   PROBABLY CONSIDER   PROBABLY NOT
CONSIDER DEFINITELY NOT CONSIDER
  1   2
3   4

However, if I have a column that has no long label and ONLY value
labels, then it's not working properly:

> attr(spss1$MYVAR, "label")
VERY/SOMEWHAT FAMILIARNOT AT ALL FAMILIAR
 1  2
> attr(spss1$MYVAR, "labels")
VERY/SOMEWHAT FAMILIARNOT AT ALL FAMILIAR
 1  2

And I actually need to be able to identify if label is empty.
Thank you for looking into it!

Dimitri


On Thu, Nov 12, 2015 at 5:55 PM, Dimitri Liakhovitski
 wrote:
> Looks like a little bug in 'haven':
>
> When I actually look at the attributes of one variable that has no
> long label in SPSS but has Value Labels, I am getting:
> attr(spss1$WAVE, "label")
> NULL
>
> But when I sapply my function longlabels to my data frame and ask it
> to print the long labels for each column, for the same column "WAVE" I
> am getting - instead of NULL:
> NULL
> VERY/SOMEWHAT FAMILIARNOT AT ALL FAMILIAR
>  1  2
>
> This is, of course, incorrect, because it grabs the next attribute
> (which one? And replaces NULL with it).
> Any suggestions?
> Thanks!
>
>
>
>
> On Thu, Nov 12, 2015 at 11:56 AM, Dimitri Liakhovitski
>  wrote:
>> Hello!
>>
>> I don't have an example file, but I think my question should be clear
>> without it.
>> I have an SPSS file. I read it in using 'haven':
>>
>> library(haven)
>> spss1 <- read_spss("SPSS_Example.sav")
>>
>> I created a function that extracts the long labels (in SPSS - "Label"):
>>
>> fix_labels <- function(x, TextIfMissing) {
>>   val <- attr(x, "label")
>>   if (is.null(val)) TextIfMissing else val
>> }
>> longlabels <- sapply(spss1, fix_labels, TextIfMissing = "NO LABLE IN SPSS")
>>
>> This function is supposed to create a vector of long labels and
>> usually it does, e.g.:
>>
>> str(longlabels)
>>  Named chr [1:64] "Serial number" ...
>>  - attr(*, "names")= chr [1:64] "Respondent_Serial" "weight" "r7_1" "r7_2" 
>> ...
>>
>> However, I just got an SPSS file with 92 columns and ran exactly the
>> same function on it. Now, I am getting not a vector, but a list
>>
>> str(longlabels)
>> List of 92
>>  $ VEHRATED  : chr "VEHICLE RATED"
>>  $ RESPID: chr "RESPONDENT ID"
>>  $ RESPID8   : chr "8 DIGIT RESPONDENT NUMBER"
>>
>> An observation about the structure of longlabels here: those columns
>> that do NOT have a long lable in SPSS but DO have Values (value
>> labels) - for them my function grabs their value labels, so that now
>> my long label is recorded as a numeric vector with names, e.g.:
>>
>>  $ AWARE2: Named num [1:2] 1 2
>>   ..- attr(*, "names")= chr [1:2] "VERY/SOMEWHAT FAMILIAR" "NOT AT ALL 
>> FAMILIAR"
>>
>> Question: How could I avoid the extraction of the Value Labels for the
>> columns that have no long labels?
>>
>> Thank you very much!
>> --
>> Dimitri Liakhovitski
>
>
>
> --
> Dimitri Liakhovitski



-- 
Dimitri Liakhovitski

__
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] extraction of parameters for intercept from "lavaan" object

2015-11-12 Thread Dimitri Liakhovitski
I am using 'lavaan' to estimate a single indicators model.
My model itself looks like this:

sem1model <- '
Imp ~ Ux
Mem ~ Ux + Imp
AE ~ Imp + Mem + Ux
UL ~ Ux + Imp + AE
'
sem1 <- sem(sem1model, data = mydata)

I am getting a decent fit and want to use this model.
My unstandardized coefficient for regressing Imp onto UX is 1.057,
taken from parameterEstimates(sem1, standardized = TRUE):

   lhs  op   rhs   est
1 Impression  ~UX 1.057

Question: Can I know say: in order to predict Imp based on Ux it's Imp
= Ux * 1.057?
Or should there also be an intercept present in this formula?
I did not specify any intercepts anywhere in my model?

If there should be an intercept, then where can I find it in the object sem1?

Thanks a lot!

-- 
Dimitri Liakhovitski

__
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] Compute Regressions with R-Function

2015-11-12 Thread Bert Gunter
No function is necessary for multiple lhs's. lm() allows a matrix as
it's lhs and will fit a separate regression for each column of the
matrix. Please read ?lm carefully for details. For that matter, please
read the linked Help pages and/or spend some time with a tutorial
(there are many on the web) to learn proper linear models syntax.
There are subtleties involved (formulas have environments, use of ".",
use of I(), etc.) that require some effort to learn. It may help you
avoid further difficulties down the road.

Cheers,
Bert
Bert Gunter

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


On Thu, Nov 12, 2015 at 9:37 AM, Jeff Newmiller
 wrote:
> Your email is severely damaged because you sent it using HTML format. Please 
> adjust the settings in your email software to use only plain text when 
> sending to this list so we can see what you see.
>
> While you are at it you should read about making your examples reproducible 
> [1]... it may seem like a pain but you are likely to get better assistance if 
> you make the extra effort before pressing the send button.
>
> (Also, RStudio is a fine way to use R, but many people here use the R 
> interpreter just fine without it so ask all you like about R here but don't 
> assume we are all looking at the same screen you are. If you find you need to 
> refer to RStudio to ask your question then you may be going off-topic. Your 
> current question seems on topic though.)
>
> I don't see a problem with your approach such as I can guess where you are 
> going with it, but your code is messed up and your error does not look like 
> it goes with that code so I have no idea where your actual problem is.
>
> [1] 
> http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
> ---
> 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 November 12, 2015 8:27:58 AM PST, Matthias Worni  
> wrote:
>>Hello
>>
>>I was trying to set up a function() that allows easely to calculate
>>regressions for severel dependent variables with the same independent
>>variables.
>>
>>My function looked like this but was turned down by an error (Im quiet
>>new
>>to R Studio). So here is my solution:
>>
>>b
>>CO2
>>logTrop_Aerosol
>>lm(b ~ CO2  + logTrop_Aerosol  )
>>
>>Trend <- function(x,CO2,logTrop_Aerosol) { lm x   CO2  +
>>logTrop_Aerosol}
>>
>>b is a vector containing 400 values of heat content
>>CO2 also contains 400 values as well as logTropAerosol
>>
>>my idea would be that I simply can replace x (heat content) by other
>>vectors containing heat content.
>>
>>The error I got was the following:
>>
>>Error: unexpected symbol in "Trend <- function(x,y,z) { lm x"
>>
>>Thanks a lot for the help!
>>
>>Best Matthias
>>
>>   [[alternative HTML version deleted]]
>>
>>__
>>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>https://stat.ethz.ch/mailman/listinfo/r-help
>>PLEASE do read the posting guide
>>http://www.R-project.org/posting-guide.html
>>and provide commented, minimal, self-contained, reproducible code.
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Quotes

2015-11-12 Thread Jim Lemon
Hi Daniel,
As David said, these problems are almost always due to fancy quotes. If you
want plain old ASCII 34 (double) or 39 (single) quotes, try using Notepad
for your editing rather than Word.

Jim


On Thu, Nov 12, 2015 at 5:02 PM, David Winsemius 
wrote:

>
> > On Nov 11, 2015, at 6:54 PM, Daniel Wiegert  wrote:
> >
> > Hello, I am trying to use a code which requires quotes around each of
> about 1000 entries. When I did this
>
> The use of pronouns in place of code is a major cause of ambiguity. What
> was … “this”?
>
>
> > in Microsoft programs, R rejected every quote.
>
> Again. the phrase "R rejected” is completely ambiguous. Did you see an
> error message after you did . If so, please offer up for
> examination both the  and the error message.
>
>
> > I converted the font to courier new size 10 true type (the R default).
> No luck. I had to find a sample code and copy the quotes from that 2000
> times for R to accept them, or type them in manually in R.
>
> Word typically uses smart quotes rather than either the single-quote or
> double-quotes. You can change this behavior in Word by changing the
> preferences. But you really should not be using Word for either data entry
> or for code.
>
> >
> > Is there anyway to make this easier? What font in Word/Excel etc. does R
> prefer and will function using quotes? Commas, letters, numbers, all work,
> just the full double quotes won't work.
>
> As above. The “quotes” that Word uses are not shared by most codign
> platforms.
>
> >
> > Thank you,
> >
> > Daniel
> > __
> > 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.
>
> David Winsemius
> Alameda, CA, USA
>
> __
> 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] recursive partitioning in R

2015-11-12 Thread Therneau, Terry M., Ph.D.
Look at the rpart vignette "User written split functions".  The code allows you to add 
your own splitting method to the code (in R, no C required).  This has proven to be very 
useful for trying out new ideas.


The second piece would be to do your own cross-validation.  That is, turn off the built in 
cross-validation using the xval=0 option, then explicitly do the cross-validation 
yourself.  Fit a new tree to some chosen subset of data, using your split rule of course, 
and then use predict() to get predicted values for the remaining observations. Again, this 
is all in R, and you can explicitly control your in or out of bag subsets.

The xpred.rpart function may be useful to automate some of the steps.

If you look up rpart on CRAN, you will see a link to the package source.  If you were to 
read the C source code you will discover that 95% is boring bookkeeping of what 
observations are in what part(s) of the tree, sorting the data, tracking missing values, 
etc.  If you ever do want to write your own code you are more than welcome to build off 
this --- I wouldn't want to write that part again.


Terry Therneau

On 11/12/2015 05:00 AM, r-help-requ...@r-project.org wrote:

Dear List,

I'd like to make a few modifications to the typical CART algorithm, and
I'd rather not code the whole thing from scratch.  Specifically I want
to use different in-sample and out-of-sample fit criteria in the split
choosing and cross-validation stages.

I see however that the code for CART in both the rpart and the tree
packages is written in C.

Two questions:

   * Where is the C code?  It might be possible to get a C-fluent
 programmer to help me with this.
   * Is there any code for CART that is written entirely in R?

Thanks,
Andrew


__
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] *.rpt data

2015-11-12 Thread Mangalani Peter Makananisa
Hi,

Could you please assist, how do I load the rpt data into R without converting 
it first to csv?

Kind regards
Peter

Please Note: This email and its contents are subject to our email legal notice 
which can be viewed at http://www.sars.gov.za/Pages/Email-disclaimer.aspx
[[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] Problema con la lectura de datos

2015-11-12 Thread Isidro Hidalgo
Yo también uso XLConnect y me va muy bien.


Isidro Hidalgo Arellano
Observatorio del Mercado de Trabajo
Consejería de Economía, Empresas y Empleo
http://www.castillalamancha.es/



> -Mensaje original-
> De: R-help-es [mailto:r-help-es-boun...@r-project.org] En nombre de
> Francisco Rodríguez
> Enviado el: jueves, 12 de noviembre de 2015 11:35
> Para: r-help-es@r-project.org
> Asunto: Re: [R-es] Problema con la lectura de datos
>
> Yo uso habitualmente XLConnect y est  muy bien, permite un control total al
> poder atacar directamente a la terna hoja, celda y columna. Aqu  un trozo de
> c digo de muestra:
> library(XLConnect)
> a <- readWorksheetFromFile(" n>", sheet = ...,startRow = ..., startCol = ..., endCol = ..., endRow = ..., 
> header
> = FALSE) Como se observa se puede escoger desde un  nico n mero situado
> en una (Hoja; Celda; Columna) hasta una matriz Ojo, que el objeto a ser  de
> tipo lista, despu s se tendr  que pasar al tipo de dato que se necesite
>
> XLConnect es compatible con ficheros xls y xlsx Un saludo
>
> > From: miguel.angel.rodriguez.mui...@sergas.es
> > To: r-help-es@r-project.org
> > Date: Thu, 12 Nov 2015 09:58:06 +
> > Subject: Re: [R-es] Problema con la lectura de datos
> >
> > Otra opci n es importar directamente los datos que necesites usando
> > XLConnect (sin llevarlos a CSV).
> > Ese paquete permite hacer cosas muy potentes desde el propio fichero
> > de Excel.
> > https://cran.r-project.org/web/packages/XLConnect/index.html
> >
> > Recomiendo, encarecidamente, la lectura de sus dos vignettes.
> >
> >
> > Un Saludo,
> >
> > --
> > Miguel  ngel Rodr guez Mu  os
> > Direcci n Xeral de Sa de P blica
> > Conseller a de Sanidade
> > Xunta de Galicia
> > http://dxsp.sergas.es
> >
> >
> >
> >
> > El 12/11/2015 a las 9:14, Isidro Hidalgo escribi :
> > > Completando lo que ya te han dicho, si grabas un CSV desde Excel, 3
> cosas m s:
> > > - Selecciona todas las columnas vac as a la derecha de tus datos y
> > > elim nalas (no vale con borrar el contenido, usa el bot n derecho y
> > > "Eliminar...")
> > > - Selecciona todas las filas vac as abajo de tus datos y elim nalas
> > > (tampoco vale con borrar el contenido, usa el bot n derecho y
> > > "Eliminar...")
> > > - cuidado con el formato de los datos en Excel. Los decimales que
> > > veas son los que te llevar s al fichero CSV, perdiendo el resto...
> > > En general, si puedes evitar usar Excel para manipular datos
> > > posteriormente en R (o en otro sitio), MEJOR. Si no tienes m s
> > > remedio, comprueba exhaustivamente los datos que tienes en R, asegur
> ndote de que son correctos.
> > > Uso Excel para muchas cosas y me encanta, es probablemente el mejor
> > > software de Office, pero tiene su PARTICULAR forma de guardar la
> > > informaci n, y hay que conocerla.
> > > Suerte
> > >
> > > Isidro Hidalgo Arellano
> > > Observatorio del Mercado de Trabajo
> > > Consejer a de Econom a, Empresas y Empleo
> > > http://www.castillalamancha.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
>
>   [[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] Problema con la lectura de datos

2015-11-12 Thread Bartolomé Marcos , José Antonio
El problema de XLConnect es que necesita java para funcionar  y en equipos con 
poca memoria puede dar problemas.
Por eso, yo aconsejo openxlsx (para Excel 2007 o superior) que no necesita de 
ningún programa externo.



-Mensaje original-
De: R-help-es [mailto:r-help-es-boun...@r-project.org] En nombre de Isidro 
Hidalgo
Enviado el: Thursday, November 12, 2015 11:50 AM
Para: r-help-es@r-project.org
Asunto: Re: [R-es] Problema con la lectura de datos

Yo también uso XLConnect y me va muy bien.


Isidro Hidalgo Arellano
Observatorio del Mercado de Trabajo
Consejería de Economía, Empresas y Empleo http://www.castillalamancha.es/



> -Mensaje original-
> De: R-help-es [mailto:r-help-es-boun...@r-project.org] En nombre de 
> Francisco Rodríguez Enviado el: jueves, 12 de noviembre de 2015 11:35
> Para: r-help-es@r-project.org
> Asunto: Re: [R-es] Problema con la lectura de datos
>
> Yo uso habitualmente XLConnect y est  muy bien, permite un control 
> total al poder atacar directamente a la terna hoja, celda y columna. 
> Aqu  un trozo de c digo de muestra:
> library(XLConnect)
> a <- readWorksheetFromFile(" n>", sheet = ...,startRow = ..., startCol = ..., endCol = ..., endRow 
> n>= ...,
> header
> = FALSE) Como se observa se puede escoger desde un  nico n mero 
> situado en una (Hoja; Celda; Columna) hasta una matriz Ojo, que el 
> objeto a ser  de tipo lista, despu s se tendr  que pasar al tipo de 
> dato que se necesite
>
> XLConnect es compatible con ficheros xls y xlsx Un saludo
>
> > From: miguel.angel.rodriguez.mui...@sergas.es
> > To: r-help-es@r-project.org
> > Date: Thu, 12 Nov 2015 09:58:06 +
> > Subject: Re: [R-es] Problema con la lectura de datos
> >
> > Otra opci n es importar directamente los datos que necesites usando 
> > XLConnect (sin llevarlos a CSV).
> > Ese paquete permite hacer cosas muy potentes desde el propio fichero 
> > de Excel.
> > https://cran.r-project.org/web/packages/XLConnect/index.html
> >
> > Recomiendo, encarecidamente, la lectura de sus dos vignettes.
> >
> >
> > Un Saludo,
> >
> > --
> > Miguel  ngel Rodr guez Mu  os
> > Direcci n Xeral de Sa de P blica
> > Conseller a de Sanidade
> > Xunta de Galicia
> > http://dxsp.sergas.es
> >
> >
> >
> >
> > El 12/11/2015 a las 9:14, Isidro Hidalgo escribi :
> > > Completando lo que ya te han dicho, si grabas un CSV desde Excel, 
> > > 3
> cosas m s:
> > > - Selecciona todas las columnas vac as a la derecha de tus datos y 
> > > elim nalas (no vale con borrar el contenido, usa el bot n derecho 
> > > y
> > > "Eliminar...")
> > > - Selecciona todas las filas vac as abajo de tus datos y elim 
> > > nalas (tampoco vale con borrar el contenido, usa el bot n derecho 
> > > y
> > > "Eliminar...")
> > > - cuidado con el formato de los datos en Excel. Los decimales que 
> > > veas son los que te llevar s al fichero CSV, perdiendo el resto...
> > > En general, si puedes evitar usar Excel para manipular datos 
> > > posteriormente en R (o en otro sitio), MEJOR. Si no tienes m s 
> > > remedio, comprueba exhaustivamente los datos que tienes en R, 
> > > asegur
> ndote de que son correctos.
> > > Uso Excel para muchas cosas y me encanta, es probablemente el 
> > > mejor software de Office, pero tiene su PARTICULAR forma de 
> > > guardar la informaci n, y hay que conocerla.
> > > Suerte
> > >
> > > Isidro Hidalgo Arellano
> > > Observatorio del Mercado de Trabajo Consejer a de Econom a, 
> > > Empresas y Empleo http://www.castillalamancha.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
>
>   [[alternative HTML version deleted]]

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

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


Re: [R] Problems using save to store NAMED R objects

2015-11-12 Thread Duncan Murdoch

On 12/11/2015 6:41 PM, Julio Sergio Santana wrote:

I have to store (in a file) an R object that was created with is name as
a string of characters, as follows:

: nn <- "xxx"
: assign(nn, 5)
: xxx
[1] 5

I don't want to store the object nn but the object xxx. I tried the
following two expressions but none of them worked:

: save(get(nn), file="f.RData")
Error in save(get(nn), file = "f.RData") : object ‘get(nn)’ not found

: save(eval(nn), file="f.RData")
Error in save(eval(nn), file = "f.RData") : object ‘eval(nn)’ not
found

I know that both save(xxx, ..), and save("xxx", ..) work, but the fact
is that the string is going to be provided by an user:

: nn <- readline("Your variable->")

and
: save(nn, file="f.RData")
stores the objet nn not xxx

Do you have any comments on this?


I believe

do.call(save, list(as.name(nn), file = "f.RData"))

should do what you want.  There are probably other ways, maybe simpler 
ones.


If you're interested, the theory here is that do.call() constructs a 
call to the first argument, with arguments found by evaluating the 
second argument.


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.

[R] Problems using save to store NAMED R objects

2015-11-12 Thread Julio Sergio Santana
I have to store (in a file) an R object that was created with is name as 
a string of characters, as follows:

   : nn <- "xxx"
   : assign(nn, 5)
   : xxx
   [1] 5

I don't want to store the object nn but the object xxx. I tried the 
following two expressions but none of them worked:

   : save(get(nn), file="f.RData")
   Error in save(get(nn), file = "f.RData") : object ‘get(nn)’ not found

   : save(eval(nn), file="f.RData")
   Error in save(eval(nn), file = "f.RData") : object ‘eval(nn)’ not 
found

I know that both save(xxx, ..), and save("xxx", ..) work, but the fact 
is that the string is going to be provided by an user:

   : nn <- readline("Your variable->")

and 
   : save(nn, file="f.RData")
stores the objet nn not xxx

Do you have any comments on this?

Thanks

  -Sergio.
__
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] Problems using save to store NAMED R objects

2015-11-12 Thread Julio Sergio Santana
Thanks Duncan,

I just saw another, but similar, solution for this in
http://stackoverflow.com/questions/11084395/save-object-using-variable-with-object-name
,
and it is:

   : save(list=nn, file="f.RData")

Thanks again,

  -Sergio.

On Thu, Nov 12, 2015 at 8:57 PM, Duncan Murdoch 
wrote:

> On 12/11/2015 6:41 PM, Julio Sergio Santana wrote:
>
>> I have to store (in a file) an R object that was created with is name as
>> a string of characters, as follows:
>>
>> : nn <- "xxx"
>> : assign(nn, 5)
>> : xxx
>> [1] 5
>>
>> I don't want to store the object nn but the object xxx. I tried the
>> following two expressions but none of them worked:
>>
>> : save(get(nn), file="f.RData")
>> Error in save(get(nn), file = "f.RData") : object ‘get(nn)’ not found
>>
>> : save(eval(nn), file="f.RData")
>> Error in save(eval(nn), file = "f.RData") : object ‘eval(nn)’ not
>> found
>>
>> I know that both save(xxx, ..), and save("xxx", ..) work, but the fact
>> is that the string is going to be provided by an user:
>>
>> : nn <- readline("Your variable->")
>>
>> and
>> : save(nn, file="f.RData")
>> stores the objet nn not xxx
>>
>> Do you have any comments on this?
>>
>
> I believe
>
> do.call(save, list(as.name(nn), file = "f.RData"))
>
> should do what you want.  There are probably other ways, maybe simpler
> ones.
>
> If you're interested, the theory here is that do.call() constructs a call
> to the first argument, with arguments found by evaluating the second
> argument.
>
> Duncan Murdoch
>



-- 

[image: Julio Sergio Santana on about.me]

Julio Sergio Santana
about.me/juliosergio00
  

Julio Sergio Santana
Instituto Mexicano de Tecnología del Agua
Tel   +52 777 3293600 x 826
Tel/Fax +52 777 3293683
---

[[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] *.rpt data

2015-11-12 Thread PIKAL Petr
Hi

Please keep conversation on list, others may have better opinion than myself. 
The attachment is not welcomed when posting to R help list, you can post error 
message directly to your mail.

Anyway, you will hardly get any useful answer if you keep your cards hidden. 
You shall at least show some snippet of rpt file and its size.

Cheers
Petr


> -Original Message-
> From: Mangalani Peter Makananisa [mailto:pmakanan...@sars.gov.za]
> Sent: Thursday, November 12, 2015 3:58 PM
> To: PIKAL Petr
> Subject: RE: [R] *.rpt data
>
> I can see now it is working but R is now complaining about memory
> allocation, see the attached.
>
> Peter
>
> -Original Message-
> From: PIKAL Petr [mailto:petr.pi...@precheza.cz]
> Sent: 12 November 2015 03:53 PM
> To: Mangalani Peter Makananisa; r-help
> Subject: RE: [R] *.rpt data
>
> Hi
>
> If it is really "like" csv data you can import it by
>
> read.csv...
>
> or you can use any other read.* function.
>
> Did you try it? If yes, what was the result?
> If not, why not?
>
> Cheers
> Petr
>
> > -Original Message-
> > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Sarah
> > Goslee
> > Sent: Thursday, November 12, 2015 2:41 PM
> > To: Mangalani Peter Makananisa; r-help
> > Subject: Re: [R] *.rpt data
> >
> > On Thursday, November 12, 2015, Mangalani Peter Makananisa <
> > pmakanan...@sars.gov.za> wrote:
> >
> > > .rpt is one of the data extension like .csv, .txt , …..
> > >
> > > All extensions are 'data extensions' in some sense.
> >
> > Without knowing quite a bit more about YOUR rpt extension, it's
> > impossible to answer.
> >
> >
> > > *From:* Sarah Goslee [mailto:sarah.gos...@gmail.com
> > > ]
> > > *Sent:* 12 November 2015 03:17 PM
> > > *To:* Mangalani Peter Makananisa
> > > *Cc:* r-help@r-project.org
> > > 
> > > *Subject:* Re: [R] *.rpt data
> > >
> > >
> > >
> > > What is "rpt data"? What source produced it? Where did you get it?
> > > Is it associated with particular software? Is it ascii or binary?
> > >
> > > Sarah
> > >
> > > On Thursday, November 12, 2015, Mangalani Peter Makananisa <
> > > pmakanan...@sars.gov.za
> > > > wrote:
> > >
> > > Hi,
> > >
> > > Could you please assist, how do I load the rpt data into R without
> > > converting it first to csv?
> > >
> > > Kind regards
> > > Peter
> > >
> > > Please Note: This email and its contents are subject to our email
> > > legal notice which can be viewed at
> > > http://www.sars.gov.za/Pages/Email-disclaimer.aspx
> > > [[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.
> > >
> > >
> > >
> > > --
> > > Sarah Goslee
> > > http://www.stringpage.com
> > > http://www.sarahgoslee.com
> > > http://www.functionaldiversity.org
> > >
> > > Please Note: This email and its contents are subject to our email
> > > legal notice which can be viewed at
> > > http://www.sars.gov.za/Pages/Email-disclaimer.aspx
> > >
> >
> >
> > --
> > Sarah Goslee
> > http://www.stringpage.com
> > http://www.sarahgoslee.com
> > http://www.functionaldiversity.org
> >
> >   [[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 

Re: [R] *.rpt data

2015-11-12 Thread PIKAL Petr
Hi

If it is really "like" csv data you can import it by

read.csv...

or you can use any other read.* function.

Did you try it? If yes, what was the result?
If not, why not?

Cheers
Petr

> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Sarah
> Goslee
> Sent: Thursday, November 12, 2015 2:41 PM
> To: Mangalani Peter Makananisa; r-help
> Subject: Re: [R] *.rpt data
>
> On Thursday, November 12, 2015, Mangalani Peter Makananisa <
> pmakanan...@sars.gov.za> wrote:
>
> > .rpt is one of the data extension like .csv, .txt , …..
> >
> > All extensions are 'data extensions' in some sense.
>
> Without knowing quite a bit more about YOUR rpt extension, it's
> impossible to answer.
>
>
> > *From:* Sarah Goslee [mailto:sarah.gos...@gmail.com
> > ]
> > *Sent:* 12 November 2015 03:17 PM
> > *To:* Mangalani Peter Makananisa
> > *Cc:* r-help@r-project.org
> > 
> > *Subject:* Re: [R] *.rpt data
> >
> >
> >
> > What is "rpt data"? What source produced it? Where did you get it? Is
> > it associated with particular software? Is it ascii or binary?
> >
> > Sarah
> >
> > On Thursday, November 12, 2015, Mangalani Peter Makananisa <
> > pmakanan...@sars.gov.za
> > > wrote:
> >
> > Hi,
> >
> > Could you please assist, how do I load the rpt data into R without
> > converting it first to csv?
> >
> > Kind regards
> > Peter
> >
> > Please Note: This email and its contents are subject to our email
> > legal notice which can be viewed at
> > http://www.sars.gov.za/Pages/Email-disclaimer.aspx
> > [[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.
> >
> >
> >
> > --
> > Sarah Goslee
> > http://www.stringpage.com
> > http://www.sarahgoslee.com
> > http://www.functionaldiversity.org
> >
> > Please Note: This email and its contents are subject to our email
> > legal notice which can be viewed at
> > http://www.sars.gov.za/Pages/Email-disclaimer.aspx
> >
>
>
> --
> Sarah Goslee
> http://www.stringpage.com
> http://www.sarahgoslee.com
> http://www.functionaldiversity.org
>
>   [[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 

Re: [R] *.rpt data

2015-11-12 Thread John McKown
On Thu, Nov 12, 2015 at 7:52 AM, PIKAL Petr  wrote:

> Hi
>
> If it is really "like" csv data you can import it by
>
> read.csv...
>
> or you can use any other read.* function.
>
> Did you try it? If yes, what was the result?
> If not, why not?
>
> Cheers
> Petr
>

​Purely as a guess, ".rpt" really seems to be short for "report". Which I
would guess indicates that this is some sort of file which was originally
physically printed to be read by a human. So I would _guess_ that perhaps
it is column oriented and might be readable using read.fwf() .Or course, it
if really is a "report" there are those irritating page headers & footers,
perhaps along with a summary at the end which would need to be ignored. The
OP really needs to cut'n'paste (NO HTML PLEASE!) about 10 lines for us to
all "eyeball".​


-- 

Schrodinger's backup: The condition of any backup is unknown until a
restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! <><
John McKown

[[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] *.rpt data

2015-11-12 Thread Sarah Goslee
On Thursday, November 12, 2015, Mangalani Peter Makananisa <
pmakanan...@sars.gov.za> wrote:

> .rpt is one of the data extension like .csv, .txt , …..
>
> All extensions are 'data extensions' in some sense.

Without knowing quite a bit more about YOUR rpt extension, it's impossible
to answer.


> *From:* Sarah Goslee [mailto:sarah.gos...@gmail.com
> ]
> *Sent:* 12 November 2015 03:17 PM
> *To:* Mangalani Peter Makananisa
> *Cc:* r-help@r-project.org
> 
> *Subject:* Re: [R] *.rpt data
>
>
>
> What is "rpt data"? What source produced it? Where did you get it? Is it
> associated with particular software? Is it ascii or binary?
>
> Sarah
>
> On Thursday, November 12, 2015, Mangalani Peter Makananisa <
> pmakanan...@sars.gov.za
> > wrote:
>
> Hi,
>
> Could you please assist, how do I load the rpt data into R without
> converting it first to csv?
>
> Kind regards
> Peter
>
> Please Note: This email and its contents are subject to our email legal
> notice which can be viewed at
> http://www.sars.gov.za/Pages/Email-disclaimer.aspx
> [[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.
>
>
>
> --
> Sarah Goslee
> http://www.stringpage.com
> http://www.sarahgoslee.com
> http://www.functionaldiversity.org
>
> Please Note: This email and its contents are subject to our email legal
> notice which can be viewed at
> http://www.sars.gov.za/Pages/Email-disclaimer.aspx
>


-- 
Sarah Goslee
http://www.stringpage.com
http://www.sarahgoslee.com
http://www.functionaldiversity.org

[[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] How to calculate variance on multiple numbers at once?

2015-11-12 Thread Luigi Marongiu
Essentially the problem is related to this problem. I am measuring the
fluorescence (flu) generated over time (clock) from 5 samples (samp)
which are grouped by two targets (targ).
I can calculate the variance of the fluorescence for each sample at a
given time (in this example, for sample 1); but if I consider a target
at the time there would be multiple readings at once to consider.
would the variance formula still be OK to use.
In this example:
>>>
samp <- c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4,
5, 5, 5, 5, 5)
clock <- rep(1:5,5)
targ <- c(rep("A", 5), rep("B", 5), rep("A", 5), rep("A", 5), rep("B", 5))
flu <- c(-0.012, -0.01, -0.008, -0.002, -0.001, -0.007, -0.008,
-0.009, -0.009, -0.012, -0.002, -0.003, -0.003, 0.001, 0.002, -0.006,
-0.001, 0.001, 0.002, 0.002, -0.002, -0.003, -0.003, -0.002, -0.001)
my.data <- data.frame(well, clock, targ, flu, stringsAsFactors = FALSE)

# variance with individual numbers
sub <- subset(my.data, samp == 1)
plot(sub$flu ~ sub$clock)
abline(lm(sub$flu ~ sub$clock))
for (i in 2:nrow(sub)) {
  X <- subset(sub, clock <= i)
  V <- var(X$flu)
  cat("variance at clock ", i, " = ", V, "\n", sep="")
}
# variance with multiple numbers
sub <- subset(my.data, targ == 'A')
plot(sub$flu ~ sub$clock)
abline(lm(sub$flu ~ sub$clock))
for (i in 2:max(sub$clock)) {
  X <- subset(sub, clock <= i)
  V <- var(X$flu)
  cat("variance at clock ", i, " = ", V, "\n", sep="")
}

the results for the individual numbers are:
variance at clock 2 = 2e-06
variance at clock 3 = 4e-06
variance at clock 4 = 1.87e-05
variance at clock 5 = 2.38e-05

while the results for the multiple numbers are:
variance at clock 2 = 2.026667e-05
variance at clock 3 = 1.91e-05
variance at clock 4 = 2.026515e-05
variance at clock 5 = 1.995238e-05

shall I accept these latter values?
Thanks

On Thu, Nov 12, 2015 at 10:59 AM, John Kane  wrote:
> I still don't understand what you are doing. I think we need to see your 
> actual data and the code your are using.  If S.Ellison's post has not shown 
> up it is below my signature.
>
> Have a look at 
> http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
>  and/or http://adv-r.had.co.nz/Reproducibility.html for suggestions on how to 
> pose a question here. In particular data should be supplied in dput() format 
> as it gives us a copy of exactly how the data is formatted on your machine.
>
>
> John Kane
> Kingston ON Canada
>
> ## ===
>> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Luigi
>> Marongiu
>> if I have a sample set of the following numbers x1=0.09, x2=0.94, x3=0.48,
>> x4=0.74, x5=0.04 I can calculate the variance easily.
> Not without concatenating them into a vector, you can't. You need them in a 
> vector, as in
> var( c(x1, x2, x3, x4, x5) )
>
>> But if each x is actually a subset of multiple values, what would be the 
>> formula
>> to calculate the variance? and it is possible to implement such mathematical
>> function in R?
> This is what R wants anyway, so the function you are looking for is var()
>
>> For instance if I have the following: x1=(0.77, 0.22, 0.44), x2=(0.26, 0.89, 
>> 0.58),
>> x3=(0.20, 0.25, 0.91), x4=(0.06, 0.13, 0.26) and x5=(0.65, 0.16, 0.72) how 
>> can i
>> calculate the variance for each x?
> var(x1)
> var(x2)
> 
>
> or, if you want to be a bit more slick about it and do it in one line
>
> lapply(list( x1, x2, x3, ...), var  )
>
> (or sapply() if you want a vector result)
>
> ## ===
>
>
>> -Original Message-
>> From: marongiu.lu...@gmail.com
>> Sent: Wed, 11 Nov 2015 23:20:26 +
>> To: jrkrid...@inbox.com
>> Subject: Re: [R] How to calculate variance on multiple numbers at once?
>>
>> Thank you for the reply. For clarification, let's say that I can
>> calculate the sum of variances of the individual x numbers in five
>> consecutive steps (although of course there are better
>> implementations) where each step the sum is incremented by (x -
>> mean)^2.
>> In the case I am handling, at each step i have to consider 3 values at
>> once and I don't know how to relate them neither with the mathematical
>> formula nor with the R implementation.
>> Besides I haven't seen Ellison's answer...
>> Best regards
>> L
>>
>> On Wed, Nov 11, 2015 at 1:04 PM, John Kane  wrote:
>>> I really don't understand what you are looking for but if S. Ellison's
>>> answer is not what you want what about this where your various x vectors
>>> are in a data frame
>>>
>>> ibrary(reshape2)
>>> library(plyr)
>>>
>>> dat1  <-  structure(list(x1 = c(0.77, 0.22, 0.44), x2 = c(0.26, 0.89,
>>> 0.58
>>> ), x3 = c(0.2, 0.25, 0.91), x4 = c(0.06, 0.13, 0.26), x5 = c(0.65,
>>> 0.16, 0.72)), .Names = c("x1", "x2", "x3", "x4", "x5"), row.names =
>>> c(NA,
>>> -3L), class = "data.frame")
>>>
>>> m1  <-   melt(dat1)
>>>
>>> ddply(m1, .(variable), summarize, variance = 

Re: [R] *.rpt data

2015-11-12 Thread Sarah Goslee
What is "rpt data"? What source produced it? Where did you get it? Is it
associated with particular software? Is it ascii or binary?

Sarah

On Thursday, November 12, 2015, Mangalani Peter Makananisa <
pmakanan...@sars.gov.za> wrote:

> Hi,
>
> Could you please assist, how do I load the rpt data into R without
> converting it first to csv?
>
> Kind regards
> Peter
>
> Please Note: This email and its contents are subject to our email legal
> notice which can be viewed at
> http://www.sars.gov.za/Pages/Email-disclaimer.aspx
> [[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.
>


-- 
Sarah Goslee
http://www.stringpage.com
http://www.sarahgoslee.com
http://www.functionaldiversity.org

[[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] *.rpt data

2015-11-12 Thread David L Carlson
Another possibility for .rpt files from file-extensions.org:

"The rpt file extension is frequently used for various reports - output files 
of programs, often used for further analyze. Probably the most common type of 
RPT format is the one exported by Crystal Reports.

Crystal Reports is a business intelligence program for generating reports from 
a  wide range of data sources. Many applications (including Microsoft Visual 
Studio) bundled Crystal Reports as a general tool for reporting.

Other programs might also use rpt file extension for their reports, but it is 
mostly not always Crystal Reports format, unless the program is using the same 
reporting engine."

If it is a Crystal Reports file, the portion needed would likely have to be 
converted to .csv unless 


-
David L Carlson
Department of Anthropology
Texas A University
College Station, TX 77840-4352


-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of John McKown
Sent: Thursday, November 12, 2015 8:26 AM
To: r-help
Subject: Re: [R] *.rpt data

On Thu, Nov 12, 2015 at 7:52 AM, PIKAL Petr  wrote:

> Hi
>
> If it is really "like" csv data you can import it by
>
> read.csv...
>
> or you can use any other read.* function.
>
> Did you try it? If yes, what was the result?
> If not, why not?
>
> Cheers
> Petr
>

​Purely as a guess, ".rpt" really seems to be short for "report". Which I
would guess indicates that this is some sort of file which was originally
physically printed to be read by a human. So I would _guess_ that perhaps
it is column oriented and might be readable using read.fwf() .Or course, it
if really is a "report" there are those irritating page headers & footers,
perhaps along with a summary at the end which would need to be ignored. The
OP really needs to cut'n'paste (NO HTML PLEASE!) about 10 lines for us to
all "eyeball".​


-- 

Schrodinger's backup: The condition of any backup is unknown until a
restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! <><
John McKown

[[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] mlogit.optim start values problem

2015-11-12 Thread Jim Lemon
Hi Alaa,
>From the code you sent, I think that the error may be in one or more lines
preceding the call to mlogit.optim. The "+" prompt means that the R
interpreter thinks there is more to come, and when you added a right brace
("}"), it probably tried to interpret everything back to the last left
brace ("{"). Can you show us the preceding lines?

Jim


On Fri, Nov 13, 2015 at 8:06 AM, Alaa Sindi  wrote:

> Hello All,
>
> I received the following message and I think it is regarding start values
> or the method.
>
> semsem = mlogit.optim ( LL=LL*Prob[i,1] , start = c(1,1,1), method =
> c("bfgs"), iterlim = 2000, tol = 1E-05, ftol = 1e-08, steptol = 1e-10,
> print.level = 2)
> +
> + }
>
> Error in as.name(f[[2]]) :
>   'pairlist' object cannot be coerced to type ‘symbol'
>
> Do you have an idea how to fix this?
>
> Thanks in advance
>
> __
> 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] Una ayudita

2015-11-12 Thread Francisco Rodriguez Sanchez

Hola Heber,

Sin dudar, el libro de Hadley Wickham: http://r-pkgs.had.co.nz/ (acceso 
gratis online)


Suerte

Paco

El 12/11/2015 a las 18:11, heber sarmiento via R-help-es escribió:

Quisiera saber si alguien me puede ayudar con documentación o el lugar donde 
encontrarla, relacionada con la elaboración de paquetes en R, tengo algunos 
script programados y quiero convertirlos en paquetes; he leído el manual para 
hacer extensiones pero quiero algo más sintético y practico,
Agradezco cualquier colaboración al respecto
Heber
[[alternative HTML version deleted]]

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


--
Dr Francisco Rodriguez-Sanchez
Integrative Ecology Group
Estacion Biologica de Doñana - CSIC
Avda. Americo Vespucio s/n
41092 Sevilla (Spain)
http://bit.ly/frod_san

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


Re: [R] recursive partitioning in R

2015-11-12 Thread ACD
Dear Terry,

Thanks for pointing me to your vignette.  I can't say that I fully 
understand it however.  I'd be grateful for your help with a couple of 
specific questions:

  * In my application, each potential split will be a function of the
outcome (y), as well as two other variables (p1 and p2). These will
need to be passed down the tree, as my data is the set of {y, p1,
p2, X}.  How would p1 and p2 be passed to the three functions that
you describe (init, eval, and split)?
  * What does the initialize function do exactly?  I see that it takes
as arguments (y), along with offsets, weights, and "parms", and
outputs y again, along with numresp, numy, and a string.  I guess
I'd understand what this function was doing if I understood what
contexts it was called in.  Why is it needed? What process needs
"numresp" and "numy", and why does it need them?  And where is
"sfun" getting its information from?  And what gets done with the
string that gets outputted from it?
  * The evaluation function makes more sense to me at present.  It takes
y, along with weights and parameters, and gives back the deviance,
which is how different potential splits are evaluated.  The label is
passed along to something (what is it passed to?) so that the mean
of y in that partition can be known.
  o If it wanted to define a different evaluation function rss =
f(y, p1,p2), using only data from within a particular node,
would p1 and p2 be components of the "parms" object?  Is "parms"
a list?
  * The splitting function makes the most sense of all to me -- the
arguments are data (presumably only within-node data?), "parms"
contains my p1 and p2 parameters (I still want to know if "parms" is
a list or what), and outputs a goodness of fit measure, and a direction.
  o What  is the point of the direction?  Is not a split x?
  o If each splitting function evaluates goodness, what is the
deviance in the eval function doing?

I appreciate your patience with my questions.  I'm sure that some of 
them will become painfully obvious once I'm able to share your perspective.

Best,
Andrew


On 11/12/2015 07:44 AM, Therneau, Terry M., Ph.D. wrote:
> Look at the rpart vignette "User written split functions".  The code 
> allows you to add your own splitting method to the code (in R, no C 
> required).  This has proven to be very useful for trying out new ideas.
>
> The second piece would be to do your own cross-validation.  That is, 
> turn off the built in cross-validation using the xval=0 option, then 
> explicitly do the cross-validation yourself.  Fit a new tree to some 
> chosen subset of data, using your split rule of course, and then use 
> predict() to get predicted values for the remaining observations. 
> Again, this is all in R, and you can explicitly control your in or out 
> of bag subsets.
> The xpred.rpart function may be useful to automate some of the steps.
>
> If you look up rpart on CRAN, you will see a link to the package 
> source.  If you were to read the C source code you will discover that 
> 95% is boring bookkeeping of what observations are in what part(s) of 
> the tree, sorting the data, tracking missing values, etc.  If you ever 
> do want to write your own code you are more than welcome to build off 
> this --- I wouldn't want to write that part again.
>
> Terry Therneau
>
> On 11/12/2015 05:00 AM, r-help-requ...@r-project.org wrote:
>> Dear List,
>>
>> I'd like to make a few modifications to the typical CART algorithm, and
>> I'd rather not code the whole thing from scratch.  Specifically I want
>> to use different in-sample and out-of-sample fit criteria in the split
>> choosing and cross-validation stages.
>>
>> I see however that the code for CART in both the rpart and the tree
>> packages is written in C.
>>
>> Two questions:
>>
>>* Where is the C code?  It might be possible to get a C-fluent
>>  programmer to help me with this.
>>* Is there any code for CART that is written entirely in R?
>>
>> Thanks,
>> Andrew


[[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] problema as.numeric

2015-11-12 Thread Fernando Macedo
Otra cosa que se puede hacer con factors es usar 
as.numeric(as.character(x$factor))


Saludos

DMTV Fernando Macedo
Asistente del área Mejoramiento Genético
Facultad de Veterinaria - UdelarR - Uruguay
Tel: 26284291
Cel.: 098596947
ferm...@gmail.com

El 10/11/2015 a las 04:47 p.m., Javier Rubén Marcuzzi escribió:

Gracias Carlos

Javier Rubén Marcuzzi
Técnico en Industrias Lácteas
Veterinario



De: Carlos Ortega
Enviado: martes, 10 de noviembre de 2015 16:43
Para: Javier Rubén Marcuzzi
CC: r-help-es@r-project.org
Asunto: Re: [R-es] problema as.numeric


Hola,
b$Edad es un "factor".
En vez de convertir a "numeric", convierte a "vector"
b$Edad <- as.vector(b$Edad)
Saludos,
Carlos Ortega
www.qualityexcellence.es

El 10 de noviembre de 2015, 20:31, Javier Rubén Marcuzzi 
 escribió:
Estimados

Hay un problema, miren lo que sale en b$Edad, esos valores son correctos, pero 
luego realizo str$Edad, aparecen 24, 24, 24, 5 …. , convierto a números con b$Edad 
<- as.numeric(b$Edad) y los valores son 24, 24, 25 … (valores que no son 
reales).

Es fácil, lo realice muchas veces pero ahora estoy confundido. ¿Alguna ayuda? 
Gracias


b$Edad

   [1] 5   5   5   0,5 0,5 5   5   2   9   9   9   9   9   9   9   9   9
  [18] 7   7   5   16  16  0,3 2   5   5   5   5   7   7   7   4   4   4
  [35] 4   13  5   5   5   0,3 0,3 0,3 6   6   7   10  10  10  3   0,9 0,9
  [52] 0,9 10  8   8   8   8   3   3   3   10  10  10  1   15  15  15  3
  [69] 3   2   2   8   8   11  11  11  0,1 0,1 0,1 0,1 3   12  10  10  10
  [86] 3   3   3   4   2   0,3 0,3 0,3 10  0,8 0,8 0,8 8   8   8   1   1
[103] 1   1   1   8   7   5   3   6   4   16  17  11  9   10
[120] 1   2   2   2   3   13  14  5   5   3   3   6   4   7   1,4 0,4
[137] 6   2   3   4   10  9   7   9   8   8   8   8   8   10  13  13  0,8
[154] 1,8 6   7   1   1   5   8   8   10  9   8   2   2   2   7   10  9
[171] 8   10  10  10  0,4 4   6   5   3   2   2   10  8   9   4   4   11
[188] 11  6   5   7   4   5   4   0,5 0,5 0,7 12  12  14  14
[205] 16  15  8   8   4   0,4 1,4 0,4 2,4 0,4 5   6   4   2   3   2   2
[222] 4   4   4   4   1   2   3   6   7   1   2   7   7
28 Levels:  0,1 0,3 0,4 0,5 0,7 0,8 0,9 1 1,4 1,8 10 11 12 13 14 15 ... 9

str(b$Edad)

  Factor w/ 28 levels "","0,1","0,3",..: 24 24 24 5 5 24 24 20 28 28 ...

b$Edad <- as.numeric(b$Edad)
str(b$Edad)

  num [1:234] 24 24 24 5 5 24 24 20 28 28 ...


Javier Rubén Marcuzzi
Técnico en Industrias Lácteas
Veterinario

 [[alternative HTML version deleted]]

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






---
El software de antivirus Avast ha analizado este correo electrónico en busca de 
virus.
https://www.avast.com/antivirus

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

Re: [R] Compute Regressions with R-Function

2015-11-12 Thread Nordlund, Dan (DSHS/RDA)
You may have additional scoping problems depending on where you various 
variables exist, but your Trend function syntax is incorrect. You need 
parentheses around your arguments to the lm call, and you left out the '~' in 
your formula.  In addition, don't fool yourself by your use of the names CO2 
and logTrop_Aerosol as the function arguments.  Those arguments don't refer to 
variables in the global environment.  Function parameters have local scope in 
the function.   

Trend <- function(x,CO2,logTrop_Aerosol) { lm(x ~  CO2  + logTrop_Aerosol)}


Dan

Daniel Nordlund, PhD
Research and Data Analysis Division
Services & Enterprise Support Administration
Washington State Department of Social and Health Services


-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Matthias Worni
Sent: Thursday, November 12, 2015 8:28 AM
To: r-help@r-project.org
Subject: [R] Compute Regressions with R-Function

Hello

I was trying to set up a function() that allows easely to calculate regressions 
for severel dependent variables with the same independent variables.

My function looked like this but was turned down by an error (Im quiet new to R 
Studio). So here is my solution:

b
CO2
logTrop_Aerosol
lm(b ~ CO2  + logTrop_Aerosol  )

Trend <- function(x,CO2,logTrop_Aerosol) { lm x   CO2  + logTrop_Aerosol}

b is a vector containing 400 values of heat content
CO2 also contains 400 values as well as logTropAerosol

my idea would be that I simply can replace x (heat content) by other vectors 
containing heat content.

The error I got was the following:

Error: unexpected symbol in "Trend <- function(x,y,z) { lm x"

Thanks a lot for the help!

Best Matthias

[[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] Compute Regressions with R-Function

2015-11-12 Thread Michael Dewey

In-line

On 12/11/2015 16:27, Matthias Worni wrote:

Hello

I was trying to set up a function() that allows easely to calculate
regressions for severel dependent variables with the same independent
variables.

My function looked like this but was turned down by an error (Im quiet new
to R Studio). So here is my solution:

b
CO2
logTrop_Aerosol
lm(b ~ CO2  + logTrop_Aerosol  )

Trend <- function(x,CO2,logTrop_Aerosol) { lm x   CO2  + logTrop_Aerosol}


Since you posted in HTML it is hard to be sure but I would have thought 
you have left out the parentheses and the ~ symbol.




b is a vector containing 400 values of heat content
CO2 also contains 400 values as well as logTropAerosol

my idea would be that I simply can replace x (heat content) by other
vectors containing heat content.

The error I got was the following:

Error: unexpected symbol in "Trend <- function(x,y,z) { lm x"

Thanks a lot for the help!

Best Matthias

[[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] Plot with pauses?

2015-11-12 Thread Greg Snow
Here is one option if you don't want to write the explicit for loop
(there is still a loop):

library(TeachingDemos)
v<-0:60
z<-3/5+4i/5
t<-z^(v/9)
tmpfun <- function(npoints) {
  plot( Re(t)[seq_len(npoints)], Im(t)[seq_len(npoints)],
xlab="Real", ylab="Imaginary", xlim=c(-1,1), ylim=c(-1,1),
asp=1)
}
tkexamp(
  tmpfun,
  list(npoints=list('animate',from=0,to=length(t), resolution=1, delay=500))
)



On Wed, Nov 11, 2015 at 10:30 PM, Judson  wrote:
> I'm trying to create a
> series of demos for students.
>
> It would be helpful
> if plotted data points
> could appear one by one
> with, say, half-second delays
> between points.
>
> For instance,
> code like this
>
> v<-0:60
> z<-3/5+4i/5
> t<-z^(v/9)
> plot(Re(t),Im(t))
>
> would be better if I
> could invoke some
> pausing between points
> so the student could see
> the progression of
> the process.  Many
> mathematical progressions
> might be more understandable
> if the viewer could see
> this happen over intervals
> of time.
>
> Naturally I'd like to
> avoid for loops if that's
> possible.
>
> I really don't know
> where to start my
> search.   Any suggestions?
>
> . judson blake
> [[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.



-- 
Gregory (Greg) L. Snow Ph.D.
538...@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] Compute Regressions with R-Function

2015-11-12 Thread Jeff Newmiller
Your email is severely damaged because you sent it using HTML format. Please 
adjust the settings in your email software to use only plain text when sending 
to this list so we can see what you see.

While you are at it you should read about making your examples reproducible 
[1]... it may seem like a pain but you are likely to get better assistance if 
you make the extra effort before pressing the send button.

(Also, RStudio is a fine way to use R, but many people here use the R 
interpreter just fine without it so ask all you like about R here but don't 
assume we are all looking at the same screen you are. If you find you need to 
refer to RStudio to ask your question then you may be going off-topic. Your 
current question seems on topic though.)

I don't see a problem with your approach such as I can guess where you are 
going with it, but your code is messed up and your error does not look like it 
goes with that code so I have no idea where your actual problem is.

[1] 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
---
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 November 12, 2015 8:27:58 AM PST, Matthias Worni  
wrote:
>Hello
>
>I was trying to set up a function() that allows easely to calculate
>regressions for severel dependent variables with the same independent
>variables.
>
>My function looked like this but was turned down by an error (Im quiet
>new
>to R Studio). So here is my solution:
>
>b
>CO2
>logTrop_Aerosol
>lm(b ~ CO2  + logTrop_Aerosol  )
>
>Trend <- function(x,CO2,logTrop_Aerosol) { lm x   CO2  +
>logTrop_Aerosol}
>
>b is a vector containing 400 values of heat content
>CO2 also contains 400 values as well as logTropAerosol
>
>my idea would be that I simply can replace x (heat content) by other
>vectors containing heat content.
>
>The error I got was the following:
>
>Error: unexpected symbol in "Trend <- function(x,y,z) { lm x"
>
>Thanks a lot for the help!
>
>Best Matthias
>
>   [[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-es] Una ayudita

2015-11-12 Thread heber sarmiento via R-help-es
Quisiera saber si alguien me puede ayudar con documentación o el lugar donde 
encontrarla, relacionada con la elaboración de paquetes en R, tengo algunos 
script programados y quiero convertirlos en paquetes; he leído el manual para 
hacer extensiones pero quiero algo más sintético y practico, 
Agradezco cualquier colaboración al respecto
Heber
[[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 R

2015-11-12 Thread Marco
Excerpts from Rolf Turner's message of 2015-11-06 00:34:06 -0200:
> 
> On 06/11/15 14:31, Jim Lemon wrote:
> 
> 
> 
> > The fundamental problem that has emerged in this discussion is that
> > you seem to be applying the method of post-modernist deconstruction
> > to programming in R. I see no future in this enterprise.
> 
> 
> 
> *Gotta* be a fortune!!!
> 
> cheers,
> 
> Rolf
> 

Jim++
Rolf++

must be.

-- 
Marco Arthur @ (M)arco Creatives

__
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] replace NA's with row means for specific columns

2015-11-12 Thread Marco
Excerpts from Zahra via R-help's message of 2015-11-02 17:49:01 -0200:
> Hi there,
> 
> I am looking for some help replacing missing values in R with the row mean. 
> This is survey data and I am trying to impute values for missing variables in 
> each set of questions separately using the mean of the scores for the other 
> questions within that set. 
> 
> I have a dataset that looks like this
> 
> ID  A1A2A3  B1 B2 B3 C1   C2   C3C4
> b4   5  NA  2   NA  4  5  1   
>  3  NA
> c4   5  1NA  34  5  1 
>3  2
> d   NA 5  11NA  4  5  1   
>  3  2
> e4   5  45   NA  4   5  1 
>3  2
> 
> 
> I want to replace any NA's in columns A1:A3 with the row mean for those 
> columns only. So for ID=b, I want the NA in A3[ID=b] to be (4+5)/2 which is 
> the average of the values in A1 and A2 for that row. 
> Same thing for columns B1:B3 - I want the NA in B2[ID=b] to be the mean of 
> the values of B1 and B3 in row ID=b so that B2[ID=b] becomes 3 which is 
> (2+4)/2. And same in C1:C4, I want C4[ID=b] to become (5+1+3)/3 which is the 
> mean of C1:C3. 
> 
> Then I want to go to row ID=c and do the same thing and so on.
> 
> Can anybody help me do this? I have tried using rowMeans and subsetting but 
> can't figure out the right code to do it. 
> 
> Thanks so much.
> Zahra
> 
use 

is.na(df[ which(df$ID) == 'b']) <- fmean(...), where fmean:

Depends on column selection (Axx, Byy, etc..) and the row id itself (so 
consider pass
the left hand of assignment entirely). I would use:

fmean <- function(row, col_selection) { # homework for you here }

Best Regards,

-- 
Marco Arthur @ (M)arco Creatives

__
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] Quotes

2015-11-12 Thread Daniel Wiegert
Thank you. This was helpful. I'll try it. 

Daniel Wiegert 

> On Nov 12, 2015, at 1:11 AM, Jim Lemon  wrote:
> 
> Hi Daniel,
> As David said, these problems are almost always due to fancy quotes. If you 
> want plain old ASCII 34 (double) or 39 (single) quotes, try using Notepad for 
> your editing rather than Word.
> 
> Jim
> 
> 
>> On Thu, Nov 12, 2015 at 5:02 PM, David Winsemius  
>> wrote:
>> 
>> > On Nov 11, 2015, at 6:54 PM, Daniel Wiegert  wrote:
>> >
>> > Hello, I am trying to use a code which requires quotes around each of 
>> > about 1000 entries. When I did this
>> 
>> The use of pronouns in place of code is a major cause of ambiguity. What was 
>> … “this”?
>> 
>> 
>> > in Microsoft programs, R rejected every quote.
>> 
>> Again. the phrase "R rejected” is completely ambiguous. Did you see an error 
>> message after you did . If so, please offer up for examination 
>> both the  and the error message.
>> 
>> 
>> > I converted the font to courier new size 10 true type (the R default). No 
>> > luck. I had to find a sample code and copy the quotes from that 2000 times 
>> > for R to accept them, or type them in manually in R.
>> 
>> Word typically uses smart quotes rather than either the single-quote or 
>> double-quotes. You can change this behavior in Word by changing the 
>> preferences. But you really should not be using Word for either data entry 
>> or for code.
>> 
>> >
>> > Is there anyway to make this easier? What font in Word/Excel etc. does R 
>> > prefer and will function using quotes? Commas, letters, numbers, all work, 
>> > just the full double quotes won't work.
>> 
>> As above. The “quotes” that Word uses are not shared by most codign 
>> platforms.
>> 
>> >
>> > Thank you,
>> >
>> > Daniel
>> > __
>> > 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.
>> 
>> David Winsemius
>> Alameda, CA, USA
>> 
>> __
>> 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] "haven" - read_spss: How to avoid extracting value labels instead of long labels?

2015-11-12 Thread Dimitri Liakhovitski
Hello!

I don't have an example file, but I think my question should be clear
without it.
I have an SPSS file. I read it in using 'haven':

library(haven)
spss1 <- read_spss("SPSS_Example.sav")

I created a function that extracts the long labels (in SPSS - "Label"):

fix_labels <- function(x, TextIfMissing) {
  val <- attr(x, "label")
  if (is.null(val)) TextIfMissing else val
}
longlabels <- sapply(spss1, fix_labels, TextIfMissing = "NO LABLE IN SPSS")

This function is supposed to create a vector of long labels and
usually it does, e.g.:

str(longlabels)
 Named chr [1:64] "Serial number" ...
 - attr(*, "names")= chr [1:64] "Respondent_Serial" "weight" "r7_1" "r7_2" ...

However, I just got an SPSS file with 92 columns and ran exactly the
same function on it. Now, I am getting not a vector, but a list

str(longlabels)
List of 92
 $ VEHRATED  : chr "VEHICLE RATED"
 $ RESPID: chr "RESPONDENT ID"
 $ RESPID8   : chr "8 DIGIT RESPONDENT NUMBER"

An observation about the structure of longlabels here: those columns
that do NOT have a long lable in SPSS but DO have Values (value
labels) - for them my function grabs their value labels, so that now
my long label is recorded as a numeric vector with names, e.g.:

 $ AWARE2: Named num [1:2] 1 2
  ..- attr(*, "names")= chr [1:2] "VERY/SOMEWHAT FAMILIAR" "NOT AT ALL FAMILIAR"

Question: How could I avoid the extraction of the Value Labels for the
columns that have no long labels?

Thank you very much!
-- 
Dimitri Liakhovitski

__
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] Compute Regressions with R-Function

2015-11-12 Thread Matthias Worni
Hello

I was trying to set up a function() that allows easely to calculate
regressions for severel dependent variables with the same independent
variables.

My function looked like this but was turned down by an error (Im quiet new
to R Studio). So here is my solution:

b
CO2
logTrop_Aerosol
lm(b ~ CO2  + logTrop_Aerosol  )

Trend <- function(x,CO2,logTrop_Aerosol) { lm x   CO2  + logTrop_Aerosol}

b is a vector containing 400 values of heat content
CO2 also contains 400 values as well as logTropAerosol

my idea would be that I simply can replace x (heat content) by other
vectors containing heat content.

The error I got was the following:

Error: unexpected symbol in "Trend <- function(x,y,z) { lm x"

Thanks a lot for the help!

Best Matthias

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