Re: [R] factor analysis of dynamic structure (FADS) for a huge time-series data

2021-05-08 Thread Ranjan Maitra
I am an author of the paper behind the fad package. I suspect that the call is 
not correct. Actually, fad does not quite account for time series or other 
structured data and you have to enter it, as in all general EFA packages as a n 
x p matrix, with n the number of observations and p the number of coordinates.
 
So, if you can provide a reproducible example, I can look into it, or you can 
also file an issue on the github site.
 
One thing to note that EFA requires all variances in the dispersion matrix to 
be positive, and it is possible that your images have some background where 
there is no activity and hence the sd for those pixel/voxels are zero. 

Of course, ideally, your EFA should account for the image structure, but that 
is a different topic and not part of fad or any similar package.

Ranjan

PS: I monitor this e-mail address only through this list.
 

 
 
 

Sent: Saturday, May 08, 2021 at 5:05 AM
From: "Hyun Soo Park" 
To: "r-help@r-project.org" 
Subject: [R] factor analysis of dynamic structure (FADS) for a huge time-series 
data
Dear R users,

I want to find the latent factors from a kind of time-series data
describing temporal changes of concentration using a factor analysis
technique called 'factor analysis of dynamic structure (FADS).' I learned
how to form the data for the analysis using a proper package embedding
FADS, such as 'fad' package.

The analysis with 'fad' worked and gave me results, but the problem was
raised when the time-series data is vast.

The time-series data extracted from the 3-dimensional matrix (i.e., 3D
image volume of 50 x 50 x 163) repeatedly acquired at 54-time points is
consisted of 50 x 50 x 163 x 54 = 22,005,000 observations. The desired
number of the latent factor (k) is 4. What I got from fad(MATRIX, k) is
following:

Error in fun(A, k, nu, nv, opts, mattype = "matrix") :
TridiagEigen: eigen decomposition failed

When I resize the matrix smaller into 5 x 5 x 15, it gives me what I wanted
properly.

I found that some resampling methods such as random sampling, data
stratification, etc., could resolve this kind of problem, but I have no
ideas which one could be appropriate.

Please teach me with any ideas and comments.

Thanks in advance,

Park

--
*연구중점교수, 분당서울대학교병원*
*전화번호:*
(사무실) +82-31-787-2936
(휴대전화) +82-10-8833-2806
*팩스:* +82-31-787-4018
*이메일:* hy...@snu.ac.kr

*Hyun Soo Park, PhD*
*--*
*Research professor*
Department of Nuclear Medicine
Seoul National University Bundang Hospital, Seongnam, Korea
*Telephone:*
(Office) +82-31-787-2936
(Mobile) +82-10-8833-2806
*Fax:* +82-31-787-4018
*email:* hy...@snu.ac.kr

