Re: [R-es] Combinatoria

2015-03-22 Thread Our Utopy
Ya me extrañaba a mi!
Mañana a primera hora miro todo lo que me comentas.
Ahora estoy con ecuaciones no lineales y ya veo que hay que cargar
librerias
Muchas gracias. Un saludo

El 23 de marzo de 2015, 0:08, Carlos Ortega c...@qualityexcellence.es
escribió:

 Hola,

 Por precisar un par de detalles:


- Con el paquete gtools se pueden generar:
- las variaciones, permutaciones, combinaciones, variaciones con
   repetición y combinaciones con repetición (mira el ejemplo adjunto con 
 las
   combinaciones con repetición).
   - Quedan sin cubrir las permutaciones con repetición.


- Y dentro del paquete base, sí que hay formas de calcular algunas
cosas de combinatoria. Mira la función choose() para el cálculo de las
combinaciones. En el ejemplo de la función incluso aparece una forma de
generar el triángulo de Pascal.

 #- Ejemplo de Combinaciones con repetición (gtools) -

  x - c('rojo', 'azul', 'verde')
  # Combinaciones sin repetición
  combinations(n=3, r=2, v=x, repeats=FALSE)
  [,1]   [,2]
 [1,] azul rojo
 [2,] azul verde
 [3,] rojo verde
  # Combinaciones con repetición
  combinations(n=3, r=2, v=x, repeats=TRUE)
  [,1][,2]
 [1,] azul  azul
 [2,] azul  rojo
 [3,] azul  verde
 [4,] rojo  rojo
 [5,] rojo  verde
 [6,] verde verde

 #---

 Saludos,
 Carlos Ortega
 www.qualityexcellence.es

 El 22 de marzo de 2015, 22:50, Our Utopy ourut...@gmail.com escribió:

 Hola amigos, muchas gracias por vuestra ayuda.

 Entonces veo que mi sorpresa era legítima. Por todos vuestros mails la
 conclusión es que:

- En el módulo base de R no incluye combinatoria elemental, ni siquiera
el número combinatorio Cm,n hay que cargar el paquete *combinat*
- Y para las variaciones con repetición el paquete* gtools*
- Y aún así no tenemos ni las combinaciones ni las permutaciones, ambas
con repetición.


 Pues tendremos que ponernos a ello ¿no creéis? y hacer un paquete que lo
 resuelva y que genere incluso un triángulo de Pascal y otras cuestiones
 del
 binomio de Newton.
 Ya sé que es matemática elemental pero repito que estoy sorprendido por
 este hecho y más porque estas *Técnicas de conteo* son imprescindibles
 para
 el cálculo básico de probabilidades.

 Seguimos en la lucha. Un saludo


 El 22 de marzo de 2015, 19:32, Francisco Rodríguez fjr...@hotmail.com
 escribió:

  Carlos, creo que el ejemplo que mandas se refiere a las Variaciones con
  Repetición de 3 elementos tomados de 3 en 3 y cuyo número asciende a 27
 
  En las Permutaciones con repetición con las observaciones se forman
 grupos
  disjuntos cuya suma de cardinales es el número total, así pues puede
  hablarse de Permutaciones con Repetición de 10 elementos tomados de 5
 en 5,
  2 en 2 y de 3 en 3, en este caso, el número de combinaciones que sale
  seria: PR5;3,2,3 = 10!/(5!·2!·3!)
 
  Este caso es el que digo que seria mas dificil de preparar y quizas si
  requiere algo de programacion, porque el numero de grupos es variable,
 pero
  a lo mejor en lo que mandas se puede introducir algun tipo de vector, en
  todo caso lo miro mañana
 
 
  Un saludo
 
  --
  Date: Sun, 22 Mar 2015 13:22:36 +0100
  Subject: Re: [R-es] Combinatoria
  From: c...@qualityexcellence.es
  To: fjr...@hotmail.com
  CC: ourut...@gmail.com; r-help-es@r-project.org
 
 
  Sí, también...
  Para las permutaciones, n=r.
  Y con el parámetro repeats.allowed controlas si son con o sin
 repetción:
 
  #--
   #Permutaciones *con repetición*

   permutations(n=3, r=3, v=x, repeats.allowed=TRUE)
[,1][,2][,3]
   [1,] azul  azul  azul
   [2,] azul  azul  rojo
   [3,] azul  azul  verde
   [4,] azul  rojo  azul
   [5,] azul  rojo  rojo
   [6,] azul  rojo  verde
   [7,] azul  verde azul
   [8,] azul  verde rojo
   [9,] azul  verde verde
  [10,] rojo  azul  azul
  [11,] rojo  azul  rojo
  [12,] rojo  azul  verde
  [13,] rojo  rojo  azul
  [14,] rojo  rojo  rojo
  [15,] rojo  rojo  verde
  [16,] rojo  verde azul
  [17,] rojo  verde rojo
  [18,] rojo  verde verde
  [19,] verde azul  azul
  [20,] verde azul  rojo
  [21,] verde azul  verde
  [22,] verde rojo  azul
  [23,] verde rojo  rojo
  [24,] verde rojo  verde
  [25,] verde verde azul
  [26,] verde verde rojo
  [27,] verde verde verde
   #Permutaciones *sin repetición*

   permutations(n=3, r=3, v=x, repeats.allowed=FALSE)
   [,1][,2][,3]
  [1,] azul  rojo  verde
  [2,] azul  verde rojo
  [3,] rojo  azul  verde
  [4,] rojo  verde azul
  [5,] verde azul  rojo
  [6,] verde rojo  azul
  #
 
 
  Saludos,
  Carlos Ortega
  www.qualityexcellence.es
 
 
  El 22 de marzo de 2015, 12:18, Francisco Rodríguez fjr...@hotmail.com
  escribió:
 
  Carlos y ya puestos ¿Las permutaciones con repetición, salen también de
  aquí?
 
  Un saludo y gracias
 
   Date: Sun, 22 Mar 2015 12:15:45 +0100
   From: 

Re: [R-es] Combinatoria

2015-03-22 Thread Francisco Rodríguez
Carlos y ya puestos �Las permutaciones con repetici�n, salen tambi�n de aqu�?
Un saludo y gracias

 Date: Sun, 22 Mar 2015 12:15:45 +0100
 From: c...@qualityexcellence.es
 To: ourut...@gmail.com
 CC: r-help-es@r-project.org
 Subject: Re: [R-es] Combinatoria
 
 Hola Miguel,
 
 S� se pueden obtener las variaciones con y sin repetici�n en R.
 Eso s� est�n un poco escondidas...
 
 Se pueden calcular de esta forma:
 
 #--
  #Cargar el paquete gtools
  library(gtools)
  #Definir el conjunto sobre el que se har� el c�lculo
  x - c('rojo', 'azul', 'verde')
  #Utilizar la funci�n permutations() modificando el valor de r y
  #modificando el par�metro repeats.allowed dependiendo si sequieren con
 o sin repetici�n
  permutations(n=3, r=2, v=x, repeats.allowed=FALSE)
  [,1][,2]
 [1,] azul  rojo
 [2,] azul  verde
 [3,] rojo  azul
 [4,] rojo  verde
 [5,] verde azul
 [6,] verde rojo
  permutations(n=3, r=2, v=x, repeats.allowed=TRUE)
   [,1][,2]
  [1,] azul  azul
  [2,] azul  rojo
  [3,] azul  verde
  [4,] rojo  azul
  [5,] rojo  rojo
  [6,] rojo  verde
  [7,] verde azul
  [8,] verde rojo
  [9,] verde verde
 #--
 
 
 Saludos,
 Carlos Ortega
 www.qualityexcellence.es
 
 
 El 22 de marzo de 2015, 9:02, Our Utopy ourut...@gmail.com escribi�:
 
  Hola de nuevo amigos, Gracias por vuestras respuestas. Un placer levantarme
  esta ma�ana y ver que alguien hab�a tratado de ayudarme. Espero en unas
  semanas poder tambi�n ser yo �til a quien lo necesite.
 
  Me explico de nuevo. Estoy aprendiendo y mi primera visi�n, antes del Data
  Mining y las redes neuronales a las que quiero llegar, es ir solucionando
  los problemas b�sicos adem�s de explicarles R a mis propios alumnos en
  lugar de Wiris (id�neo para secundaria) o Maxima.
 
  Mi problema es de combinatoria b�sica, quiero calcular Cm,n  Pn  Vm,n  y lo
  mismo con repetici�n. Son cosas muy b�sicas de secundaria que cualquier
  programa o calculadora de mano las resuelve. Supuse que R en su m�dulo
  b�sico o CORE las responder�a al igual que responde a logaritmos en
  cualquier base, determinantes e inversas de matrices.
 
  Pero no, hay que instalar paquetes adicionales.
 
  Buscando encontr� que el paquete *combinat* incluye dos de estas funciones
 
 - *combn(m,n)*
 - *permn(n)*
 - *e incluso mCn(m,n)*
 
  N es solo que haga el c�lculod e cuantas son sino que las escribe todas,
  por ejemplo
 
   combn(4,2)
   [,1] [,2] [,3] [,4] [,5] [,6]
  [1,]111223
  [2,]234344
 
   permn(3)
  [[1]]
  [1] 1 2 3
 
  [[2]]
  [1] 1 3 2
 
  [[3]]
  [1] 3 1 2
 
  [[4]]
  [1] 3 2 1
 
  [[5]]
  [1] 2 3 1
 
  [[6]]
  [1] 2 1 3
 
 
  Y mCn las calcula, sin escribirlas:
 
   nCm(4,2)
  [1] 6
 
  Pero me choc� que NO incluyese Variaciones con y sin repetici�n, y
  combinaciones y permutaciones con repetici�n. Tanto que me las calcule como
  que me las escriba. Al menos yo no las encuentro a pesar de ser una
  cuesti�n muy b�sica en combinatoria que ayuda a calcular probabilidades y
  claro, �es que R es un programa de Estad�stica!
 
  De ah� mi pregunta al grupo.
 
  Si tengo que hacerme mi propia librer�a, pues creo que en unos d�as ser�
  capaz de hacerlo. Ayer precisamente ya estuve leyendo sobre construirme mis
  propias funciones, pero es que me choca que no haya ninguna librer�a entre
  las 6200 del repositorio que ya lo incluya.
 
  Esa era mi pregunta.
 
  Gracias anticipadas.
 
  Miguel
 
 
 
 
 
 
 
 
 
 
 
  El 21 de marzo de 2015, 19:35, Francisco Rodr�guez fjr...@hotmail.com
  escribi�:
 
   En relaci�n con lo que comenta Carlos, por ejemplo para el caso de las
   Variaciones sin Repetici�n, puede ser instructivo
   ense�ar como se construye como por ejemplo:
  
  
   VsinR - function(m, n){
  
 return (factorial(m)/factorial(m-n))
   }
  
  
   VsinR(9,3)
  
   -
  
  
   Creo que con la funci�n factorial que viene por defecto en R puedes
   construir siguiendo este modelo r�pidadmente
   casi cualquier funci�n de las de bachillerato. Las VconR ser�an m elevado
   a n
  
   Quiz�s la �nica que merezca la pena construir es la de Permutaciones con
   Repetici�n porque la parte de repetici�n puede tener m�s variedad, voy a
   mirar si lo encuentro y si no una funci�n lo puede resolver.
   PR(m; n1, ..., nk) donde n1+...+nk = m y PR(m;n1, ...,nk) = m!/(n1!
   �...�nk!)
  
  
   Un saludo
  
  
  
  
Date: Sat, 21 Mar 2015 16:36:50 +0100
From: c...@datanalytics.com
To: ourut...@gmail.com
CC: r-help-es@r-project.org
Subject: Re: [R-es] Combinatoria
  
   
Hola, �qu� tal?
   
�Qu� quieres hacer, construir las
combinaciones/permutaciones/variaciones o calcular cu�ntas hay?
   
Es improbable que encuentres funciones que resuelvan exactamente un
problema espec�fico. Pero s� que podr�s, con no mucho esfuerzo,
extender lo que hay para atacar esos problemas.
   
Un saludo y suerte con R,
   
Carlos 

Re: [R-es] Combinatoria

2015-03-22 Thread Carlos Ortega
Hola Miguel,

Sí se pueden obtener las variaciones con y sin repetición en R.
Eso sí están un poco escondidas...

Se pueden calcular de esta forma:

#--
 #Cargar el paquete gtools
 library(gtools)
 #Definir el conjunto sobre el que se hará el cálculo
 x - c('rojo', 'azul', 'verde')
 #Utilizar la función permutations() modificando el valor de r y
 #modificando el parámetro repeats.allowed dependiendo si sequieren con
o sin repetición
 permutations(n=3, r=2, v=x, repeats.allowed=FALSE)
 [,1][,2]
[1,] azul  rojo
[2,] azul  verde
[3,] rojo  azul
[4,] rojo  verde
[5,] verde azul
[6,] verde rojo
 permutations(n=3, r=2, v=x, repeats.allowed=TRUE)
  [,1][,2]
 [1,] azul  azul
 [2,] azul  rojo
 [3,] azul  verde
 [4,] rojo  azul
 [5,] rojo  rojo
 [6,] rojo  verde
 [7,] verde azul
 [8,] verde rojo
 [9,] verde verde
#--


Saludos,
Carlos Ortega
www.qualityexcellence.es


El 22 de marzo de 2015, 9:02, Our Utopy ourut...@gmail.com escribió:

 Hola de nuevo amigos, Gracias por vuestras respuestas. Un placer levantarme
 esta mañana y ver que alguien había tratado de ayudarme. Espero en unas
 semanas poder también ser yo útil a quien lo necesite.

 Me explico de nuevo. Estoy aprendiendo y mi primera visión, antes del Data
 Mining y las redes neuronales a las que quiero llegar, es ir solucionando
 los problemas básicos además de explicarles R a mis propios alumnos en
 lugar de Wiris (idóneo para secundaria) o Maxima.

 Mi problema es de combinatoria básica, quiero calcular Cm,n  Pn  Vm,n  y lo
 mismo con repetición. Son cosas muy básicas de secundaria que cualquier
 programa o calculadora de mano las resuelve. Supuse que R en su módulo
 básico o CORE las respondería al igual que responde a logaritmos en
 cualquier base, determinantes e inversas de matrices.

 Pero no, hay que instalar paquetes adicionales.

 Buscando encontré que el paquete *combinat* incluye dos de estas funciones

