mardi 31 mars 2020

Choose randomly a number from two columns rstudio

I have this data frame and I' trying to create a new column considering the data in the first column and the column called "zero", I've been using sample(), for an interval from (0,df$firstcolumn) but It gaves me a number between 0 and the data in the first column, not one(0) or another (as an example 9).

Initial data frame:

First column: 9,8,16 Zero column: 0,0,0

What I want is something like this:

First column: 9,8,16 Zero column: 0,0,0 New column: 9,0,16

I really appreciate your answers or opinions. Thank you!




Aucun commentaire:

Enregistrer un commentaire