[[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[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] grep

2021-05-08 Thread Steven Yen

Thank to Rui, Jeff, and Bert. They are all very useful.
Somewhat related is the following, in which jindex is a numeric or 
alphanumeric vector in a function that starts with


try<-function(, jindex=NA)

In the if loop, in the first line I am trying to determine whether the 
vector jindex is NA;
In the second line, I am trying to determine whether elements in vector 
jindex is are all non-numeric.


Not sure how so I tried to judge by the first element of jindex. Any 
better way? Thannks.


  if (!is.na(jindex[1])){   # like to improve this line
    if(!is.numeric(jindex)[1]){ # like to improve this line
  words  <-jindex
  pattern<-paste(words,collapse="|")
  jindex <-grep(pattern=pattern,x.label,value=FALSE)
    }
    jj<-jindex; x.label<-x.label[jj]
  }

On 2021/5/9 上午 03:02, Rui Barradas wrote:

Hello,

The pattern can be assembled with paste(., collapse = "|").
With the same vector of names, nms:


words <- c("black","conserv")
pattern <- paste(words, collapse = "|")
grep(pattern = pattern, nms, value = TRUE)
#[1] "x1.black"   "x1.conserv" "x2.black"   "x2.conserv"


Hope this helps,

Rui Barradas

Às 18:20 de 08/05/21, Jeff Newmiller escreveu:
Regular expression patterns are not vectorized... only the data to be 
searched are. Use one of the many websites dedicated to tutoring 
regular expressions to learn how they work. (Using function names 
like "names" as data names is bad practice.)


nms <- c( "x1.one", "x1.black", "x1.othrrace", "x1.moddkna", 
"x1.conserv", "x1.nstrprty", "x1.strrep", "x1.sevngprt", "x2.one", 
"x2.black", "x2.othrrace", "x2.moddkna", "x2.conserv", "x2.nstrprty", 
"x2.strrep", "x2.sevngprt" )


grep( "black|conserv", nms, value = TRUE )

On May 8, 2021 10:00:12 AM PDT, Steven Yen  wrote:

Below, the first command simply creates a list of 16 names (labels)
which can be ignore.

In the 2nd and 3rd commands, I am able to identify names containing
"black".

In line 4, I am trying to identify names containing "black" or
"conserv"
but obviously it does not work. Can someone help? Thanks.


names<-names(tp.nohs$estimate)[c(1:8,58:65)]; names

  [1] "x1.one"  "x1.black"    "x1.othrrace" "x1.moddkna"
"x1.conserv"  "x1.nstrprty"
  [7] "x1.strrep"   "x1.sevngprt" "x2.one"  "x2.black" 
"x2.othrrace"


"x2.moddkna"
[13] "x2.conserv"  "x2.nstrprty" "x2.strrep"   "x2.sevngprt"

grep("black",names,value=TRUE)

[1] "x1.black" "x2.black"

grep("black",names,value=FALSE)

[1]  2 10

grep(c("black","conserv"),names,value=TRUE)

[1] "x1.black" "x2.black"
Warning message:
In grep(c("black", "conserv"), names, value = TRUE) :
   argument 'pattern' has length > 1 and only the first element will be
used

__
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] factor analysis of dynamic structure (FADS) for a huge time-series data

2021-05-08 Thread Jeff Newmiller
This not being a question about R, but rather about statistics, or possibly 
about a contributed package, means (per the Posting Guide) that you should be 
asking in a statistics forum like stats.stackexchange.com or corresponding with 
the author of the package in question. If you are lucky someone here will have 
something to offer, but it is not very likely.

On May 8, 2021 3:05:12 AM PDT, Hyun Soo Park  wrote:
>Dear R users,
>
>I want to find the latent factors from a kind of time-series data
>describing temporal changes of concentration using a factor analysis
>technique called 'factor analysis of dynamic structure (FADS).' I
>learned
>how to form the data for the analysis using a proper package embedding
>FADS, such as 'fad' package.
>
>The analysis with 'fad' worked and gave me results, but the problem was
>raised when the time-series data is vast.
>
>The time-series data extracted from the 3-dimensional matrix (i.e., 3D
>image volume of 50 x 50 x 163) repeatedly acquired at 54-time points is
>consisted of 50 x 50 x 163 x 54 = 22,005,000 observations. The desired
>number of the latent factor (k) is 4. What I got from fad(MATRIX, k) is
>following:
>
>Error in fun(A, k, nu, nv, opts, mattype = "matrix") :
>  TridiagEigen: eigen decomposition failed
>
>When I resize the matrix smaller into 5 x 5 x 15, it gives me what I
>wanted
>properly.
>
>I found that some resampling methods such as random sampling, data
>stratification, etc., could resolve this kind of problem, but I have no
>ideas which one could be appropriate.
>
>Please teach me with any ideas and comments.
>
>Thanks in advance,
>
>Park

-- 
Sent from my phone. Please excuse my brevity.

__
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] Reemplazar con NAs en la columna "esc" condicionado a lo que sucede en otra columna

2021-05-08 Thread Eric Concha M.
Gracias Javier.