- *combn(m,n)*
- *permn(n)*
- *e incluso mCn(m,n)*

 N es solo que haga el cálculod e cuantas son sino que las escribe todas,
 por ejemplo

  combn(4,2)
  [,1] [,2] [,3] [,4] [,5] [,6]
 [1,]111223
 [2,]234344

  permn(3)
 [[1]]
 [1] 1 2 3

 [[2]]
 [1] 1 3 2

 [[3]]
 [1] 3 1 2

 [[4]]
 [1] 3 2 1

 [[5]]
 [1] 2 3 1

 [[6]]
 [1] 2 1 3


 Y mCn las calcula, sin escribirlas:

  nCm(4,2)
 [1] 6

 Pero me chocó que NO incluyese Variaciones con y sin repetición, y
 combinaciones y permutaciones con repetición. Tanto que me las calcule como
 que me las escriba. Al menos yo no las encuentro a pesar de ser una
 cuestión muy básica en combinatoria que ayuda a calcular probabilidades y
 claro, ¡es que R es un programa de Estadística!

 De ahí mi pregunta al grupo.

 Si tengo que hacerme mi propia librería, pues creo que en unos días seré
 capaz de hacerlo. Ayer precisamente ya estuve leyendo sobre construirme mis
 propias funciones, pero es que me choca que no haya ninguna librería entre
 las 6200 del repositorio que ya lo incluya.

 Esa era mi pregunta.

 Gracias anticipadas.

 Miguel











 El 21 de marzo de 2015, 19:35, Francisco Rodríguez fjr...@hotmail.com
 escribió:

  En relación con lo que comenta Carlos, por ejemplo para el caso de las
  Variaciones sin Repetición, puede ser instructivo
  enseñar como se construye como por ejemplo:
 
 
  VsinR - function(m, n){
 
return (factorial(m)/factorial(m-n))
  }
 
 
  VsinR(9,3)
 
  -
 
 
  Creo que con la función factorial que viene por defecto en R puedes
  construir siguiendo este modelo rápidadmente
  casi cualquier función de las de bachillerato. Las VconR serían m elevado
  a n
 
  Quizás la única que merezca la pena construir es la de Permutaciones con
  Repetición porque la parte de repetición puede tener más variedad, voy a
  mirar si lo encuentro y si no una función lo puede resolver.
  PR(m; n1, ..., nk) donde n1+...+nk = m y PR(m;n1, ...,nk) = m!/(n1!
  ·...·nk!)
 
 
  Un saludo
 
 
 
 
   Date: Sat, 21 Mar 2015 16:36:50 +0100
   From: c...@datanalytics.com
   To: ourut...@gmail.com
   CC: r-help-es@r-project.org
   Subject: Re: [R-es] Combinatoria
 
  
   Hola, ¿qué tal?
  
   ¿Qué quieres hacer, construir las
   combinaciones/permutaciones/variaciones o calcular cuántas hay?
  
   Es improbable que encuentres funciones que resuelvan exactamente un
   problema específico. Pero sí que podrás, con no mucho esfuerzo,
   extender lo que hay para atacar esos problemas.
  
   Un saludo y suerte con R,
  
   Carlos J. Gil Bellosta
   http://www.datanalytics.com
  
   El día 21 de marzo de 2015, 8:39, Our Utopy ourut...@gmail.com
  escribió:
Hola buenos días, me presento, me llamo Miguel y 'soy de' y 'vivo en'
Galicia.
Soy profesor de secundaria (Bachillerato Adultos) y llevo 15 días
estudiando R a un buen ritmo, pero todavía me faltan miles de cosas.
   
He visto que R facilita, no solo el análisis de datos y que posee una

Re: [R-es] Combinatoria

2015-03-22 Thread Carlos Ortega
Sí, también...
Para las permutaciones, n=r.
Y con el parámetro repeats.allowed controlas si son con o sin repetción:

#--
 #Permutaciones *con repetición*
 permutations(n=3, r=3, v=x, repeats.allowed=TRUE)
  [,1][,2][,3]
 [1,] azul  azul  azul
 [2,] azul  azul  rojo
 [3,] azul  azul  verde
 [4,] azul  rojo  azul
 [5,] azul  rojo  rojo
 [6,] azul  rojo  verde
 [7,] azul  verde azul
 [8,] azul  verde rojo
 [9,] azul  verde verde
[10,] rojo  azul  azul
[11,] rojo  azul  rojo
[12,] rojo  azul  verde
[13,] rojo  rojo  azul
[14,] rojo  rojo  rojo
[15,] rojo  rojo  verde
[16,] rojo  verde azul
[17,] rojo  verde rojo
[18,] rojo  verde verde
[19,] verde azul  azul
[20,] verde azul  rojo
[21,] verde azul  verde
[22,] verde rojo  azul
[23,] verde rojo  rojo
[24,] verde rojo  verde
[25,] verde verde azul
[26,] verde verde rojo
[27,] verde verde verde
 #Permutaciones *sin repetición*
 permutations(n=3, r=3, v=x, repeats.allowed=FALSE)
 [,1][,2][,3]
[1,] azul  rojo  verde
[2,] azul  verde rojo
[3,] rojo  azul  verde
[4,] rojo  verde azul
[5,] verde azul  rojo
[6,] verde rojo  azul
#


Saludos,
Carlos Ortega
www.qualityexcellence.es


El 22 de marzo de 2015, 12:18, Francisco Rodríguez fjr...@hotmail.com
escribió:

 Carlos y ya puestos ¿Las permutaciones con repetición, salen también de
 aquí?

 Un saludo y gracias

  Date: Sun, 22 Mar 2015 12:15:45 +0100
  From: c...@qualityexcellence.es

  To: ourut...@gmail.com
  CC: r-help-es@r-project.org
  Subject: Re: [R-es] Combinatoria
 
  Hola Miguel,
 
  Sí se pueden obtener las variaciones con y sin repetición en R.
  Eso sí están un poco escondidas...
 
  Se pueden calcular de esta forma:
 
  #--
   #Cargar el paquete gtools
   library(gtools)
   #Definir el conjunto sobre el que se hará el cálculo
   x - c('rojo', 'azul', 'verde')
   #Utilizar la función permutations() modificando el valor de r y
   #modificando el parámetro repeats.allowed dependiendo si sequieren
 con
  o sin repetición
   permutations(n=3, r=2, v=x, repeats.allowed=FALSE)
  [,1] [,2]
  [1,] azul rojo
  [2,] azul verde
  [3,] rojo azul
  [4,] rojo verde
  [5,] verde azul
  [6,] verde rojo
   permutations(n=3, r=2, v=x, repeats.allowed=TRUE)
  [,1] [,2]
  [1,] azul azul
  [2,] azul rojo
  [3,] azul verde
  [4,] rojo azul
  [5,] rojo rojo
  [6,] rojo verde
  [7,] verde azul
  [8,] verde rojo
  [9,] verde verde
  #--
 
 
  Saludos,
  Carlos Ortega
  www.qualityexcellence.es
 
 
  El 22 de marzo de 2015, 9:02, Our Utopy ourut...@gmail.com escribió:
 
   Hola de nuevo amigos, Gracias por vuestras respuestas. Un placer
 levantarme
   esta mañana y ver que alguien había tratado de ayudarme. Espero en unas
   semanas poder también ser yo útil a quien lo necesite.
  
   Me explico de nuevo. Estoy aprendiendo y mi primera visión, antes del
 Data
   Mining y las redes neuronales a las que quiero llegar, es ir
 solucionando
   los problemas básicos además de explicarles R a mis propios alumnos en
   lugar de Wiris (idóneo para secundaria) o Maxima.
  
   Mi problema es de combinatoria básica, quiero calcular Cm,n Pn Vm,n y
 lo
   mismo con repetición. Son cosas muy básicas de secundaria que cualquier
   programa o calculadora de mano las resuelve. Supuse que R en su módulo
   básico o CORE las respondería al igual que responde a logaritmos en
   cualquier base, determinantes e inversas de matrices.
  
   Pero no, hay que instalar paquetes adicionales.
  
   Buscando encontré que el paquete *combinat* incluye dos de estas
 funciones
  
   - *combn(m,n)*
   - *permn(n)*
   - *e incluso mCn(m,n)*
  
   N es solo que haga el cálculod e cuantas son sino que las escribe
 todas,
   por ejemplo
  
combn(4,2)
   [,1] [,2] [,3] [,4] [,5] [,6]
   [1,] 1 1 1 2 2 3
   [2,] 2 3 4 3 4 4
  
permn(3)
   [[1]]
   [1] 1 2 3
  
   [[2]]
   [1] 1 3 2
  
   [[3]]
   [1] 3 1 2
  
   [[4]]
   [1] 3 2 1
  
   [[5]]
   [1] 2 3 1
  
   [[6]]
   [1] 2 1 3
  
  
   Y mCn las calcula, sin escribirlas:
  
nCm(4,2)
   [1] 6
  
   Pero me chocó que NO incluyese Variaciones con y sin repetición, y
   combinaciones y permutaciones con repetición. Tanto que me las calcule
 como
   que me las escriba. Al menos yo no las encuentro a pesar de ser una
   cuestión muy básica en combinatoria que ayuda a calcular
 probabilidades y
   claro, ¡es que R es un programa de Estadística!
  
   De ahí mi pregunta al grupo.
  
   Si tengo que hacerme mi propia librería, pues creo que en unos días
 seré
   capaz de hacerlo. Ayer precisamente ya estuve leyendo sobre
 construirme mis
   propias funciones, pero es que me choca que no haya ninguna librería
 entre
   las 6200 del repositorio que ya lo incluya.
  
   Esa era mi pregunta.
  
   Gracias anticipadas.
  
   Miguel
  
  
  
  
  
  
  
  
  
  
  
   El 21 de marzo de 2015, 19:35, Francisco Rodríguez fjr...@hotmail.com
 
   escribió:
  
En relación con lo que comenta Carlos, por 

Re: [R] Joining two datasets - recursive procedure?

2015-03-22 Thread Luca Meyer
Hi Bert, hello R-experts,

