[R] code to run a simulation

2018-07-05 Thread Adam Z. Jabir
Hi Guys, I am doing some imputation for my dataset. I am looking for code to do simulation before choosing the right package (mice, Knn). Does anyone have some code that can do the following: 1. introduce some missing rate into the data 2. Apply the two imputaion methods 3. Compute R

Re: [R] Generate random Bernoulli draws

2018-07-05 Thread Marino David
Dear Bert, I know it is a simple question. But for me, at current, I fail to implement it. So, I ask for help here. It is not homework. Best, David 2018-07-06 13:32 GMT+08:00 Bert Gunter : > Is this homework? > > (There is an informal no-homework policy on this list). > > Cheers, > Bert > > >

Re: [R] Generate random Bernoulli draws

2018-07-05 Thread Bert Gunter
Is this homework? (There is an informal no-homework policy on this list). Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Thu, Jul 5, 2018 at 10

[R] Generate random Bernoulli draws

2018-07-05 Thread Marino David
Dear All, I would like to generate N random Bernoulli draws given a probability function F(x)=1-exp(-2.5*x) in which x follows uniform distribution, say x~U(0,2). Can some one leave me some code lines for implementing this? Thanks in advance. David [[alternative HTML version deleted]]

Re: [R] command to change some vars to missing into my dataset

2018-07-05 Thread Bert Gunter
Jim/Rui: Strictly speaking, this is wrong. What you have described is MCAR -- missing completely at random -- not MAR. They are different! Nevertheless, the OP seems to be similarly confused about this, so MCAR may in fact be what what was wanted. Without further context, it is as clear as mud to

Re: [R] command to change some vars to missing into my dataset

2018-07-05 Thread Jim Lemon
Hi Adam, Looks like you have a matrix or data frame and want to change one or more observations to NA. I think this will do the trick: # assume the matrix or data frame is named "ajdat" randomNA<-function(x,nNA=1) { dimx<-dim(x) x[sample(1:dimx[1],nNA),sample(1:dimx[2],nNA)]<-NA return(x) } So

Re: [R] command to change some vars to missing into my dataset

2018-07-05 Thread Rui Barradas
Hello, What type of data do you have? A vector? Or is it a matrix, a data.frame, a list, etc? Suppose it is a vector named x. Then you could do something like rate <- 0.2 is.na(x) <- sample(length(x), rate*length(x)) At an R prompt type ?is.na ?sample Hope this helps, Rui Barradas Às 21:

Re: [R] "igraph0" package installation

2018-07-05 Thread Sarah Goslee
Hi, According to https://cran.r-project.org/web/packages/igraph0/index.html igraph0 is obsolete. I don't know what package the gspan() function comes from, but most likely you should update that package to the current version. Or, if it's this issue: https://stackoverflow.com/questions/33268708/

[R] "igraph0" package installation

2018-07-05 Thread Maryam R via R-help
Hi, I’m maryam that ask question about "igraph0" package installation in R-help. I thank you for your answering. i used and install “igraph” library in R but i faced with below error when I use this command : results <- gspan(database) Error: Error in library(igraph0) : there is no package ca

[R] command to change some vars to missing into my dataset

2018-07-05 Thread Adam Z. Jabir
Hi, I want to simulate missing at random for my dataset. Do you know an easy way to do it? I want to try not to have the missing�s for the same observations. I mean if one observation is been selected randomly to have missing I don�t want to have all the var of the same obs missing. I want to

Re: [R] "igraph0" package installation

2018-07-05 Thread Loris Bennett
Hi Maryam, Maryam R via R-help writes: > Hi, i want to install 'igraph0' package in R on windows 10. I downloaded > "igraph0_0.5.5-1.tar" from Index of /src/contrib/Archive/igraph0 then i try to > import this package to R with this > command:install.packages("~/R/igraph0_0.5.5-1.tar.gz",type="so

[R] "igraph0" package installation

2018-07-05 Thread Maryam R via R-help
Hi, i want to install 'igraph0' package in R on windows 10. I downloaded "igraph0_0.5.5-1.tar" from Index of /src/contrib/Archive/igraph0 then i try to import this package to R with this command:install.packages("~/R/igraph0_0.5.5-1.tar.gz",type="source",repos=NULL, dependencies=TRUE) | | |