Sólo para aclarar el punto, lo que quiero decir con "autodidacta" es
que yo, por falta de tiempo, aprendo lo que necesito aprender y no he
hecho un barrido sistemático acerca de los fundamentos de R, pues
apenas me alcanza el tiempo para resolver los problemas operativos que
se presentan en mi trabajo. En cambio, creo si hubiera tomado algunos
cursos probablemente no me habría equivocado con lo de NA :) ... En mis
vacaciones me daré el tiempo para tomar varios cursos ya que ocurrirán
encerrado en cuarentena jaj.

Voy a mirar mis objetos con str().

Saludos y gracias !!

Eric.





On Sat, 8 May 2021 11:19:59 -0300
Javier Marcuzzi  wrote:

> Estimado Eric Concha
> 
> Cuidado con su razonamiento, ser autodidacta no es malo, ya hace mucho
> tiempo yo comencé con R, versión 1 y algo, sin persona que me pueda
> explicar algo, por otro lado, NA no es una cadena, la cadena tiene
> valor, el NA es nulo, no hay nada y se especifica que con NA, una
> forma de estar seguro es realizar str(datos), y mirar los resultados
> de esta función, ahí uno se puede dar cuenta si hay algunos errores
> en los datos..
> 
> Javier Rubén Marcuzzi
> 
> El vie, 7 may 2021 a las 17:58, Eric Concha M.
> () escribió:
> 
> >
> > Muchas gracias Emilio, Luis y Juan ... después de ver las soluciones
> > propouestas le di una mirada a los fundamentos de R y cai en cuenta
> > de que, errónamente, yo creía que para que NA fuera distinto del
> > string "NA" había forzomente que asignarlo con alguna de las
> > funciones de R y al parecer no es así jaj ... eso es lo que
> > pasa por ser autodidacta XD
> >
> > Bueno, problema resuelto, muchas gracias !!
> >
> > Eric.
> >
> >
> >
> >
> >
> > On Fri, 7 May 2021 08:42:01 +0200
> > "Emilio L. Cano"  wrote:
> >
> > > Hola,
> > >
> > > Seguramente puedas imputar esos valores NA en la propia
> > > importación de los datos. Si usas read.table (o alguno de sus
> > > wrappers como read.csv), el argumento na.strings hará el trabajo.
> > > Las funciones que importan desde otros archivos como excel tienen
> > > opciones similares.
> > >
> > > Un saludo,
> > >
> > > Emilio L. Cano
> > > http://emilio.lcano.com
> > >
> > >
> > >
> > >
> > > > El 7 may 2021, a las 0:41, Eric Concha M.
> > > >  escribió:
> > > >
> > > >
> > > > Hola comunidad, una consulta por favor, de un problema que no
> > > > puedo resolver ... tengo que asignar NA (missing data) a la
> > > > columna "esc" cuando el valor de "b2c" sea 99 ... cómo lo puedo
> > > > hacer en un único paso ? he probado con las funciones:
> > > >
> > > > is.na()
> > > > na_if(x, y)
> > > > replace_with_na()
> > > >
> > > > pero esas funciones siempre reemplazan en la misma columna que
> > > > establece la condición, me explico ? Aquí un set de datos de
> > > > ejemplo.
> > > >
> > > >
> > > >  folio b2c b2n a16 a19a22   a23 esc
> > > >  1: 112721  99  99   1  27 Sin pareja Pueblo originario
> > > >  2: 112741   1  99   1  24 Sin pareja Pueblo originario
> > > >  3: 115861  99  99   1  40 Con parejaNPANPI
> > > >  4: 116081  99  99   1  23 Con parejaNPANPI
> > > >  5: 123761   7  99   1  25 Con parejaNPANPI
> > > >
> > > >
> > > > Muchas gracias por la orientación !!
> > > >
> > > > Saludos,
> > > >
> > > > Eric.
> > > >
> > > > ___
> > > > 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
> >

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


[R] factor analysis of dynamic structure (FADS) for a huge time-series data

2021-05-08 Thread Hyun Soo Park
Dear R users,

