[R-es] FUNCION "SI" en R

Javier Marcuzzi javier.ruben.marcuzzi en gmail.com
Vie Abr 21 00:05:07 CEST 2017


Estimado Javier Cantallopts

Lo que escribe Carlos es correcto, pero le envío lo siguiente https://www.tutorialspoint.com/r/r_decision_making.htm porque hay diagramas con if, if anidados y case, tres formas que permiten solucionar ese tipo de problemas (entre otras alternativas).

Javier Ruben Marcuzzi

De: Carlos Ortega
Enviado: jueves, 20 de abril de 2017 18:09
Para: Javier Valdes Cantallopts (DGA)
CC: r-help-es en r-project.org
Asunto: Re: [R-es] FUNCION "SI" en R

Hola,

Esta es una forma:

#---------------

df <- data.frame(
                   a = rnorm(10),
                   b = rnorm(10),
                   c = rnorm(10)
                )

my_nam <- names(df)
my_new_nam <- ifelse(my_nam == "a", "nuevo_a", ifelse(my_nam == "b", "nuevo_b", ifelse( my_nam == "c", "nuevo_c", my_nam )) )
my_new_nam
names(df) <- my_new_nam

#---------------

Saludos,
Carlos Ortega
www.qualityexcellence.es

El 20 de abril de 2017, 22:48, Javier Valdes Cantallopts (DGA) <javier.valdes en mop.gov.cl> escribió:
Hola  a todos
Primero que todo, gracias por todos los consejos, me han servido ene.
 
Mi pregunta es la siguiente:
Como armar una función lógica “SI” PARA CAMBIAR LOS NOMBRES A LOS HEADER 
Por ejemplo, si tengo una tabla así;
a
b
c
d
1
3
4
6
2
4
6
7
 
a= “pluvio mensual”
b= “carga de batería”
c= “temperatura”
d= “radiación”. 
La idea es reemplazar, en el caso que el HEADER sea (a), QUE EL NOMBRE DEL HEADER CAMBIE A “PLUVIO MENSUAL”
 
Se me ocurre DAR UNA INSTRUCCIÓN TIPO COLNAMES<-¿
Espero sus respuestas, saludos.
 
 
 
 

 



CONFIDENCIALIDAD: La información contenida en este mensaje y/o en los archivos adjuntos es de carácter confidencial o privilegiada y está destinada al uso exclusivo del emisor y/o de la persona o entidad a quien va dirigida. Si usted no es el destinatario, cualquier almacenamiento, divulgación, distribución o copia de esta información está estrictamente prohibido y sancionado por la ley. Si recibió este mensaje por error, por favor infórmenos inmediatamente respondiendo este mismo mensaje y borre todos los archivos adjuntos. Gracias.

CONFIDENTIAL NOTE: The information transmitted in this message and/or attachments is confidential and/or privileged and is intented only for use of the person or entity to whom it is addressed. If you are not the intended recipient, any retention, dissemination, distribution or copy of this information is strictly prohibited and sanctioned by law. If you received this message in error, please reply us this same message and delete this message and all attachments. Thank you.




-- 
Saludos,
Carlos Ortega
www.qualityexcellence.es

------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <https://stat.ethz.ch/pipermail/r-help-es/attachments/20170420/e6a190f3/attachment-0001.html>
------------ próxima parte ------------
A non-text attachment was scrubbed...
Name: E56D40881AFE44238A953C043C1C2D22.png
Type: image/png
Size: 148 bytes
Desc: no disponible
URL: <https://stat.ethz.ch/pipermail/r-help-es/attachments/20170420/e6a190f3/attachment-0002.png>
------------ próxima parte ------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 33786 bytes
Desc: no disponible
URL: <https://stat.ethz.ch/pipermail/r-help-es/attachments/20170420/e6a190f3/attachment-0003.png>


Más información sobre la lista de distribución R-help-es