Hello
I would like to delete some values at random in a data frame. Does
anyone know how I could do?
With best regards
Caroline
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http:/
Caroline,
You probably want to look at ?sample.
Use sample to choose the rows for deletion then use:
df.new = df[-sampled,]
Sean
On Mar 1, 2005, at 9:04 AM, Caroline TRUNTZER wrote:
Hello
I would like to delete some values at random in a data frame. Does
anyone know how I could do?
With best regard
On Tue, 2005-03-01 at 15:04 +0100, Caroline TRUNTZER wrote:
> Hello
> I would like to delete some values at random in a data frame. Does
> anyone know how I could do?
> With best regards
> Caroline
The basic process is to randomly select row indices from the possible
number of rows. If your data
Caroline TRUNTZER wrote:
Hello
I would like to delete some values at random in a data frame. Does
anyone know how I could do?
What about sample()-ing (if I understand "at random" correctly) a
certain number of values from 1:nrow(data) and using the result as
negative index the data.frame?
Uwe Li
On Tue, 01 Mar 2005 15:04:17 +0100, Caroline TRUNTZER
<[EMAIL PROTECTED]> wrote :
>Hello
>I would like to delete some values at random in a data frame. Does
>anyone know how I could do?
Assuming your data.frame is named df:
To delete index i, use df[-i, ] (i.e. the row selection is the
negative
Best,
Matthias
> -Ursprüngliche Nachricht-
> Von: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Im Auftrag von
> Caroline TRUNTZER
> Gesendet: Dienstag, 01. März 2005 15:04
> An: R-help@stat.math.ethz.ch
> Betreff: [R] Help : delete at random
>
>
> Hello
> I woul
Might be slightly more interesting. If we want to generate values which
are completely missing at random, then we can just simply sample all
available index of a 2-d array.
# simulate data #
set.seed(1) # for reproducibility
m <- matrix( rnorm(12), nr=4, nc=3 )
m
[,1] [,2]