I want to find the latent factors from a kind of time-series data
describing temporal changes of concentration using a factor analysis
technique called 'factor analysis of dynamic structure (FADS).' I learned
how to form the data for the analysis using a proper package embedding
FADS, such as 'fad' package.

The analysis with 'fad' worked and gave me results, but the problem was
raised when the time-series data is vast.

The time-series data extracted from the 3-dimensional matrix (i.e., 3D
image volume of 50 x 50 x 163) repeatedly acquired at 54-time points is
consisted of 50 x 50 x 163 x 54 = 22,005,000 observations. The desired
number of the latent factor (k) is 4. What I got from fad(MATRIX, k) is
following:

Error in fun(A, k, nu, nv, opts, mattype = "matrix") :
  TridiagEigen: eigen decomposition failed

When I resize the matrix smaller into 5 x 5 x 15, it gives me what I wanted
properly.

I found that some resampling methods such as random sampling, data
stratification, etc., could resolve this kind of problem, but I have no
ideas which one could be appropriate.

Please teach me with any ideas and comments.

Thanks in advance,

Park

-- 
*연구중점교수, 분당서울대학교병원*
*전화번호:*
(사무실) +82-31-787-2936
(휴대전화) +82-10-8833-2806
*팩스:* +82-31-787-4018
*이메일:* hy...@snu.ac.kr

*Hyun Soo Park, PhD*
*--*
*Research professor*
Department of Nuclear Medicine
Seoul National University Bundang Hospital, Seongnam, Korea
*Telephone:*
(Office) +82-31-787-2936
(Mobile) +82-10-8833-2806
*Fax:* +82-31-787-4018
*email:* hy...@snu.ac.kr