I am close to a solution but I still need one hint w.r.t. the following
procedure (available also from
https://www.dropbox.com/s/qhmpkkrejjkpbkx/sample_code.txt?dl=0)

rm(list=ls())

# this is (an extract of) the INPUT file I have:
f1 - structure(list(v1 = c(A, A, A, A, A, A, B, B, B,
B, B, B), v2 = c(A, B, C, A, B, C, A, B, C, A,
B, C), v3 = c(B, B, B, C, C, C, B, B, B, C, C,
C), v4 = c(18.18530, 3.43806,0.00273, 1.42917, 1.05786, 0.00042, 2.37232,
3.01835, 0, 1.13430, 0.92872, 0)), .Names = c(v1, v2, v3, v4),
class = data.frame, row.names = c(2L, 9L, 11L, 41L, 48L, 50L, 158L, 165L,
167L, 197L, 204L, 206L))

# this is the procedure that Bert suggested (slightly adjusted):
z - rnorm(nrow(f1)) ## or anything you want
z1 - round(with(f1,v4 + z -ave(z,v1,v2,FUN=mean)), digits=5)
aggregate(v4~v1*v2,f1,sum)
aggregate(z1~v1*v2,f1,sum)
aggregate(v4~v3,f1,sum)
aggregate(z1~v3,f1,sum)

My question to you is: how can I set z so that I can obtain specific values
for z1-v4 in the v3 aggregation?
In other words, how can I configure the procedure so that e.g. B=29 and
C=2.56723 after running the procedure:
aggregate(z1~v3,f1,sum)

Thank you,

Luca

PS: to avoid any doubts you might have about who I am the following is my
web page: http://lucameyer.wordpress.com/


2015-03-21 18:13 GMT+01:00 Bert Gunter gunter.ber...@gene.com:

 ... or cleaner:

 z1 - with(f1,v4 + z -ave(z,v1,v2,FUN=mean))


 Just for curiosity, was this homework? (in which case I should
 probably have not provided you an answer -- that is, assuming that I
 HAVE provided an answer).

 Cheers,
 Bert

 Bert Gunter
 Genentech Nonclinical Biostatistics
 (650) 467-7374

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




 On Sat, Mar 21, 2015 at 7:53 AM, Bert Gunter bgun...@gene.com wrote:
  z - rnorm(nrow(f1)) ## or anything you want
  z1 - f1$v4 + z - with(f1,ave(z,v1,v2,FUN=mean))
 
 
  aggregate(v4~v1,f1,sum)
  aggregate(z1~v1,f1,sum)
  aggregate(v4~v2,f1,sum)
  aggregate(z1~v2,f1,sum)
  aggregate(v4~v3,f1,sum)
  aggregate(z1~v3,f1,sum)
 
 
  Cheers,
  Bert
 
  Bert Gunter
  Genentech Nonclinical Biostatistics
  (650) 467-7374
 
  Data is not information. Information is not knowledge. And knowledge
  is certainly not wisdom.
  Clifford Stoll
 
 
 
 
  On Sat, Mar 21, 2015 at 6:49 AM, Luca Meyer lucam1...@gmail.com wrote:
  Hi Bert,
 
  Thank you for your message. I am looking into ave() and tapply() as you
  suggested but at the same time I have prepared a example of input and
 output
  files, just in case you or someone else would like to make an attempt to
  generate a code that goes from input to output.
 
  Please see below or download it from
  https://www.dropbox.com/s/qhmpkkrejjkpbkx/sample_code.txt?dl=0
 
  # this is (an extract of) the INPUT file I have:
  f1 - structure(list(v1 = c(A, A, A, A, A, A, B, B,
  B, B, B, B), v2 = c(A, B, C, A, B, C, A,
  B, C, A, B, C), v3 = c(B, B, B, C, C, C,
  B, B, B, C, C, C), v4 = c(18.18530, 3.43806,0.00273,
 1.42917,
  1.05786, 0.00042, 2.37232, 3.01835, 0, 1.13430, 0.92872,
  0)), .Names = c(v1, v2, v3, v4), class = data.frame,
 row.names =
  c(2L,
  9L, 11L, 41L, 48L, 50L, 158L, 165L, 167L, 197L, 204L, 206L))
 
  # this is (an extract of) the OUTPUT file I would like to obtain:
  f2 - structure(list(v1 = c(A, A, A, A, A, A, B, B,
  B, B, B, B), v2 = c(A, B, C, A, B, C, A,
  B, C, A, B, C), v3 = c(B, B, B, C, C, C,
  B, B, B, C, C, C), v4 = c(17.83529, 3.43806,0.00295,
 1.77918,
  1.05786, 0.0002, 2.37232, 3.01835, 0, 1.13430, 0.92872,
  0)), .Names = c(v1, v2, v3, v4), class = data.frame,
 row.names =
  c(2L,
  9L, 11L, 41L, 48L, 50L, 158L, 165L, 167L, 197L, 204L, 206L))
 
  # please notice that while the aggregated v4 on v3 has changed …
  aggregate(f1[,c(v4)],list(f1$v3),sum)
  aggregate(f2[,c(v4)],list(f2$v3),sum)
 
  # … the aggregated v4 over v1xv2 has remained unchanged:
  aggregate(f1[,c(v4)],list(f1$v1,f1$v2),sum)
  aggregate(f2[,c(v4)],list(f2$v1,f2$v2),sum)
 
  Thank you very much in advance for your assitance.
 
  Luca
 
  2015-03-21 13:18 GMT+01:00 Bert Gunter gunter.ber...@gene.com:
 
  1. Still not sure what you mean, but maybe look at ?ave and ?tapply,
  for which ave() is a wrapper.
 
  2. You still need to heed the rest of Jeff's advice.
 
  Cheers,
  Bert
 
  Bert Gunter
  Genentech Nonclinical Biostatistics
  (650) 467-7374
 
  Data is not information. Information is not knowledge. And knowledge
  is certainly not wisdom.
  Clifford Stoll
 
 
 
 
  On Sat, Mar 21, 2015 at 4:53 AM, Luca Meyer lucam1...@gmail.com
 wrote:
   Hi Jeff  other R-experts,
  
   Thank you for your note. I have tried myself to solve the issue
 without
   success.
  
   Following your suggestion, I am providing a sample of the dataset I
 am
   using below (also downloadble in plain text from
   https://www.dropbox.com/s/qhmpkkrejjkpbkx/sample_code.txt?dl=0):
  
   #this is an extract of the overall dataset (n=1200 cases)
   

[R] Why can't I access this type?

2015-03-22 Thread Yves S. Garret
Hi, I'm just learning my way around R.  I got a bunch of states and would
like to access to get all of the ones where it's cold.  But when I do the
following, I will get the following error:

 all.states - as.data.frame(state.x77)
 cold.states - all.states[all.states$Frost  150, c(Name, Frost)]
Error in `[.data.frame`(all.states, all.states$Frost  150, c(Name,  :
  undefined columns selected

I don't get it.  When I look at all.states, this is what I see:

 str(all.states)
'data.frame':   50 obs. of  8 variables:
 $ Population: num  3615 365 2212 2110 21198 ...
 $ Income: num  3624 6315 4530 3378 5114 ...
 $ Illiteracy: num  2.1 1.5 1.8 1.9 1.1 0.7 1.1 0.9 1.3 2 ...
 $ Life Exp  : num  69 69.3 70.5 70.7 71.7 ...
 $ Murder: num  15.1 11.3 7.8 10.1 10.3 6.8 3.1 6.2 10.7 13.9 ...
 $ HS Grad   : num  41.3 66.7 58.1 39.9 62.6 63.9 56 54.6 52.6 40.6 ...
 $ Frost : num  20 152 15 65 20 166 139 103 11 60 ...
 $ Area  : num  50708 566432 113417 51945 156361 ...

What am I messing up?

[[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] My R stopped working

2015-03-22 Thread adeela uaf
Hi,
I was downloading some shape files in R then I use the package lsmeans in R
but I received the message R for winfows GUI front end has stopped working
 . What I have to do to overcome this problem

[[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] Fwd: Joining two datasets - recursive procedure?

2015-03-22 Thread Luca Meyer
Sorry forgot to keep the rest of the group in the loop - Luca
-- Forwarded message --
From: Luca Meyer lucam1...@gmail.com
Date: 2015-03-22 16:27 GMT+01:00
Subject: Re: [R] Joining two datasets - recursive procedure?
To: Bert Gunter gunter.ber...@gene.com


Hi Bert,

That is exactly what I am trying to achieve. Please notice that negative v4
values are allowed. I have done a similar task in the past manually by
recursively alterating v4 distribution across v3 categories within fix each
v1v2 combination so I am quite positive it can be achieved but honestly I
took me forever to do it manually and since this is likely to be an
exercise I need to repeat from time to time I wish I could learn how to do
it programmatically

Thanks again for any further suggestion you might have,

Luca


2015-03-22 16:05 GMT+01:00 Bert Gunter gunter.ber...@gene.com:

 Oh, wait a minute ...

 You still want the marginals for the other columns to be as originally?

 If so, then this is impossible in general as the sum of all the values
 must be what they were originally and you cannot therefore choose your
 values for V3 arbitrarily.

 Or at least, that seems to be what you are trying to do.

 -- Bert

 Bert Gunter
 Genentech Nonclinical Biostatistics
 (650) 467-7374

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




 On Sun, Mar 22, 2015 at 7:55 AM, Bert Gunter bgun...@gene.com wrote:
  I would have thought that this is straightforward given my previous
 email...
 
  Just set z to what you want -- e,g, all B values to 29/number of B's,
  and all C values to 2.567/number of C's (etc. for more categories).
 
  A slick but sort of cheat way to do this programmatically -- in the
  sense that it relies on the implementation of factor() rather than its
  API -- is:
 
  y - f1$v3  ## to simplify the notation; could be done using with()
  z - (c(29,2.567)/table(y))[c(y)]
 
  Then proceed to z1 as I previously described
 
  -- Bert
 
 
  Bert Gunter
  Genentech Nonclinical Biostatistics
  (650) 467-7374
 
  Data is not information. Information is not knowledge. And knowledge
  is certainly not wisdom.
  Clifford Stoll
 
 
 
 
  On Sun, Mar 22, 2015 at 2:00 AM, Luca Meyer lucam1...@gmail.com wrote:
  Hi Bert, hello R-experts,
 
  I am close to a solution but I still need one hint w.r.t. the following
  procedure (available also from
  https://www.dropbox.com/s/qhmpkkrejjkpbkx/sample_code.txt?dl=0)
 
  rm(list=ls())
 
  # this is (an extract of) the INPUT file I have:
  f1 - structure(list(v1 = c(A, A, A, A, A, A, B, B, B,
  B, B, B), v2 = c(A, B, C, A, B, C, A, B, C, A,
  B, C), v3 = c(B, B, B, C, C, C, B, B, B, C, C,
  C), v4 = c(18.18530, 3.43806,0.00273, 1.42917, 1.05786, 0.00042,
 2.37232,
  3.01835, 0, 1.13430, 0.92872, 0)), .Names = c(v1, v2, v3, v4),
 class
  = data.frame, row.names = c(2L, 9L, 11L, 41L, 48L, 50L, 158L, 165L,
 167L,
  197L, 204L, 206L))
 
  # this is the procedure that Bert suggested (slightly adjusted):
  z - rnorm(nrow(f1)) ## or anything you want
  z1 - round(with(f1,v4 + z -ave(z,v1,v2,FUN=mean)), digits=5)
  aggregate(v4~v1*v2,f1,sum)
  aggregate(z1~v1*v2,f1,sum)
  aggregate(v4~v3,f1,sum)
  aggregate(z1~v3,f1,sum)
 
  My question to you is: how can I set z so that I can obtain specific
 values
  for z1-v4 in the v3 aggregation?
  In other words, how can I configure the procedure so that e.g. B=29 and
  C=2.56723 after running the procedure:
  aggregate(z1~v3,f1,sum)
 
  Thank you,
 
  Luca
 
  PS: to avoid any doubts you might have about who I am the following is
 my
  web page: http://lucameyer.wordpress.com/
 
 
  2015-03-21 18:13 GMT+01:00 Bert Gunter gunter.ber...@gene.com:
 
  ... or cleaner:
 
  z1 - with(f1,v4 + z -ave(z,v1,v2,FUN=mean))
 
 
  Just for curiosity, was this homework? (in which case I should
  probably have not provided you an answer -- that is, assuming that I
  HAVE provided an answer).
 
  Cheers,
  Bert
 
  Bert Gunter
  Genentech Nonclinical Biostatistics
  (650) 467-7374
 
  Data is not information. Information is not knowledge. And knowledge
  is certainly not wisdom.
  Clifford Stoll
 
 
 
 
  On Sat, Mar 21, 2015 at 7:53 AM, Bert Gunter bgun...@gene.com wrote:
   z - rnorm(nrow(f1)) ## or anything you want
   z1 - f1$v4 + z - with(f1,ave(z,v1,v2,FUN=mean))
  
  
   aggregate(v4~v1,f1,sum)
   aggregate(z1~v1,f1,sum)
   aggregate(v4~v2,f1,sum)
   aggregate(z1~v2,f1,sum)
   aggregate(v4~v3,f1,sum)
   aggregate(z1~v3,f1,sum)
  
  
   Cheers,
   Bert
  
   Bert Gunter
   Genentech Nonclinical Biostatistics
   (650) 467-7374
  
   Data is not information. Information is not knowledge. And knowledge
   is certainly not wisdom.
   Clifford Stoll
  
  
  
  
   On Sat, Mar 21, 2015 at 6:49 AM, Luca Meyer lucam1...@gmail.com
 wrote:
   Hi Bert,
  
   Thank you for your message. I am looking into ave() and tapply() as
 you
   suggested but at the same time I have prepared a example of input
 and
   output
  

Re: [R] My R stopped working

2015-03-22 Thread Jeff Newmiller
You could use a search engine to find other people's solutions to this problem. 
Or you could just try again.

Unfortunately, if you want help here, your explanation is simply too brief. The 
normal expectation here is that you provide a reproducible example. Since R 
works by accepting text commands, that means give us the sequence of commands 
you used starting from a freshly opened R session that lead to the problem. 
Also give us an abbreviated amount of data to work with. Please post using 
plain text email, since the HTML you used to post this question usually messes 
up the R code by the time it gets to us.
---
Jeff NewmillerThe .   .  Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

On March 22, 2015 2:11:29 AM PDT, adeela uaf adeela@gmail.com wrote:
Hi,
I was downloading some shape files in R then I use the package lsmeans
in R
but I received the message R for winfows GUI front end has stopped
working
 . What I have to do to overcome this problem

   [[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] Package build help - thanks

2015-03-22 Thread Glenn Schultz

Hello All,

I have finally addressed all the cmd issues with my package build bondlab.  I 
would like to thank everyone that took the time to answer my questions.  I have the 
following question:  Currently the package has a non-standard directory/folder structure. 
 The non-standard folders are listed below.  I use connections to open and close 
directories during an analysis run.  I don't think having these directories in the 
bondlab directory is a long term viable option as the number of mortgage and REMIC cusips 
is well over 2 million.  My question is two parts:

First part, what do you believe is the best way to store these objects as blobs 
(everything is serialized) in a database or in a folder structure residing on 
the local machine.
In the event I first start with a folder structure on a local machine.  Is it possible to 
instruct R to create the directory and move the examples to the appropriate folder?  For 
example, could I create a folder data and then move each of the below folders to data and 
on install move the data folders to say a bondlabdata folder?
Best Regards,
Glenn

Non Standard Folders are below
BondData - bond objects (S4) identified by cusip with structural information: 
coupon, payment dates, etc...
Groups - collateral group data: (S4) identifies the underlying collateral group 
of a mortgage REMIC
PrepaymentModel - S4 object which holds mortgage prepayment model tuning 
parameters
RatesData - holds swap rate curve history
RDME - REMIC Disclosure Month End (S4): updated REMIC information 
REMICData - REMIC structures (S4) 
Scenario - Interest rate scenarios (S4) for total return analysis
Schedules - structure elements (S4) for REMIC (PAC Schedules, etc)
Tranches - Tranches for REMIC structure tool (S4)
Waterfall - source - cash allocation rules for REMIC cash flow


__
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] Why can't I access this type?

2015-03-22 Thread Bert Gunter
Your data frame contains no column named Name .

Maybe what you want is

rownames(all.states)[all.state$Frost150]

However, what you clearly need to do is stop posting until you have
done your homework by spending some time with one of the many good R
tutorials that are out there (possibly Intro to R, which ships with R,
though it's getting a bit dated now). This appears to be a very basic
question. If you are going through a tutorial and got stuck here, then
note that row names are an attribute of the data frame, not a column
name of one of its columns. See ?rownames and the links therein for
more info.

Cheers,
Bert

Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

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




On Sun, Mar 22, 2015 at 7:39 AM, Yves S. Garret
yoursurrogate...@gmail.com wrote:
 Hi, I'm just learning my way around R.  I got a bunch of states and would
 like to access to get all of the ones where it's cold.  But when I do the
 following, I will get the following error:

 all.states - as.data.frame(state.x77)
 cold.states - all.states[all.states$Frost  150, c(Name, Frost)]
 Error in `[.data.frame`(all.states, all.states$Frost  150, c(Name,  :
   undefined columns selected

 I don't get it.  When I look at all.states, this is what I see:

 str(all.states)
 'data.frame':   50 obs. of  8 variables:
  $ Population: num  3615 365 2212 2110 21198 ...
  $ Income: num  3624 6315 4530 3378 5114 ...
  $ Illiteracy: num  2.1 1.5 1.8 1.9 1.1 0.7 1.1 0.9 1.3 2 ...
  $ Life Exp  : num  69 69.3 70.5 70.7 71.7 ...
  $ Murder: num  15.1 11.3 7.8 10.1 10.3 6.8 3.1 6.2 10.7 13.9 ...
  $ HS Grad   : num  41.3 66.7 58.1 39.9 62.6 63.9 56 54.6 52.6 40.6 ...
  $ Frost : num  20 152 15 65 20 166 139 103 11 60 ...
  $ Area  : num  50708 566432 113417 51945 156361 ...

 What am I messing up?

 [[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] My R stopped working

2015-03-22 Thread Bert Gunter
restart R.

-- Bert

Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

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




On Sun, Mar 22, 2015 at 2:11 AM, adeela uaf adeela@gmail.com wrote:
 Hi,
 I was downloading some shape files in R then I use the package lsmeans in R
 but I received the message R for winfows GUI front end has stopped working
  . What I have to do to overcome this problem

 [[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] Joining two datasets - recursive procedure?

2015-03-22 Thread Bert Gunter
I would have thought that this is straightforward given my previous email...

Just set z to what you want -- e,g, all B values to 29/number of B's,
and all C values to 2.567/number of C's (etc. for more categories).

A slick but sort of cheat way to do this programmatically -- in the
sense that it relies on the implementation of factor() rather than its
API -- is:

y - f1$v3  ## to simplify the notation; could be done using with()
z - (c(29,2.567)/table(y))[c(y)]

Then proceed to z1 as I previously described

-- Bert


Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

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




On Sun, Mar 22, 2015 at 2:00 AM, Luca Meyer lucam1...@gmail.com wrote:
 Hi Bert, hello R-experts,

 I am close to a solution but I still need one hint w.r.t. the following
 procedure (available also from
 https://www.dropbox.com/s/qhmpkkrejjkpbkx/sample_code.txt?dl=0)

 rm(list=ls())

 # this is (an extract of) the INPUT file I have:
 f1 - structure(list(v1 = c(A, A, A, A, A, A, B, B, B,
 B, B, B), v2 = c(A, B, C, A, B, C, A, B, C, A,
 B, C), v3 = c(B, B, B, C, C, C, B, B, B, C, C,
 C), v4 = c(18.18530, 3.43806,0.00273, 1.42917, 1.05786, 0.00042, 2.37232,
 3.01835, 0, 1.13430, 0.92872, 0)), .Names = c(v1, v2, v3, v4), class
 = data.frame, row.names = c(2L, 9L, 11L, 41L, 48L, 50L, 158L, 165L, 167L,
 197L, 204L, 206L))

 # this is the procedure that Bert suggested (slightly adjusted):
 z - rnorm(nrow(f1)) ## or anything you want
 z1 - round(with(f1,v4 + z -ave(z,v1,v2,FUN=mean)), digits=5)
 aggregate(v4~v1*v2,f1,sum)
 aggregate(z1~v1*v2,f1,sum)
 aggregate(v4~v3,f1,sum)
 aggregate(z1~v3,f1,sum)

 My question to you is: how can I set z so that I can obtain specific values
 for z1-v4 in the v3 aggregation?
 In other words, how can I configure the procedure so that e.g. B=29 and
 C=2.56723 after running the procedure:
 aggregate(z1~v3,f1,sum)

 Thank you,

 Luca

 PS: to avoid any doubts you might have about who I am the following is my
 web page: http://lucameyer.wordpress.com/


 2015-03-21 18:13 GMT+01:00 Bert Gunter gunter.ber...@gene.com:

 ... or cleaner:

 z1 - with(f1,v4 + z -ave(z,v1,v2,FUN=mean))


 Just for curiosity, was this homework? (in which case I should
 probably have not provided you an answer -- that is, assuming that I
 HAVE provided an answer).

 Cheers,
 Bert

 Bert Gunter
 Genentech Nonclinical Biostatistics
 (650) 467-7374

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




 On Sat, Mar 21, 2015 at 7:53 AM, Bert Gunter bgun...@gene.com wrote:
  z - rnorm(nrow(f1)) ## or anything you want
  z1 - f1$v4 + z - with(f1,ave(z,v1,v2,FUN=mean))
 
 
  aggregate(v4~v1,f1,sum)
  aggregate(z1~v1,f1,sum)
  aggregate(v4~v2,f1,sum)
  aggregate(z1~v2,f1,sum)
  aggregate(v4~v3,f1,sum)
  aggregate(z1~v3,f1,sum)
 
 
  Cheers,
  Bert
 
  Bert Gunter
  Genentech Nonclinical Biostatistics
  (650) 467-7374
 
  Data is not information. Information is not knowledge. And knowledge
  is certainly not wisdom.
  Clifford Stoll
 
 
 
 
  On Sat, Mar 21, 2015 at 6:49 AM, Luca Meyer lucam1...@gmail.com wrote:
  Hi Bert,
 
  Thank you for your message. I am looking into ave() and tapply() as you
  suggested but at the same time I have prepared a example of input and
  output
  files, just in case you or someone else would like to make an attempt
  to
  generate a code that goes from input to output.
 
  Please see below or download it from
  https://www.dropbox.com/s/qhmpkkrejjkpbkx/sample_code.txt?dl=0
 
  # this is (an extract of) the INPUT file I have:
  f1 - structure(list(v1 = c(A, A, A, A, A, A, B, B,
  B, B, B, B), v2 = c(A, B, C, A, B, C, A,
  B, C, A, B, C), v3 = c(B, B, B, C, C, C,
  B, B, B, C, C, C), v4 = c(18.18530, 3.43806,0.00273,
  1.42917,
  1.05786, 0.00042, 2.37232, 3.01835, 0, 1.13430, 0.92872,
  0)), .Names = c(v1, v2, v3, v4), class = data.frame,
  row.names =
  c(2L,
  9L, 11L, 41L, 48L, 50L, 158L, 165L, 167L, 197L, 204L, 206L))
 
  # this is (an extract of) the OUTPUT file I would like to obtain:
  f2 - structure(list(v1 = c(A, A, A, A, A, A, B, B,
  B, B, B, B), v2 = c(A, B, C, A, B, C, A,
  B, C, A, B, C), v3 = c(B, B, B, C, C, C,
  B, B, B, C, C, C), v4 = c(17.83529, 3.43806,0.00295,
  1.77918,
  1.05786, 0.0002, 2.37232, 3.01835, 0, 1.13430, 0.92872,
  0)), .Names = c(v1, v2, v3, v4), class = data.frame,
  row.names =
  c(2L,
  9L, 11L, 41L, 48L, 50L, 158L, 165L, 167L, 197L, 204L, 206L))
 
  # please notice that while the aggregated v4 on v3 has changed …
  aggregate(f1[,c(v4)],list(f1$v3),sum)
  aggregate(f2[,c(v4)],list(f2$v3),sum)
 
  # … the aggregated v4 over v1xv2 has remained unchanged:
  aggregate(f1[,c(v4)],list(f1$v1,f1$v2),sum)
  aggregate(f2[,c(v4)],list(f2$v1,f2$v2),sum)
 
  Thank you very much in advance for your assitance.
 
  Luca
 
  2015-03-21 13:18 GMT+01:00 Bert Gunter gunter.ber...@gene.com:
 
  1. Still not sure what 

Re: [R] Joining two datasets - recursive procedure?

2015-03-22 Thread Bert Gunter
Oh, wait a minute ...

You still want the marginals for the other columns to be as originally?

If so, then this is impossible in general as the sum of all the values
must be what they were originally and you cannot therefore choose your
values for V3 arbitrarily.

Or at least, that seems to be what you are trying to do.

-- Bert

Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

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




On Sun, Mar 22, 2015 at 7:55 AM, Bert Gunter bgun...@gene.com wrote:
 I would have thought that this is straightforward given my previous email...

 Just set z to what you want -- e,g, all B values to 29/number of B's,
 and all C values to 2.567/number of C's (etc. for more categories).

 A slick but sort of cheat way to do this programmatically -- in the
 sense that it relies on the implementation of factor() rather than its
 API -- is:

 y - f1$v3  ## to simplify the notation; could be done using with()
 z - (c(29,2.567)/table(y))[c(y)]

 Then proceed to z1 as I previously described

 -- Bert


 Bert Gunter
 Genentech Nonclinical Biostatistics
 (650) 467-7374

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




 On Sun, Mar 22, 2015 at 2:00 AM, Luca Meyer lucam1...@gmail.com wrote:
 Hi Bert, hello R-experts,

 I am close to a solution but I still need one hint w.r.t. the following
 procedure (available also from
 https://www.dropbox.com/s/qhmpkkrejjkpbkx/sample_code.txt?dl=0)

 rm(list=ls())

 # this is (an extract of) the INPUT file I have:
 f1 - structure(list(v1 = c(A, A, A, A, A, A, B, B, B,
 B, B, B), v2 = c(A, B, C, A, B, C, A, B, C, A,
 B, C), v3 = c(B, B, B, C, C, C, B, B, B, C, C,
 C), v4 = c(18.18530, 3.43806,0.00273, 1.42917, 1.05786, 0.00042, 2.37232,
 3.01835, 0, 1.13430, 0.92872, 0)), .Names = c(v1, v2, v3, v4), class
 = data.frame, row.names = c(2L, 9L, 11L, 41L, 48L, 50L, 158L, 165L, 167L,
 197L, 204L, 206L))

 # this is the procedure that Bert suggested (slightly adjusted):
 z - rnorm(nrow(f1)) ## or anything you want
 z1 - round(with(f1,v4 + z -ave(z,v1,v2,FUN=mean)), digits=5)
 aggregate(v4~v1*v2,f1,sum)
 aggregate(z1~v1*v2,f1,sum)
 aggregate(v4~v3,f1,sum)
 aggregate(z1~v3,f1,sum)

 My question to you is: how can I set z so that I can obtain specific values
 for z1-v4 in the v3 aggregation?
 In other words, how can I configure the procedure so that e.g. B=29 and
 C=2.56723 after running the procedure:
 aggregate(z1~v3,f1,sum)

 Thank you,

 Luca

 PS: to avoid any doubts you might have about who I am the following is my
 web page: http://lucameyer.wordpress.com/


 2015-03-21 18:13 GMT+01:00 Bert Gunter gunter.ber...@gene.com:

 ... or cleaner:

 z1 - with(f1,v4 + z -ave(z,v1,v2,FUN=mean))


 Just for curiosity, was this homework? (in which case I should
 probably have not provided you an answer -- that is, assuming that I
 HAVE provided an answer).

 Cheers,
 Bert

 Bert Gunter
 Genentech Nonclinical Biostatistics
 (650) 467-7374

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




 On Sat, Mar 21, 2015 at 7:53 AM, Bert Gunter bgun...@gene.com wrote:
  z - rnorm(nrow(f1)) ## or anything you want
  z1 - f1$v4 + z - with(f1,ave(z,v1,v2,FUN=mean))
 
 
  aggregate(v4~v1,f1,sum)
  aggregate(z1~v1,f1,sum)
  aggregate(v4~v2,f1,sum)
  aggregate(z1~v2,f1,sum)
  aggregate(v4~v3,f1,sum)
  aggregate(z1~v3,f1,sum)
 
 
  Cheers,
  Bert
 
  Bert Gunter
  Genentech Nonclinical Biostatistics
  (650) 467-7374
 
  Data is not information. Information is not knowledge. And knowledge
  is certainly not wisdom.
  Clifford Stoll
 
 
 
 
  On Sat, Mar 21, 2015 at 6:49 AM, Luca Meyer lucam1...@gmail.com wrote:
  Hi Bert,
 
  Thank you for your message. I am looking into ave() and tapply() as you
  suggested but at the same time I have prepared a example of input and
  output
  files, just in case you or someone else would like to make an attempt
  to
  generate a code that goes from input to output.
 
  Please see below or download it from
  https://www.dropbox.com/s/qhmpkkrejjkpbkx/sample_code.txt?dl=0
 
  # this is (an extract of) the INPUT file I have:
  f1 - structure(list(v1 = c(A, A, A, A, A, A, B, B,
  B, B, B, B), v2 = c(A, B, C, A, B, C, A,
  B, C, A, B, C), v3 = c(B, B, B, C, C, C,
  B, B, B, C, C, C), v4 = c(18.18530, 3.43806,0.00273,
  1.42917,
  1.05786, 0.00042, 2.37232, 3.01835, 0, 1.13430, 0.92872,
  0)), .Names = c(v1, v2, v3, v4), class = data.frame,
  row.names =
  c(2L,
  9L, 11L, 41L, 48L, 50L, 158L, 165L, 167L, 197L, 204L, 206L))
 
  # this is (an extract of) the OUTPUT file I would like to obtain:
  f2 - structure(list(v1 = c(A, A, A, A, A, A, B, B,
  B, B, B, B), v2 = c(A, B, C, A, B, C, A,
  B, C, A, B, C), v3 = c(B, B, B, C, C, C,
  B, B, B, C, C, C), v4 = c(17.83529, 3.43806,0.00295,
  1.77918,
  1.05786, 0.0002, 2.37232, 3.01835, 0, 1.13430, 0.92872,
  

Re: [R] Joining two datasets - recursive procedure?

2015-03-22 Thread Luca Meyer
Hi Bert,

Thanks again for your assistance.

Unfortunately when I apply the additional code you suggest I get B=40.23326
 C=-8.66603 and not  B=29  C=2.56723. Any idea why that might be
happening?

Please see below or on
https://www.dropbox.com/s/qhmpkkrejjkpbkx/sample_code.txt?dl=0 the code I
am running:

rm(list=ls())

# this is (an extract of) the INPUT file I have:
f1 - structure(list(v1 = c(A, A, A, A, A, A, B, B,
B, B, B, B), v2 = c(A, B, C, A, B, C, A,
B, C, A, B, C), v3 = c(B, B, B, C, C, C,
B, B, B, C, C, C), v4 = c(18.18530, 3.43806,0.00273, 1.42917,
1.05786, 0.00042, 2.37232, 3.01835, 0, 1.13430, 0.92872,
0)), .Names = c(v1, v2, v3, v4), class = data.frame, row.names =
c(2L,
9L, 11L, 41L, 48L, 50L, 158L, 165L, 167L, 197L, 204L, 206L))

# this is the procedure that Bert suggested (slightly adjusted):

y - f1$v3  ## to simplify the notation; could be done using with()
z - (c(29,2.567)/table(y))[c(y)]
# z - rnorm(nrow(f1)) ## or anything you want
z1 - round(with(f1,v4 + z -ave(z,v1,v2,FUN=mean)), digits=5)
aggregate(v4~v1*v2,f1,sum)
aggregate(z1~v1*v2,f1,sum)
aggregate(v4~v3,f1,sum)
aggregate(z1~v3,f1,sum)

Thanks again,

Luca


2015-03-22 15:55 GMT+01:00 Bert Gunter gunter.ber...@gene.com:

 I would have thought that this is straightforward given my previous
 email...

 Just set z to what you want -- e,g, all B values to 29/number of B's,
 and all C values to 2.567/number of C's (etc. for more categories).

 A slick but sort of cheat way to do this programmatically -- in the
 sense that it relies on the implementation of factor() rather than its
 API -- is:

 y - f1$v3  ## to simplify the notation; could be done using with()
 z - (c(29,2.567)/table(y))[c(y)]

 Then proceed to z1 as I previously described

 -- Bert


 Bert Gunter
 Genentech Nonclinical Biostatistics
 (650) 467-7374

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




 On Sun, Mar 22, 2015 at 2:00 AM, Luca Meyer lucam1...@gmail.com wrote:
  Hi Bert, hello R-experts,
 
  I am close to a solution but I still need one hint w.r.t. the following
  procedure (available also from
  https://www.dropbox.com/s/qhmpkkrejjkpbkx/sample_code.txt?dl=0)
 
  rm(list=ls())
 
  # this is (an extract of) the INPUT file I have:
  f1 - structure(list(v1 = c(A, A, A, A, A, A, B, B, B,
  B, B, B), v2 = c(A, B, C, A, B, C, A, B, C, A,
  B, C), v3 = c(B, B, B, C, C, C, B, B, B, C, C,
  C), v4 = c(18.18530, 3.43806,0.00273, 1.42917, 1.05786, 0.00042,
 2.37232,
  3.01835, 0, 1.13430, 0.92872, 0)), .Names = c(v1, v2, v3, v4),
 class
  = data.frame, row.names = c(2L, 9L, 11L, 41L, 48L, 50L, 158L, 165L,
 167L,
  197L, 204L, 206L))
 
  # this is the procedure that Bert suggested (slightly adjusted):
  z - rnorm(nrow(f1)) ## or anything you want
  z1 - round(with(f1,v4 + z -ave(z,v1,v2,FUN=mean)), digits=5)
  aggregate(v4~v1*v2,f1,sum)
  aggregate(z1~v1*v2,f1,sum)
  aggregate(v4~v3,f1,sum)
  aggregate(z1~v3,f1,sum)
 
  My question to you is: how can I set z so that I can obtain specific
 values
  for z1-v4 in the v3 aggregation?
  In other words, how can I configure the procedure so that e.g. B=29 and
  C=2.56723 after running the procedure:
  aggregate(z1~v3,f1,sum)
 
  Thank you,
 
  Luca
 
  PS: to avoid any doubts you might have about who I am the following is my
  web page: http://lucameyer.wordpress.com/
 
 
  2015-03-21 18:13 GMT+01:00 Bert Gunter gunter.ber...@gene.com:
 
  ... or cleaner:
 
  z1 - with(f1,v4 + z -ave(z,v1,v2,FUN=mean))
 
 
  Just for curiosity, was this homework? (in which case I should
  probably have not provided you an answer -- that is, assuming that I
  HAVE provided an answer).
 
  Cheers,
  Bert
 
  Bert Gunter
  Genentech Nonclinical Biostatistics
  (650) 467-7374
 
  Data is not information. Information is not knowledge. And knowledge
  is certainly not wisdom.
  Clifford Stoll
 
 
 
 
  On Sat, Mar 21, 2015 at 7:53 AM, Bert Gunter bgun...@gene.com wrote:
   z - rnorm(nrow(f1)) ## or anything you want
   z1 - f1$v4 + z - with(f1,ave(z,v1,v2,FUN=mean))
  
  
   aggregate(v4~v1,f1,sum)
   aggregate(z1~v1,f1,sum)
   aggregate(v4~v2,f1,sum)
   aggregate(z1~v2,f1,sum)
   aggregate(v4~v3,f1,sum)
   aggregate(z1~v3,f1,sum)
  
  
   Cheers,
   Bert
  
   Bert Gunter
   Genentech Nonclinical Biostatistics
   (650) 467-7374
  
   Data is not information. Information is not knowledge. And knowledge
   is certainly not wisdom.
   Clifford Stoll
  
  
  
  
   On Sat, Mar 21, 2015 at 6:49 AM, Luca Meyer lucam1...@gmail.com
 wrote:
   Hi Bert,
  
   Thank you for your message. I am looking into ave() and tapply() as
 you
   suggested but at the same time I have prepared a example of input and
   output
   files, just in case you or someone else would like to make an attempt
   to
   generate a code that goes from input to output.
  
   Please see below or download it from
   https://www.dropbox.com/s/qhmpkkrejjkpbkx/sample_code.txt?dl=0
  
   # this is (an extract of) the INPUT 

Re: [R] Why can't I access this type?

2015-03-22 Thread John Kane
Well, first off, you have no variable called Name.  You have lost the state 
names as they are rownames in the matrix state.x77 and not a variable.

Try this. It's ugly and I have no idea why I had to do a cbind() but it seems 
to work. Personally I find subset easier to read than the indexing approach.

state  -  rownames(state.x77)
all.states - as.data.frame(state.x77)
all.states  -  cbind(state, all.states) ### ?

coldstates  -   subset(all.states, all.states$Frost  50, 
select = c(state,Frost) )


John Kane
Kingston ON Canada


 -Original Message-
 From: yoursurrogate...@gmail.com
 Sent: Sun, 22 Mar 2015 10:39:03 -0400
 To: r-help@r-project.org
 Subject: [R] Why can't I access this type?
 
 Hi, I'm just learning my way around R.  I got a bunch of states and would
 like to access to get all of the ones where it's cold.  But when I do the
 following, I will get the following error:
 
 all.states - as.data.frame(state.x77)
 cold.states - all.states[all.states$Frost  150, c(Name, Frost)]
 Error in `[.data.frame`(all.states, all.states$Frost  150, c(Name,  :
   undefined columns selected
 
 I don't get it.  When I look at all.states, this is what I see:
 
 str(all.states)
 'data.frame':   50 obs. of  8 variables:
  $ Population: num  3615 365 2212 2110 21198 ...
  $ Income: num  3624 6315 4530 3378 5114 ...
  $ Illiteracy: num  2.1 1.5 1.8 1.9 1.1 0.7 1.1 0.9 1.3 2 ...
  $ Life Exp  : num  69 69.3 70.5 70.7 71.7 ...
  $ Murder: num  15.1 11.3 7.8 10.1 10.3 6.8 3.1 6.2 10.7 13.9 ...
  $ HS Grad   : num  41.3 66.7 58.1 39.9 62.6 63.9 56 54.6 52.6 40.6 ...
  $ Frost : num  20 152 15 65 20 166 139 103 11 60 ...
  $ Area  : num  50708 566432 113417 51945 156361 ...
 
 What am I messing up?
 
   [[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.


FREE ONLINE PHOTOSHARING - Share your photos online with your friends and 
family!
Visit http://www.inbox.com/photosharing to find out more!

__
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] Fwd: Joining two datasets - recursive procedure?

2015-03-22 Thread Luca Meyer
Hi Bert,

Maybe I did not explain myself clearly enough. But let me show you with a
manual example that indeed what I would like to do is feasible.

The following is also available for download from
https://www.dropbox.com/s/qhmpkkrejjkpbkx/sample_code.txt?dl=0

rm(list=ls())

This is usual (an extract of) the INPUT file I have:

f1 - structure(list(v1 = c(A, A, A, A, A, A, B, B,
B, B, B, B), v2 = c(A, B, C, A, B, C, A,
B, C, A, B, C), v3 = c(B, B, B, C, C, C,
B, B, B, C, C, C), v4 = c(18.18530, 3.43806,0.00273, 1.42917,
1.05786, 0.00042, 2.37232, 3.01835, 0, 1.13430, 0.92872,
0)), .Names = c(v1, v2, v3, v4), class = data.frame, row.names =
c(2L,
9L, 11L, 41L, 48L, 50L, 158L, 165L, 167L, 197L, 204L, 206L))

This are the initial marginal distributions

aggregate(v4~v1*v2,f1,sum)
aggregate(v4~v3,f1,sum)

First I order the file such that I have nicely listed 6 distinct v1xv2
combinations.

f1 - f1[order(f1$v1,f1$v2),]

Then I compute (manually) the relative importance of each v1xv2 combination:

tAA -
(18.18530+1.42917)/(18.18530+1.42917+3.43806+1.05786+0.00273+0.00042+2.37232+1.13430+3.01835+0.92872+0.0+0.0)
# this is for combination v1=A  v2=A
tAB -
(3.43806+1.05786)/(18.18530+1.42917+3.43806+1.05786+0.00273+0.00042+2.37232+1.13430+3.01835+0.92872+0.0+0.0)
# this is for combination v1=A  v2=B
tAC -
(0.00273+0.00042)/(18.18530+1.42917+3.43806+1.05786+0.00273+0.00042+2.37232+1.13430+3.01835+0.92872+0.0+0.0)
# this is for combination v1=A  v2=C
tBA -
(2.37232+1.13430)/(18.18530+1.42917+3.43806+1.05786+0.00273+0.00042+2.37232+1.13430+3.01835+0.92872+0.0+0.0)
# this is for combination v1=B  v2=A
tBB -
(3.01835+0.92872)/(18.18530+1.42917+3.43806+1.05786+0.00273+0.00042+2.37232+1.13430+3.01835+0.92872+0.0+0.0)
# this is for combination v1=B  v2=B
tBC -
(0.0+0.0)/(18.18530+1.42917+3.43806+1.05786+0.00273+0.00042+2.37232+1.13430+3.01835+0.92872+0.0+0.0)
# this is for combination v1=B  v2=C
# and just to make sure I have not made mistakes the following should be
equal to 1
tAA+tAB+tAC+tBA+tBB+tBC

Next, I know I need to increase v4 any time v3=B and the total increase I
need to have over the whole dataset is 29-27.01676=1.98324. In turn, I need
to dimish v4 any time V3=C by the same amount (4.55047-2.56723=1.98324).
This aspect was perhaps not clear at first. I need to move v4 across v3
categories, but the totals will always remain unchanged.

Since I want the data alteration to be proportional to the v1xv2
combinations I do the following:

f1$v4 - ifelse (f1$v1==A  f1$v2==A  f1$v3==B, f1$v4+(tAA*1.98324),
f1$v4)
f1$v4 - ifelse (f1$v1==A  f1$v2==A  f1$v3==C, f1$v4-(tAA*1.98324),
f1$v4)
f1$v4 - ifelse (f1$v1==A  f1$v2==B  f1$v3==B, f1$v4+(tAB*1.98324),
f1$v4)
f1$v4 - ifelse (f1$v1==A  f1$v2==B  f1$v3==C, f1$v4-(tAB*1.98324),
f1$v4)
f1$v4 - ifelse (f1$v1==A  f1$v2==C  f1$v3==B, f1$v4+(tAC*1.98324),
f1$v4)
f1$v4 - ifelse (f1$v1==A  f1$v2==C  f1$v3==C, f1$v4-(tAC*1.98324),
f1$v4)
f1$v4 - ifelse (f1$v1==B  f1$v2==A  f1$v3==B, f1$v4+(tBA*1.98324),
f1$v4)
f1$v4 - ifelse (f1$v1==B  f1$v2==A  f1$v3==C, f1$v4-(tBA*1.98324),
f1$v4)
f1$v4 - ifelse (f1$v1==B  f1$v2==B  f1$v3==B, f1$v4+(tBB*1.98324),
f1$v4)
f1$v4 - ifelse (f1$v1==B  f1$v2==B  f1$v3==C, f1$v4-(tBB*1.98324),
f1$v4)
f1$v4 - ifelse (f1$v1==B  f1$v2==C  f1$v3==B, f1$v4+(tBC*1.98324),
f1$v4)
f1$v4 - ifelse (f1$v1==B  f1$v2==C  f1$v3==C, f1$v4-(tBC*1.98324),
f1$v4)

This are the final marginal distributions:

aggregate(v4~v1*v2,f1,sum)
aggregate(v4~v3,f1,sum)

Can this procedure be made programmatic so that I can run it on the
(8x13x13) categories matrix? if so, how would you do it? I have really hard
time to do it with some (semi)automatic procedure.

Thank you very much indeed once more :)

Luca


2015-03-22 18:32 GMT+01:00 Bert Gunter gunter.ber...@gene.com:

 Nonsense. You are not telling us something or I have failed to
 understand something.

 Consider:

 v1 = c(a,b)
 v2 = c(a,a)

 It is not possible to change the value of a sum of values
 corresponding to v2=a without also changing that for v1, which is
 not supposed to change according to my understanding of your
 specification.

 So I'm done.

 -- Bert


 Bert Gunter
 Genentech Nonclinical Biostatistics
 (650) 467-7374

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




 On Sun, Mar 22, 2015 at 8:28 AM, Luca Meyer lucam1...@gmail.com wrote:
  Sorry forgot to keep the rest of the group in the loop - Luca
  -- Forwarded message --
  From: Luca Meyer lucam1...@gmail.com
  Date: 2015-03-22 16:27 GMT+01:00
  Subject: Re: [R] Joining two datasets - recursive procedure?
  To: Bert Gunter gunter.ber...@gene.com
 
 
  Hi Bert,
 
  That is exactly what I am trying to achieve. Please notice that negative
 v4
  values are allowed. I have done a similar task in the past manually by
  recursively alterating v4 distribution across v3 categories within fix
 each
  v1v2 combination so I am 

Re: [R] Joining two datasets - recursive procedure?

2015-03-22 Thread David Winsemius

On Mar 22, 2015, at 1:12 PM, Luca Meyer wrote:

 Hi Bert,
 
 Maybe I did not explain myself clearly enough. But let me show you with a
 manual example that indeed what I would like to do is feasible.
 
 The following is also available for download from
 https://www.dropbox.com/s/qhmpkkrejjkpbkx/sample_code.txt?dl=0
 
 rm(list=ls())
 
 This is usual (an extract of) the INPUT file I have:
 
 f1 - structure(list(v1 = c(A, A, A, A, A, A, B, B,
 B, B, B, B), v2 = c(A, B, C, A, B, C, A,
 B, C, A, B, C), v3 = c(B, B, B, C, C, C,
 B, B, B, C, C, C), v4 = c(18.18530, 3.43806,0.00273, 1.42917,
 1.05786, 0.00042, 2.37232, 3.01835, 0, 1.13430, 0.92872,
 0)), .Names = c(v1, v2, v3, v4), class = data.frame, row.names =
 c(2L,
 9L, 11L, 41L, 48L, 50L, 158L, 165L, 167L, 197L, 204L, 206L))
 
 This are the initial marginal distributions
 
 aggregate(v4~v1*v2,f1,sum)
 aggregate(v4~v3,f1,sum)
 
 First I order the file such that I have nicely listed 6 distinct v1xv2
 combinations.
 
 f1 - f1[order(f1$v1,f1$v2),]
 
 Then I compute (manually) the relative importance of each v1xv2 combination:
 
 tAA -
 (18.18530+1.42917)/(18.18530+1.42917+3.43806+1.05786+0.00273+0.00042+2.37232+1.13430+3.01835+0.92872+0.0+0.0)
 # this is for combination v1=A  v2=A
 tAB -
 (3.43806+1.05786)/(18.18530+1.42917+3.43806+1.05786+0.00273+0.00042+2.37232+1.13430+3.01835+0.92872+0.0+0.0)
 # this is for combination v1=A  v2=B
 tAC -
 (0.00273+0.00042)/(18.18530+1.42917+3.43806+1.05786+0.00273+0.00042+2.37232+1.13430+3.01835+0.92872+0.0+0.0)
 # this is for combination v1=A  v2=C
 tBA -
 (2.37232+1.13430)/(18.18530+1.42917+3.43806+1.05786+0.00273+0.00042+2.37232+1.13430+3.01835+0.92872+0.0+0.0)
 # this is for combination v1=B  v2=A
 tBB -
 (3.01835+0.92872)/(18.18530+1.42917+3.43806+1.05786+0.00273+0.00042+2.37232+1.13430+3.01835+0.92872+0.0+0.0)
 # this is for combination v1=B  v2=B
 tBC -
 (0.0+0.0)/(18.18530+1.42917+3.43806+1.05786+0.00273+0.00042+2.37232+1.13430+3.01835+0.92872+0.0+0.0)
 # this is for combination v1=B  v2=C
 # and just to make sure I have not made mistakes the following should be
 equal to 1
 tAA+tAB+tAC+tBA+tBB+tBC
 
 Next, I know I need to increase v4 any time v3=B and the total increase I
 need to have over the whole dataset is 29-27.01676=1.98324. In turn, I need
 to dimish v4 any time V3=C by the same amount (4.55047-2.56723=1.98324).
 This aspect was perhaps not clear at first. I need to move v4 across v3
 categories, but the totals will always remain unchanged.
 
 Since I want the data alteration to be proportional to the v1xv2
 combinations I do the following:
 
 f1$v4 - ifelse (f1$v1==A  f1$v2==A  f1$v3==B, f1$v4+(tAA*1.98324),
 f1$v4)
 f1$v4 - ifelse (f1$v1==A  f1$v2==A  f1$v3==C, f1$v4-(tAA*1.98324),
 f1$v4)
 f1$v4 - ifelse (f1$v1==A  f1$v2==B  f1$v3==B, f1$v4+(tAB*1.98324),
 f1$v4)
 f1$v4 - ifelse (f1$v1==A  f1$v2==B  f1$v3==C, f1$v4-(tAB*1.98324),
 f1$v4)
 f1$v4 - ifelse (f1$v1==A  f1$v2==C  f1$v3==B, f1$v4+(tAC*1.98324),
 f1$v4)
 f1$v4 - ifelse (f1$v1==A  f1$v2==C  f1$v3==C, f1$v4-(tAC*1.98324),
 f1$v4)
 f1$v4 - ifelse (f1$v1==B  f1$v2==A  f1$v3==B, f1$v4+(tBA*1.98324),
 f1$v4)
 f1$v4 - ifelse (f1$v1==B  f1$v2==A  f1$v3==C, f1$v4-(tBA*1.98324),
 f1$v4)
 f1$v4 - ifelse (f1$v1==B  f1$v2==B  f1$v3==B, f1$v4+(tBB*1.98324),
 f1$v4)
 f1$v4 - ifelse (f1$v1==B  f1$v2==B  f1$v3==C, f1$v4-(tBB*1.98324),
 f1$v4)
 f1$v4 - ifelse (f1$v1==B  f1$v2==C  f1$v3==B, f1$v4+(tBC*1.98324),
 f1$v4)
 f1$v4 - ifelse (f1$v1==B  f1$v2==C  f1$v3==C, f1$v4-(tBC*1.98324),
 f1$v4)
 

Seems that this could be done a lot more simply with a lookup matrix and 
ordinary indexing

 lookarr - array(NA, 
 dim=c(length(unique(f1$v1)),length(unique(f1$v2)),length(unique(f1$v3)) ) , 
 dimnames=list( unique(f1$v1), unique(f1$v2), unique(f1$v3) ) )
 lookarr[] - c(tAA,tAA,tAB,tAB,tAC,tAC,tBA,tBA,
 tBB, tBB, tBC, tBC)

 lookarr[ A,B,C]
[1] 0.1250369

 lookarr[ with(f1, cbind(v1, v2, v3)) ]
 [1] 6.213554e-01 1.110842e-01 1.424236e-01 1.250369e-01 9.978703e-05
 [6] 0.00e+00 6.213554e-01 1.110842e-01 1.424236e-01 1.250369e-01
[11] 9.978703e-05 0.00e+00
 f1$v4mod - f1$v4*lookarr[ with(f1, cbind(v1,v2,v3)) ]
 f1
v1 v2 v3   v4v4mod
2A  A  B 18.18530 1.129954e+01
41   A  A  C  1.42917 1.587582e-01
9A  B  B  3.43806 4.896610e-01
48   A  B  C  1.05786 1.322716e-01
11   A  C  B  0.00273 2.724186e-07
50   A  C  C  0.00042 0.00e+00
158  B  A  B  2.37232 1.474054e+00
197  B  A  C  1.13430 1.260028e-01
165  B  B  B  3.01835 4.298844e-01
204  B  B  C  0.92872 1.161243e-01
167  B  C  B  0.0 0.00e+00
206  B  C  C  0.0 0.00e+00

-- 
david.


 This are the final marginal distributions:
 
 aggregate(v4~v1*v2,f1,sum)
 aggregate(v4~v3,f1,sum)
 
 Can this procedure be made programmatic so that I can run it on the
 (8x13x13) categories matrix? if so, how would you do it? I have really hard
 time to do it with some (semi)automatic procedure.
 
 Thank you very much 

Re: [R] Fwd: Joining two datasets - recursive procedure?

2015-03-22 Thread Bert Gunter
Nonsense. You are not telling us something or I have failed to
understand something.

Consider:

v1 = c(a,b)
v2 = c(a,a)

It is not possible to change the value of a sum of values
corresponding to v2=a without also changing that for v1, which is
not supposed to change according to my understanding of your
specification.

So I'm done.

-- Bert


Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

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




On Sun, Mar 22, 2015 at 8:28 AM, Luca Meyer lucam1...@gmail.com wrote:
 Sorry forgot to keep the rest of the group in the loop - Luca
 -- Forwarded message --
 From: Luca Meyer lucam1...@gmail.com
 Date: 2015-03-22 16:27 GMT+01:00
 Subject: Re: [R] Joining two datasets - recursive procedure?
 To: Bert Gunter gunter.ber...@gene.com


 Hi Bert,

 That is exactly what I am trying to achieve. Please notice that negative v4
 values are allowed. I have done a similar task in the past manually by
 recursively alterating v4 distribution across v3 categories within fix each
 v1v2 combination so I am quite positive it can be achieved but honestly I
 took me forever to do it manually and since this is likely to be an
 exercise I need to repeat from time to time I wish I could learn how to do
 it programmatically

 Thanks again for any further suggestion you might have,

 Luca


 2015-03-22 16:05 GMT+01:00 Bert Gunter gunter.ber...@gene.com:

 Oh, wait a minute ...

 You still want the marginals for the other columns to be as originally?

 If so, then this is impossible in general as the sum of all the values
 must be what they were originally and you cannot therefore choose your
 values for V3 arbitrarily.

 Or at least, that seems to be what you are trying to do.

 -- Bert

 Bert Gunter
 Genentech Nonclinical Biostatistics
 (650) 467-7374

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




 On Sun, Mar 22, 2015 at 7:55 AM, Bert Gunter bgun...@gene.com wrote:
  I would have thought that this is straightforward given my previous
 email...
 
  Just set z to what you want -- e,g, all B values to 29/number of B's,
  and all C values to 2.567/number of C's (etc. for more categories).
 
  A slick but sort of cheat way to do this programmatically -- in the
  sense that it relies on the implementation of factor() rather than its
  API -- is:
 
  y - f1$v3  ## to simplify the notation; could be done using with()
  z - (c(29,2.567)/table(y))[c(y)]
 
  Then proceed to z1 as I previously described
 
  -- Bert
 
 
  Bert Gunter
  Genentech Nonclinical Biostatistics
  (650) 467-7374
 
  Data is not information. Information is not knowledge. And knowledge
  is certainly not wisdom.
  Clifford Stoll
 
 
 
 
  On Sun, Mar 22, 2015 at 2:00 AM, Luca Meyer lucam1...@gmail.com wrote:
  Hi Bert, hello R-experts,
 
  I am close to a solution but I still need one hint w.r.t. the following
  procedure (available also from
  https://www.dropbox.com/s/qhmpkkrejjkpbkx/sample_code.txt?dl=0)
 
  rm(list=ls())
 
  # this is (an extract of) the INPUT file I have:
  f1 - structure(list(v1 = c(A, A, A, A, A, A, B, B, B,
  B, B, B), v2 = c(A, B, C, A, B, C, A, B, C, A,
  B, C), v3 = c(B, B, B, C, C, C, B, B, B, C, C,
  C), v4 = c(18.18530, 3.43806,0.00273, 1.42917, 1.05786, 0.00042,
 2.37232,
  3.01835, 0, 1.13430, 0.92872, 0)), .Names = c(v1, v2, v3, v4),
 class
  = data.frame, row.names = c(2L, 9L, 11L, 41L, 48L, 50L, 158L, 165L,
 167L,
  197L, 204L, 206L))
 
  # this is the procedure that Bert suggested (slightly adjusted):
  z - rnorm(nrow(f1)) ## or anything you want
  z1 - round(with(f1,v4 + z -ave(z,v1,v2,FUN=mean)), digits=5)
  aggregate(v4~v1*v2,f1,sum)
  aggregate(z1~v1*v2,f1,sum)
  aggregate(v4~v3,f1,sum)
  aggregate(z1~v3,f1,sum)
 
  My question to you is: how can I set z so that I can obtain specific
 values
  for z1-v4 in the v3 aggregation?
  In other words, how can I configure the procedure so that e.g. B=29 and
  C=2.56723 after running the procedure:
  aggregate(z1~v3,f1,sum)
 
  Thank you,
 
  Luca
 
  PS: to avoid any doubts you might have about who I am the following is
 my
  web page: http://lucameyer.wordpress.com/
 
 
  2015-03-21 18:13 GMT+01:00 Bert Gunter gunter.ber...@gene.com:
 
  ... or cleaner:
 
  z1 - with(f1,v4 + z -ave(z,v1,v2,FUN=mean))
 
 
  Just for curiosity, was this homework? (in which case I should
  probably have not provided you an answer -- that is, assuming that I
  HAVE provided an answer).
 
  Cheers,
  Bert
 
  Bert Gunter
  Genentech Nonclinical Biostatistics
  (650) 467-7374
 
  Data is not information. Information is not knowledge. And knowledge
  is certainly not wisdom.
  Clifford Stoll
 
 
 
 
  On Sat, Mar 21, 2015 at 7:53 AM, Bert Gunter bgun...@gene.com wrote:
   z - rnorm(nrow(f1)) ## or anything you want
   z1 - f1$v4 + z - with(f1,ave(z,v1,v2,FUN=mean))
  
  
   aggregate(v4~v1,f1,sum)
   

Re: [R-es] Combinatoria

2015-03-22 Thread Our Utopy
Hola de nuevo amigos, Gracias por vuestras respuestas. Un placer levantarme
esta mañana y ver que alguien había tratado de ayudarme. Espero en unas
semanas poder también ser yo útil a quien lo necesite.

Me explico de nuevo. Estoy aprendiendo y mi primera visión, antes del Data
Mining y las redes neuronales a las que quiero llegar, es ir solucionando
los problemas básicos además de explicarles R a mis propios alumnos en
lugar de Wiris (idóneo para secundaria) o Maxima.

Mi problema es de combinatoria básica, quiero calcular Cm,n  Pn  Vm,n  y lo
mismo con repetición. Son cosas muy básicas de secundaria que cualquier
programa o calculadora de mano las resuelve. Supuse que R en su módulo
básico o CORE las respondería al igual que responde a logaritmos en
cualquier base, determinantes e inversas de matrices.

Pero no, hay que instalar paquetes adicionales.

Buscando encontré que el paquete *combinat* incluye dos de estas funciones

   - *combn(m,n)*
   - *permn(n)*
   - *e incluso mCn(m,n)*

N es solo que haga el cálculod e cuantas son sino que las escribe todas,
por ejemplo

 combn(4,2)
 [,1] [,2] [,3] [,4] [,5] [,6]
[1,]111223
[2,]234344

 permn(3)
[[1]]
[1] 1 2 3

[[2]]
[1] 1 3 2

[[3]]
[1] 3 1 2

[[4]]
[1] 3 2 1

[[5]]
[1] 2 3 1

[[6]]
[1] 2 1 3


Y mCn las calcula, sin escribirlas:

 nCm(4,2)
[1] 6

Pero me chocó que NO incluyese Variaciones con y sin repetición, y
combinaciones y permutaciones con repetición. Tanto que me las calcule como
que me las escriba. Al menos yo no las encuentro a pesar de ser una
cuestión muy básica en combinatoria que ayuda a calcular probabilidades y
claro, ¡es que R es un programa de Estadística!

De ahí mi pregunta al grupo.

Si tengo que hacerme mi propia librería, pues creo que en unos días seré
capaz de hacerlo. Ayer precisamente ya estuve leyendo sobre construirme mis
propias funciones, pero es que me choca que no haya ninguna librería entre
las 6200 del repositorio que ya lo incluya.

Esa era mi pregunta.

Gracias anticipadas.

Miguel











El 21 de marzo de 2015, 19:35, Francisco Rodríguez fjr...@hotmail.com
escribió:

 En relación con lo que comenta Carlos, por ejemplo para el caso de las
 Variaciones sin Repetición, puede ser instructivo
 enseñar como se construye como por ejemplo:


 VsinR - function(m, n){

   return (factorial(m)/factorial(m-n))
 }


 VsinR(9,3)

 -


 Creo que con la función factorial que viene por defecto en R puedes
 construir siguiendo este modelo rápidadmente
 casi cualquier función de las de bachillerato. Las VconR serían m elevado
 a n

 Quizás la única que merezca la pena construir es la de Permutaciones con
 Repetición porque la parte de repetición puede tener más variedad, voy a
 mirar si lo encuentro y si no una función lo puede resolver.
 PR(m; n1, ..., nk) donde n1+...+nk = m y PR(m;n1, ...,nk) = m!/(n1!
 ·...·nk!)


 Un saludo




  Date: Sat, 21 Mar 2015 16:36:50 +0100
  From: c...@datanalytics.com
  To: ourut...@gmail.com
  CC: r-help-es@r-project.org
  Subject: Re: [R-es] Combinatoria

 
  Hola, ¿qué tal?
 
  ¿Qué quieres hacer, construir las
  combinaciones/permutaciones/variaciones o calcular cuántas hay?
 
  Es improbable que encuentres funciones que resuelvan exactamente un
  problema específico. Pero sí que podrás, con no mucho esfuerzo,
  extender lo que hay para atacar esos problemas.
 
  Un saludo y suerte con R,
 
  Carlos J. Gil Bellosta
  http://www.datanalytics.com
 
  El día 21 de marzo de 2015, 8:39, Our Utopy ourut...@gmail.com
 escribió:
   Hola buenos días, me presento, me llamo Miguel y 'soy de' y 'vivo en'
   Galicia.
   Soy profesor de secundaria (Bachillerato Adultos) y llevo 15 días
   estudiando R a un buen ritmo, pero todavía me faltan miles de cosas.
  
   He visto que R facilita, no solo el análisis de datos y que posee una
   potencia en cálculos estadísticos a cualquier nivel, sino gran caudal
 de
   recursos para Data Mining, Redes Neuronales, reconocimiento de
 patrones y
   probablemente todo cuanto deseemos, pero ... aqui va mi primera
   pregunta
  
   1. Si quiero calcular unas combinaciones, la función *combn* ó la
 *nCm* me
   lo resuelven
   2. Si quiero permutaciones, entonces ya tengo que cargar el paquete
   combinat
   3. Pero no encuentro , y no puedo entenderlo, que no encuentre una
   función análoga para las variaciones con y sin repetición y para las
   permutaciones con repetición. y ya llevo varias horas buscando  ¡!
   puede que ayer y hoy me encuentre algo espeso, no lo descarto.
  
   Me podríais ayudar en esta tan básica duda.
  
   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
 
  ___
  R-help-es mailing list
  R-help-es@r-project.org
  https://stat.ethz.ch/mailman/listinfo/r-help-es


  

Re: [R] ordering a boxplot

2015-03-22 Thread Antonio Silva
Dear Boris,

Thanks very much, have a great week.

Best regards

Antônio Olinto
Fisheries Institute
São Paulo, Brasil



2015-03-21 21:09 GMT-03:00 Boris Steipe boris.ste...@utoronto.ca:

 ... just for completeness - the more concise way: (no need to go through
 names()).

 boxplot(mydata[,order(apply(mydata,2,median))])

 ... or descending
 boxplot(mydata[,order(-apply(mydata,2,median))])




 B.



 On Mar 21, 2015, at 7:04 PM, Boris Steipe boris.ste...@utoronto.ca
 wrote:

  There may be more concise ways to do this - but you are 99% there with
 your approach:
  try:
 
  boxplot(mydata[,names(sort(apply(mydata,2,median)))])
 
  B.
 
 
  On Mar 21, 2015, at 6:49 PM, Antonio Silva aolinto@gmail.com
 wrote:
 
  Thanks Bill and David
 
  Here goes an example
 
  SP1-c(9,6,7,8,5,8,7,5,9,7)
  SP2-c(1,3,4,2,4,2,5,3,2,1)
  SP3-c(4,6,7,5,7,8,7,6,5,4)
  SP4-c(5,4,3,5,2,3,4,3,4,2)
  mydata-data.frame(SP1,SP2,SP3,SP4)
 
 rownames(mydata)-c(ST1,ST2,ST3,ST4,ST5,ST6,ST7,ST8,ST9,ST10)
  mydata
  boxplot(mydata)
 
  Note that this data frame does not have the format Response ~ Group. In
 my
  real matrix I have up to 40 species.
 
  Is there any way to have the species ordered by their median abundance
 (or
  other parameter?)
 
  The desired order is given by names(sort(apply(mydata,2,median)))
 
  Thanks once more,
 
  Antonio Olinto
  Fisheries Institute
  Sao Paulo, Brazil
 
  2015-03-21 15:13 GMT-03:00 William Dunlap wdun...@tibco.com:
 
  You can use the reorder() function to reorder the grouping vector's
  factor levels according to a function of the data in each group.  E.g.,
  compare the following two plots:
 
   d - data.frame(Response=cos(1:15),
 Group=rep(c(A,B,C),c(6,5,4)))
   par(mfrow=c(1,2))
   boxplot(Response ~ Group, data=d)
   boxplot(Response ~ reorder(Group, X=Response, FUN=median), data=d)
 
 
  Bill Dunlap
  TIBCO Software
  wdunlap tibco.com
 
  On Fri, Mar 20, 2015 at 2:20 PM, Antonio Silva aolinto@gmail.com
  wrote:
 
  Hello
 
  I'm using a dataframe (mydata) where row names are sampling points and
  column names are species in a multivariate analysis.
 
  If I write boxplot(mydata) I'll have boxplots for each species
 abundance
  in
  alphabetical order.
 
  How to get the boxes orderer by the median?
 
  Usually for this I write
 
 
 boxplot(value~category,at=rank(tapply(mydata$value,mydata$category,median)))
  but for this to work I need a column for the categories and another
 column
  for the values.
 
  Thanks in advance, best regards.
 
  Antonio Olinto
 
[[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-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] Combinatoria

2015-03-22 Thread Carlos Ortega
Hola,

Por precisar un par de detalles:


   - Con el paquete gtools se pueden generar:
   - las variaciones, permutaciones, combinaciones, variaciones con
  repetición y combinaciones con repetición (mira el ejemplo
adjunto con las
  combinaciones con repetición).
  - Quedan sin cubrir las permutaciones con repetición.


   - Y dentro del paquete base, sí que hay formas de calcular algunas
   cosas de combinatoria. Mira la función choose() para el cálculo de las
   combinaciones. En el ejemplo de la función incluso aparece una forma de
   generar el triángulo de Pascal.

#- Ejemplo de Combinaciones con repetición (gtools) -

 x - c('rojo', 'azul', 'verde')
 # Combinaciones sin repetición
 combinations(n=3, r=2, v=x, repeats=FALSE)
 [,1]   [,2]
[1,] azul rojo
[2,] azul verde
[3,] rojo verde
 # Combinaciones con repetición
 combinations(n=3, r=2, v=x, repeats=TRUE)
 [,1][,2]
[1,] azul  azul
[2,] azul  rojo
[3,] azul  verde
[4,] rojo  rojo
[5,] rojo  verde
[6,] verde verde

#---

Saludos,
Carlos Ortega
www.qualityexcellence.es

El 22 de marzo de 2015, 22:50, Our Utopy ourut...@gmail.com escribió:

 Hola amigos, muchas gracias por vuestra ayuda.

 Entonces veo que mi sorpresa era legítima. Por todos vuestros mails la
 conclusión es que:

- En el módulo base de R no incluye combinatoria elemental, ni siquiera
el número combinatorio Cm,n hay que cargar el paquete *combinat*
- Y para las variaciones con repetición el paquete* gtools*
- Y aún así no tenemos ni las combinaciones ni las permutaciones, ambas
con repetición.


 Pues tendremos que ponernos a ello ¿no creéis? y hacer un paquete que lo
 resuelva y que genere incluso un triángulo de Pascal y otras cuestiones del
 binomio de Newton.
 Ya sé que es matemática elemental pero repito que estoy sorprendido por
 este hecho y más porque estas *Técnicas de conteo* son imprescindibles para
 el cálculo básico de probabilidades.

 Seguimos en la lucha. Un saludo


 El 22 de marzo de 2015, 19:32, Francisco Rodríguez fjr...@hotmail.com
 escribió:

  Carlos, creo que el ejemplo que mandas se refiere a las Variaciones con
  Repetición de 3 elementos tomados de 3 en 3 y cuyo número asciende a 27
 
  En las Permutaciones con repetición con las observaciones se forman
 grupos
  disjuntos cuya suma de cardinales es el número total, así pues puede
  hablarse de Permutaciones con Repetición de 10 elementos tomados de 5 en
 5,
  2 en 2 y de 3 en 3, en este caso, el número de combinaciones que sale
  seria: PR5;3,2,3 = 10!/(5!·2!·3!)
 
  Este caso es el que digo que seria mas dificil de preparar y quizas si
  requiere algo de programacion, porque el numero de grupos es variable,
 pero
  a lo mejor en lo que mandas se puede introducir algun tipo de vector, en
  todo caso lo miro mañana
 
 
  Un saludo
 
  --
  Date: Sun, 22 Mar 2015 13:22:36 +0100
  Subject: Re: [R-es] Combinatoria
  From: c...@qualityexcellence.es
  To: fjr...@hotmail.com
  CC: ourut...@gmail.com; r-help-es@r-project.org
 
 
  Sí, también...
  Para las permutaciones, n=r.
  Y con el parámetro repeats.allowed controlas si son con o sin
 repetción:
 
  #--
   #Permutaciones *con repetición*
   permutations(n=3, r=3, v=x, repeats.allowed=TRUE)
[,1][,2][,3]
   [1,] azul  azul  azul
   [2,] azul  azul  rojo
   [3,] azul  azul  verde
   [4,] azul  rojo  azul
   [5,] azul  rojo  rojo
   [6,] azul  rojo  verde
   [7,] azul  verde azul
   [8,] azul  verde rojo
   [9,] azul  verde verde
  [10,] rojo  azul  azul
  [11,] rojo  azul  rojo
  [12,] rojo  azul  verde
  [13,] rojo  rojo  azul
  [14,] rojo  rojo  rojo
  [15,] rojo  rojo  verde
  [16,] rojo  verde azul
  [17,] rojo  verde rojo
  [18,] rojo  verde verde
  [19,] verde azul  azul
  [20,] verde azul  rojo
  [21,] verde azul  verde
  [22,] verde rojo  azul
  [23,] verde rojo  rojo
  [24,] verde rojo  verde
  [25,] verde verde azul
  [26,] verde verde rojo
  [27,] verde verde verde
   #Permutaciones *sin repetición*
   permutations(n=3, r=3, v=x, repeats.allowed=FALSE)
   [,1][,2][,3]
  [1,] azul  rojo  verde
  [2,] azul  verde rojo
  [3,] rojo  azul  verde
  [4,] rojo  verde azul
  [5,] verde azul  rojo
  [6,] verde rojo  azul
  #
 
 
  Saludos,
  Carlos Ortega
  www.qualityexcellence.es
 
 
  El 22 de marzo de 2015, 12:18, Francisco Rodríguez fjr...@hotmail.com
  escribió:
 
  Carlos y ya puestos ¿Las permutaciones con repetición, salen también de
  aquí?
 
  Un saludo y gracias
 
   Date: Sun, 22 Mar 2015 12:15:45 +0100
   From: c...@qualityexcellence.es
 
   To: ourut...@gmail.com
   CC: r-help-es@r-project.org
   Subject: Re: [R-es] Combinatoria
  
   Hola Miguel,
  
   Sí se pueden obtener las variaciones con y sin repetición en R.
   Eso sí están un poco escondidas...
  
   Se pueden calcular de esta forma:
  
   

Re: [R-es] Combinatoria

2015-03-22 Thread Our Utopy
Hola amigos, muchas gracias por vuestra ayuda.

Entonces veo que mi sorpresa era legítima. Por todos vuestros mails la
conclusión es que:

   - En el módulo base de R no incluye combinatoria elemental, ni siquiera
   el número combinatorio Cm,n hay que cargar el paquete *combinat*
   - Y para las variaciones con repetición el paquete* gtools*
   - Y aún así no tenemos ni las combinaciones ni las permutaciones, ambas
   con repetición.


Pues tendremos que ponernos a ello ¿no creéis? y hacer un paquete que lo
resuelva y que genere incluso un triángulo de Pascal y otras cuestiones del
binomio de Newton.
Ya sé que es matemática elemental pero repito que estoy sorprendido por
este hecho y más porque estas *Técnicas de conteo* son imprescindibles para
el cálculo básico de probabilidades.

Seguimos en la lucha. Un saludo


El 22 de marzo de 2015, 19:32, Francisco Rodríguez fjr...@hotmail.com
escribió:

 Carlos, creo que el ejemplo que mandas se refiere a las Variaciones con
 Repetición de 3 elementos tomados de 3 en 3 y cuyo número asciende a 27

 En las Permutaciones con repetición con las observaciones se forman grupos
 disjuntos cuya suma de cardinales es el número total, así pues puede
 hablarse de Permutaciones con Repetición de 10 elementos tomados de 5 en 5,
 2 en 2 y de 3 en 3, en este caso, el número de combinaciones que sale
 seria: PR5;3,2,3 = 10!/(5!·2!·3!)

 Este caso es el que digo que seria mas dificil de preparar y quizas si
 requiere algo de programacion, porque el numero de grupos es variable, pero
 a lo mejor en lo que mandas se puede introducir algun tipo de vector, en
 todo caso lo miro mañana


 Un saludo

 --
 Date: Sun, 22 Mar 2015 13:22:36 +0100
 Subject: Re: [R-es] Combinatoria
 From: c...@qualityexcellence.es
 To: fjr...@hotmail.com
 CC: ourut...@gmail.com; r-help-es@r-project.org


 Sí, también...
 Para las permutaciones, n=r.
 Y con el parámetro repeats.allowed controlas si son con o sin repetción:

 #--
  #Permutaciones *con repetición*
  permutations(n=3, r=3, v=x, repeats.allowed=TRUE)
   [,1][,2][,3]
  [1,] azul  azul  azul
  [2,] azul  azul  rojo
  [3,] azul  azul  verde
  [4,] azul  rojo  azul
  [5,] azul  rojo  rojo
  [6,] azul  rojo  verde
  [7,] azul  verde azul
  [8,] azul  verde rojo
  [9,] azul  verde verde
 [10,] rojo  azul  azul
 [11,] rojo  azul  rojo
 [12,] rojo  azul  verde
 [13,] rojo  rojo  azul
 [14,] rojo  rojo  rojo
 [15,] rojo  rojo  verde
 [16,] rojo  verde azul
 [17,] rojo  verde rojo
 [18,] rojo  verde verde
 [19,] verde azul  azul
 [20,] verde azul  rojo
 [21,] verde azul  verde
 [22,] verde rojo  azul
 [23,] verde rojo  rojo
 [24,] verde rojo  verde
 [25,] verde verde azul
 [26,] verde verde rojo
 [27,] verde verde verde
  #Permutaciones *sin repetición*
  permutations(n=3, r=3, v=x, repeats.allowed=FALSE)
  [,1][,2][,3]
 [1,] azul  rojo  verde
 [2,] azul  verde rojo
 [3,] rojo  azul  verde
 [4,] rojo  verde azul
 [5,] verde azul  rojo
 [6,] verde rojo  azul
 #


 Saludos,
 Carlos Ortega
 www.qualityexcellence.es


 El 22 de marzo de 2015, 12:18, Francisco Rodríguez fjr...@hotmail.com
 escribió:

 Carlos y ya puestos ¿Las permutaciones con repetición, salen también de
 aquí?

 Un saludo y gracias

  Date: Sun, 22 Mar 2015 12:15:45 +0100
  From: c...@qualityexcellence.es

  To: ourut...@gmail.com
  CC: r-help-es@r-project.org
  Subject: Re: [R-es] Combinatoria
 
  Hola Miguel,
 
  Sí se pueden obtener las variaciones con y sin repetición en R.
  Eso sí están un poco escondidas...
 
  Se pueden calcular de esta forma:
 
  #--
   #Cargar el paquete gtools
   library(gtools)
   #Definir el conjunto sobre el que se hará el cálculo
   x - c('rojo', 'azul', 'verde')
   #Utilizar la función permutations() modificando el valor de r y
   #modificando el parámetro repeats.allowed dependiendo si sequieren
 con
  o sin repetición
   permutations(n=3, r=2, v=x, repeats.allowed=FALSE)
  [,1] [,2]
  [1,] azul rojo
  [2,] azul verde
  [3,] rojo azul
  [4,] rojo verde
  [5,] verde azul
  [6,] verde rojo
   permutations(n=3, r=2, v=x, repeats.allowed=TRUE)
  [,1] [,2]
  [1,] azul azul
  [2,] azul rojo
  [3,] azul verde
  [4,] rojo azul
  [5,] rojo rojo
  [6,] rojo verde
  [7,] verde azul
  [8,] verde rojo
  [9,] verde verde
  #--
 
 
  Saludos,
  Carlos Ortega
  www.qualityexcellence.es
 
 
  El 22 de marzo de 2015, 9:02, Our Utopy ourut...@gmail.com escribió:
 
   Hola de nuevo amigos, Gracias por vuestras respuestas. Un placer
 levantarme
   esta mañana y ver que alguien había tratado de ayudarme. Espero en unas
   semanas poder también ser yo útil a quien lo necesite.
  
   Me explico de nuevo. Estoy aprendiendo y mi primera visión, antes del
 Data
   Mining y las redes neuronales a las que quiero llegar, es ir
 solucionando
   los problemas básicos además de explicarles R a mis propios alumnos en
   lugar de Wiris (idóneo 

[R] 1st script

2015-03-22 Thread memilanuk
So... wrote my first script, rather than just using the interactive 
console.  I think I got everything working more or less the way I want, 
but I'm sure there's a ton of room for improvement.  Specifically in the 
way of automation - but thats where I kind of ran out of steam.  Any 
suggestions would be much appreciated.


case_data.r

# Import CSV file into a data frame.
case_weights - read.csv(file = case_weights.csv)

# For each row, take the number in the Weight column and replicate it
# as many times as there are in each count column.
LC09 - rep(case_weights$Weight, case_weights$LC09)
LC10 - rep(case_weights$Weight, case_weights$LC10)
LP14b1 - rep(case_weights$Weight, case_weights$LP14b1)
LP14b2 - rep(case_weights$Weight, case_weights$LP14b2)

# Determine the longest vector, to help with the next step.
max.len - max(length(LC09), length(LC10), length(LP14b1),
length(LP14b2))

# Pad each vector with NA so they are all the same length and will
# go in a data frame.
LC09 - c(LC09, rep(NA, max.len - length(LC09)))
LC10 - c(LC10, rep(NA, max.len - length(LC10)))
LP14b1 - c(LP14b1, rep(NA, max.len - length(LP14b1)))
LP14b2 - c(LP14b2, rep(NA, max.len - length(LP14b2)))

# Stick everything back into one data frame.
case_dat - data.frame(LC09)
case_dat$LC10 - LC10
case_dat$LP14b1 - LP14b1
case_dat$LP14b2 - LP14b2

# Stuff said data frame back into a CSV for use elsewhere (plot.ly).
write.csv(case_dat, file = expanded_case_weights.csv)

# Boxplot it
boxplot(case_dat, varwidth = TRUE, notch = TRUE, horizontal = TRUE,
main = Case Weights, xlab = Weight (grains),
ylab = Batch, las = 1, names = c(LC09, LC10, LP14b1,
LP14b2))



--
Shiny!  Let's be bad guys.

Reach me @ memilanuk (at) gmail dot 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-es] Combinatoria

2015-03-22 Thread Carlos J. Gil Bellosta
Hola, ¿qué tal?

Efectivamente, no hay demasiado soporte para combinatoria (y para
matemática simbólica, y para...). Quienes se dedican a esas cosas
siempre puede usar Sage. Puedes echarle un vistazo a

http://www.sagemath.org/doc/reference/combinat/sage/combinat/tutorial.html

Es cierto que en estadística contar es un problema. Pero se parece mucho más a

http://andrewgelman.com/2008/05/08/doing_the_candy/

(una pequeña historia que te recomiendo) que a aquellas historias de
las variaciones con y sin repetición de mi primero de BUP.

Un saludo,

Carlos J. Gil Bellosta
http://www.datanalytics.com




El día 22 de marzo de 2015, 22:50, Our Utopy ourut...@gmail.com escribió:
 Hola amigos, muchas gracias por vuestra ayuda.

 Entonces veo que mi sorpresa era legítima. Por todos vuestros mails la
 conclusión es que:

- En el módulo base de R no incluye combinatoria elemental, ni siquiera
el número combinatorio Cm,n hay que cargar el paquete *combinat*
- Y para las variaciones con repetición el paquete* gtools*
- Y aún así no tenemos ni las combinaciones ni las permutaciones, ambas
con repetición.


 Pues tendremos que ponernos a ello ¿no creéis? y hacer un paquete que lo
 resuelva y que genere incluso un triángulo de Pascal y otras cuestiones del
 binomio de Newton.
 Ya sé que es matemática elemental pero repito que estoy sorprendido por
 este hecho y más porque estas *Técnicas de conteo* son imprescindibles para
 el cálculo básico de probabilidades.

 Seguimos en la lucha. Un saludo


 El 22 de marzo de 2015, 19:32, Francisco Rodríguez fjr...@hotmail.com
 escribió:

 Carlos, creo que el ejemplo que mandas se refiere a las Variaciones con
 Repetición de 3 elementos tomados de 3 en 3 y cuyo número asciende a 27

 En las Permutaciones con repetición con las observaciones se forman grupos
 disjuntos cuya suma de cardinales es el número total, así pues puede
 hablarse de Permutaciones con Repetición de 10 elementos tomados de 5 en 5,
 2 en 2 y de 3 en 3, en este caso, el número de combinaciones que sale
 seria: PR5;3,2,3 = 10!/(5!·2!·3!)

 Este caso es el que digo que seria mas dificil de preparar y quizas si
 requiere algo de programacion, porque el numero de grupos es variable, pero
 a lo mejor en lo que mandas se puede introducir algun tipo de vector, en
 todo caso lo miro mañana


 Un saludo

 --
 Date: Sun, 22 Mar 2015 13:22:36 +0100
 Subject: Re: [R-es] Combinatoria
 From: c...@qualityexcellence.es
 To: fjr...@hotmail.com
 CC: ourut...@gmail.com; r-help-es@r-project.org


 Sí, también...
 Para las permutaciones, n=r.
 Y con el parámetro repeats.allowed controlas si son con o sin repetción:

 #--
  #Permutaciones *con repetición*
  permutations(n=3, r=3, v=x, repeats.allowed=TRUE)
   [,1][,2][,3]
  [1,] azul  azul  azul
  [2,] azul  azul  rojo
  [3,] azul  azul  verde
  [4,] azul  rojo  azul
  [5,] azul  rojo  rojo
  [6,] azul  rojo  verde
  [7,] azul  verde azul
  [8,] azul  verde rojo
  [9,] azul  verde verde
 [10,] rojo  azul  azul
 [11,] rojo  azul  rojo
 [12,] rojo  azul  verde
 [13,] rojo  rojo  azul
 [14,] rojo  rojo  rojo
 [15,] rojo  rojo  verde
 [16,] rojo  verde azul
 [17,] rojo  verde rojo
 [18,] rojo  verde verde
 [19,] verde azul  azul
 [20,] verde azul  rojo
 [21,] verde azul  verde
 [22,] verde rojo  azul
 [23,] verde rojo  rojo
 [24,] verde rojo  verde
 [25,] verde verde azul
 [26,] verde verde rojo
 [27,] verde verde verde
  #Permutaciones *sin repetición*
  permutations(n=3, r=3, v=x, repeats.allowed=FALSE)
  [,1][,2][,3]
 [1,] azul  rojo  verde
 [2,] azul  verde rojo
 [3,] rojo  azul  verde
 [4,] rojo  verde azul
 [5,] verde azul  rojo
 [6,] verde rojo  azul
 #


 Saludos,
 Carlos Ortega
 www.qualityexcellence.es


 El 22 de marzo de 2015, 12:18, Francisco Rodríguez fjr...@hotmail.com
 escribió:

 Carlos y ya puestos ¿Las permutaciones con repetición, salen también de
 aquí?

 Un saludo y gracias

  Date: Sun, 22 Mar 2015 12:15:45 +0100
  From: c...@qualityexcellence.es

  To: ourut...@gmail.com
  CC: r-help-es@r-project.org
  Subject: Re: [R-es] Combinatoria
 
  Hola Miguel,
 
  Sí se pueden obtener las variaciones con y sin repetición en R.
  Eso sí están un poco escondidas...
 
  Se pueden calcular de esta forma:
 
  #--
   #Cargar el paquete gtools
   library(gtools)
   #Definir el conjunto sobre el que se hará el cálculo
   x - c('rojo', 'azul', 'verde')
   #Utilizar la función permutations() modificando el valor de r y
   #modificando el parámetro repeats.allowed dependiendo si sequieren
 con
  o sin repetición
   permutations(n=3, r=2, v=x, repeats.allowed=FALSE)
  [,1] [,2]
  [1,] azul rojo
  [2,] azul verde
  [3,] rojo azul
  [4,] rojo verde
  [5,] verde azul
  [6,] verde rojo
   permutations(n=3, r=2, v=x, repeats.allowed=TRUE)
  [,1] [,2]
  [1,] azul azul
  [2,] azul rojo
  [3,] azul verde
  [4,] rojo azul
  [5,] rojo rojo
  [6,] 

Re: [R-es] Combinatoria

2015-03-22 Thread Jorge I Velez
Hola Miguel,
Exactamente que necesitas hacer con ecuaciones no lineales?  Encontrar la
raiz?  Si este es el caso, no necesitas, en principio, cargar ningun
paquete.  Con la funcion ?optim en base podrias hacer lo basico.
Saludos cordiales,
Jorge.-


2015-03-23 10:22 GMT+11:00 Our Utopy ourut...@gmail.com:

 Ya me extra�aba a mi!
 Ma�ana a primera hora miro todo lo que me comentas.
 Ahora estoy con ecuaciones no lineales y ya veo que hay que cargar
 librerias
 Muchas gracias. Un saludo

 El 23 de marzo de 2015, 0:08, Carlos Ortega c...@qualityexcellence.es
 escribi�:

  Hola,
 
  Por precisar un par de detalles:
 
 
 - Con el paquete gtools se pueden generar:
 - las variaciones, permutaciones, combinaciones, variaciones con
repetici�n y combinaciones con repetici�n (mira el ejemplo adjunto
 con las
combinaciones con repetici�n).
- Quedan sin cubrir las permutaciones con repetici�n.
 
 
 - Y dentro del paquete base, s� que hay formas de calcular algunas
 cosas de combinatoria. Mira la funci�n choose() para el c�lculo de
 las
 combinaciones. En el ejemplo de la funci�n incluso aparece una forma
 de
 generar el tri�ngulo de Pascal.
 
  #- Ejemplo de Combinaciones con repetici�n (gtools) -
 
   x - c('rojo', 'azul', 'verde')
   # Combinaciones sin repetici�n
   combinations(n=3, r=2, v=x, repeats=FALSE)
   [,1]   [,2]
  [1,] azul rojo
  [2,] azul verde
  [3,] rojo verde
   # Combinaciones con repetici�n
   combinations(n=3, r=2, v=x, repeats=TRUE)
   [,1][,2]
  [1,] azul  azul
  [2,] azul  rojo
  [3,] azul  verde
  [4,] rojo  rojo
  [5,] rojo  verde
  [6,] verde verde
 
  #---
 
  Saludos,
  Carlos Ortega
  www.qualityexcellence.es
 
  El 22 de marzo de 2015, 22:50, Our Utopy ourut...@gmail.com escribi�:
 
  Hola amigos, muchas gracias por vuestra ayuda.
 
  Entonces veo que mi sorpresa era leg�tima. Por todos vuestros mails la
  conclusi�n es que:
 
 - En el m�dulo base de R no incluye combinatoria elemental, ni
 siquiera
 el n�mero combinatorio Cm,n hay que cargar el paquete *combinat*
 - Y para las variaciones con repetici�n el paquete* gtools*
 - Y a�n as� no tenemos ni las combinaciones ni las permutaciones,
 ambas
 con repetici�n.
 
 
  Pues tendremos que ponernos a ello �no cre�is? y hacer un paquete que lo
  resuelva y que genere incluso un tri�ngulo de Pascal y otras cuestiones
  del
  binomio de Newton.
  Ya s� que es matem�tica elemental pero repito que estoy sorprendido por
  este hecho y m�s porque estas *T�cnicas de conteo* son imprescindibles
  para
  el c�lculo b�sico de probabilidades.
 
  Seguimos en la lucha. Un saludo
 
 
  El 22 de marzo de 2015, 19:32, Francisco Rodr�guez fjr...@hotmail.com
  escribi�:
 
   Carlos, creo que el ejemplo que mandas se refiere a las Variaciones
 con
   Repetici�n de 3 elementos tomados de 3 en 3 y cuyo n�mero asciende a
 27
  
   En las Permutaciones con repetici�n con las observaciones se forman
  grupos
   disjuntos cuya suma de cardinales es el n�mero total, as� pues puede
   hablarse de Permutaciones con Repetici�n de 10 elementos tomados de 5
  en 5,
   2 en 2 y de 3 en 3, en este caso, el n�mero de combinaciones que sale
   seria: PR5;3,2,3 = 10!/(5!�2!�3!)
  
   Este caso es el que digo que seria mas dificil de preparar y quizas si
   requiere algo de programacion, porque el numero de grupos es variable,
  pero
   a lo mejor en lo que mandas se puede introducir algun tipo de vector,
 en
   todo caso lo miro ma�ana
  
  
   Un saludo
  
   --
   Date: Sun, 22 Mar 2015 13:22:36 +0100
   Subject: Re: [R-es] Combinatoria
   From: c...@qualityexcellence.es
   To: fjr...@hotmail.com
   CC: ourut...@gmail.com; r-help-es@r-project.org
  
  
   S�, tambi�n...
   Para las permutaciones, n=r.
   Y con el par�metro repeats.allowed controlas si son con o sin
  repetci�n:
  
   #--
#Permutaciones *con repetici�n*
 
permutations(n=3, r=3, v=x, repeats.allowed=TRUE)
 [,1][,2][,3]
[1,] azul  azul  azul
[2,] azul  azul  rojo
[3,] azul  azul  verde
[4,] azul  rojo  azul
[5,] azul  rojo  rojo
[6,] azul  rojo  verde
[7,] azul  verde azul
[8,] azul  verde rojo
[9,] azul  verde verde
   [10,] rojo  azul  azul
   [11,] rojo  azul  rojo
   [12,] rojo  azul  verde
   [13,] rojo  rojo  azul
   [14,] rojo  rojo  rojo
   [15,] rojo  rojo  verde
   [16,] rojo  verde azul
   [17,] rojo  verde rojo
   [18,] rojo  verde verde
   [19,] verde azul  azul
   [20,] verde azul  rojo
   [21,] verde azul  verde
   [22,] verde rojo  azul
   [23,] verde rojo  rojo
   [24,] verde rojo  verde
   [25,] verde verde azul
   [26,] verde verde rojo
   [27,] verde verde verde
#Permutaciones *sin repetici�n*
 
permutations(n=3, r=3, v=x, repeats.allowed=FALSE)
[,1][,2][,3]
   [1,] azul  rojo  verde
   [2,] azul  

[R] R Freezes (Mac) using file.choose()

2015-03-22 Thread Vindoggy !
I'm using a mac with OSX Yosemite (10.10.2), running the latest version of R 
(3.1.3). But I've been having this same issue since Mavericks came out, using 
all of  the different versions of R that have come out since Mavericks.

Often (approximately 15% of the time I would say), whenever I use a function in 
R that pulls up a mac finder window, R will freeze and I am left with the 
spinning beach ball until I force-quit R. This happens most frequently when 
using file.choose() to open a file, but has happened to me when changing the 
working directory through the Misc tab as well:

Misc- Change Working Directory


This has happened on at least three different Mac machines of varying ages, so 
I don't think this is a computer specific issue. And as much of the scripts I 
have written use file.choose(), this happens on a regular basis.

Have other people run into this same issue? If so, is there a fix for it?
  
[[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] average wind direction calculation

2015-03-22 Thread Alemu Tadesse
Dear All,

I am wondering if you have an R script or know an R package for an average
wind direction

Best,

Alemu

[[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] average wind direction calculation

2015-03-22 Thread David Winsemius

 On Mar 22, 2015, at 9:18 PM, Alemu Tadesse alemu.tade...@gmail.com wrote:
 
 Dear All,
 
 I am wondering if you have an R script or know an R package for an average
 wind direction
 

pkg:circular

 Best,
 
 Alemu
 
   [[alternative HTML version deleted]]

R is a plain text mailing list.
— 

David Winsemius, MD
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.