[[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] grep

2021-05-08 Thread Rui Barradas

Hello,

The pattern can be assembled with paste(., collapse = "|").
With the same vector of names, nms:


words <- c("black","conserv")
pattern <- paste(words, collapse = "|")
grep(pattern = pattern, nms, value = TRUE)
#[1] "x1.black"   "x1.conserv" "x2.black"   "x2.conserv"


Hope this helps,

Rui Barradas

Às 18:20 de 08/05/21, Jeff Newmiller escreveu:

Regular expression patterns are not vectorized... only the data to be searched are. Use 
one of the many websites dedicated to tutoring regular expressions to learn how they 
work. (Using function names like "names" as data names is bad practice.)

nms <- c( "x1.one", "x1.black", "x1.othrrace", "x1.moddkna", "x1.conserv", "x1.nstrprty", "x1.strrep", "x1.sevngprt", "x2.one", "x2.black", 
"x2.othrrace", "x2.moddkna", "x2.conserv", "x2.nstrprty", "x2.strrep", "x2.sevngprt" )

grep( "black|conserv", nms, value = TRUE )

On May 8, 2021 10:00:12 AM PDT, Steven Yen  wrote:

Below, the first command simply creates a list of 16 names (labels)
which can be ignore.

In the 2nd and 3rd commands, I am able to identify names containing
"black".

In line 4, I am trying to identify names containing "black" or
"conserv"
but obviously it does not work. Can someone help? Thanks.


names<-names(tp.nohs$estimate)[c(1:8,58:65)]; names

  [1] "x1.one"  "x1.black"    "x1.othrrace" "x1.moddkna"
"x1.conserv"  "x1.nstrprty"
  [7] "x1.strrep"   "x1.sevngprt" "x2.one"  "x2.black" "x2.othrrace"

"x2.moddkna"
[13] "x2.conserv"  "x2.nstrprty" "x2.strrep"   "x2.sevngprt"

grep("black",names,value=TRUE)

[1] "x1.black" "x2.black"

grep("black",names,value=FALSE)

[1]  2 10

grep(c("black","conserv"),names,value=TRUE)

[1] "x1.black" "x2.black"
Warning message:
In grep(c("black", "conserv"), names, value = TRUE) :
   argument 'pattern' has length > 1 and only the first element will be
used

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

2021-05-08 Thread Jeff Newmiller
Regular expression patterns are not vectorized... only the data to be searched 
are. Use one of the many websites dedicated to tutoring regular expressions to 
learn how they work. (Using function names like "names" as data names is bad 
practice.)

nms <- c( "x1.one", "x1.black", "x1.othrrace", "x1.moddkna", "x1.conserv", 
"x1.nstrprty", "x1.strrep", "x1.sevngprt", "x2.one", "x2.black", "x2.othrrace", 
"x2.moddkna", "x2.conserv", "x2.nstrprty", "x2.strrep", "x2.sevngprt" )

grep( "black|conserv", nms, value = TRUE )

On May 8, 2021 10:00:12 AM PDT, Steven Yen  wrote:
>Below, the first command simply creates a list of 16 names (labels) 
>which can be ignore.
>
>In the 2nd and 3rd commands, I am able to identify names containing
>"black".
>
>In line 4, I am trying to identify names containing "black" or
>"conserv" 
>but obviously it does not work. Can someone help? Thanks.
>
> > names<-names(tp.nohs$estimate)[c(1:8,58:65)]; names
>  [1] "x1.one"  "x1.black"    "x1.othrrace" "x1.moddkna" 
>"x1.conserv"  "x1.nstrprty"
> [7] "x1.strrep"   "x1.sevngprt" "x2.one"  "x2.black" "x2.othrrace"
>
>"x2.moddkna"
>[13] "x2.conserv"  "x2.nstrprty" "x2.strrep"   "x2.sevngprt"
> > grep("black",names,value=TRUE)
>[1] "x1.black" "x2.black"
> > grep("black",names,value=FALSE)
>[1]  2 10
> > grep(c("black","conserv"),names,value=TRUE)
>[1] "x1.black" "x2.black"
>Warning message:
>In grep(c("black", "conserv"), names, value = TRUE) :
>  argument 'pattern' has length > 1 and only the first element will be
>used
>
>__
>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.

-- 
Sent from my phone. Please excuse my brevity.

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

2021-05-08 Thread David Winsemius



On 5/8/21 10:00 AM, Steven Yen wrote:
Below, the first command simply creates a list of 16 names (labels) 
which can be ignore.


In the 2nd and 3rd commands, I am able to identify names containing 
"black".


In line 4, I am trying to identify names containing "black" or 
"conserv" but obviously it does not work. Can someone help? Thanks.


> names<-names(tp.nohs$estimate)[c(1:8,58:65)]; names
 [1] "x1.one"  "x1.black"    "x1.othrrace" "x1.moddkna" 
"x1.conserv"  "x1.nstrprty"
 [7] "x1.strrep"   "x1.sevngprt" "x2.one"  "x2.black" 
"x2.othrrace" "x2.moddkna"

[13] "x2.conserv"  "x2.nstrprty" "x2.strrep"   "x2.sevngprt"
> grep("black",names,value=TRUE)
[1] "x1.black" "x2.black"
> grep("black",names,value=FALSE)
[1]  2 10
> grep(c("black","conserv"),names,value=TRUE)
[1] "x1.black" "x2.black"
Warning message:
In grep(c("black", "conserv"), names, value = TRUE) :
  argument 'pattern' has length > 1 and only the first element will be 
used



Try using the logical OR operator (vertical bar, AKA "pipe")

grep(c("black|conserv"), names, value=TRUE)

--

David.



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

2021-05-08 Thread Steven Yen
Below, the first command simply creates a list of 16 names (labels) 
which can be ignore.


In the 2nd and 3rd commands, I am able to identify names containing "black".

In line 4, I am trying to identify names containing "black" or "conserv" 
but obviously it does not work. Can someone help? Thanks.


> names<-names(tp.nohs$estimate)[c(1:8,58:65)]; names
 [1] "x1.one"  "x1.black"    "x1.othrrace" "x1.moddkna" 
"x1.conserv"  "x1.nstrprty"
 [7] "x1.strrep"   "x1.sevngprt" "x2.one"  "x2.black" "x2.othrrace" 
"x2.moddkna"

[13] "x2.conserv"  "x2.nstrprty" "x2.strrep"   "x2.sevngprt"
> grep("black",names,value=TRUE)
[1] "x1.black" "x2.black"
> grep("black",names,value=FALSE)
[1]  2 10
> grep(c("black","conserv"),names,value=TRUE)
[1] "x1.black" "x2.black"
Warning message:
In grep(c("black", "conserv"), names, value = TRUE) :
  argument 'pattern' has length > 1 and only the first element will be used

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


[R-es] SAS proc genmod con opción repeated

2021-05-08 Thread Griera
Buenas tardes, Lista:

¿Alguien me podría decir que función de R podría substituir al proc
genmod con la opción "repeated subject"?

Muchas gracias y saludos.

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


Re: [R-es] Reemplazar con NAs en la columna "esc" condicionado a lo que sucede en otra columna

2021-05-08 Thread Javier Marcuzzi
Estimado Eric Concha

Cuidado con su razonamiento, ser autodidacta no es malo, ya hace mucho
tiempo yo comencé con R, versión 1 y algo, sin persona que me pueda
explicar algo, por otro lado, NA no es una cadena, la cadena tiene valor,
el NA es nulo, no hay nada y se especifica que con NA, una forma de estar
seguro es realizar str(datos), y mirar los resultados de esta función, ahí
uno se puede dar cuenta si hay algunos errores en los datos..

Javier Rubén Marcuzzi

El vie, 7 may 2021 a las 17:58, Eric Concha M. ()
escribió:

>
> Muchas gracias Emilio, Luis y Juan ... después de ver las soluciones
> propouestas le di una mirada a los fundamentos de R y cai en cuenta de
> que, errónamente, yo creía que para que NA fuera distinto del string
> "NA" había forzomente que asignarlo con alguna de las funciones de R y
> al parecer no es así jaj ... eso es lo que pasa por ser autodidacta
> XD
>
> Bueno, problema resuelto, muchas gracias !!
>
> Eric.
>
>
>
>
>
> On Fri, 7 May 2021 08:42:01 +0200
> "Emilio L. Cano"  wrote:
>
> > Hola,
> >
> > Seguramente puedas imputar esos valores NA en la propia importación
> > de los datos. Si usas read.table (o alguno de sus wrappers como
> > read.csv), el argumento na.strings hará el trabajo. Las funciones que
> > importan desde otros archivos como excel tienen opciones similares.
> >
> > Un saludo,
> >
> > Emilio L. Cano
> > http://emilio.lcano.com
> >
> >
> >
> >
> > > El 7 may 2021, a las 0:41, Eric Concha M.
> > >  escribió:
> > >
> > >
> > > Hola comunidad, una consulta por favor, de un problema que no puedo
> > > resolver ... tengo que asignar NA (missing data) a la columna "esc"
> > > cuando el valor de "b2c" sea 99 ... cómo lo puedo hacer en un único
> > > paso ? he probado con las funciones:
> > >
> > > is.na()
> > > na_if(x, y)
> > > replace_with_na()
> > >
> > > pero esas funciones siempre reemplazan en la misma columna que
> > > establece la condición, me explico ? Aquí un set de datos de
> > > ejemplo.
> > >
> > >
> > >  folio b2c b2n a16 a19a22   a23 esc
> > >  1: 112721  99  99   1  27 Sin pareja Pueblo originario
> > >  2: 112741   1  99   1  24 Sin pareja Pueblo originario
> > >  3: 115861  99  99   1  40 Con parejaNPANPI
> > >  4: 116081  99  99   1  23 Con parejaNPANPI
> > >  5: 123761   7  99   1  25 Con parejaNPANPI
> > >
> > >
> > > Muchas gracias por la orientación !!
> > >
> > > Saludos,
> > >
> > > Eric.
> > >
> > > ___
> > > 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
>

[[alternative HTML version deleted]]

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