R functions that output datasets -


I'm a new one for R and trying to use a function to output dataframe. I have several dataframes that require deduplication. In each data frame in the data frame, there is an index variable and a patient ID (PattID) in each record. If patients have been listed several times in the dataframe, then I want to select the largest record of the record.

I want to be able to change this data frame:

  Patid RecID 1 1 2 2 3 3 4 3 5 6 6   

In this dataframe, you can use the following code to successfully deploy the dataframe:

  PatID RecID 1 2 3 3 5 6 6   

I am

  df < - df [command (df $ patid, -df $ recID),] df & lt; - DF [! Duplicate (DF $ PattID),]   

I have created a function with this code, so I can easily apply my deduplication plan to multiple data frames.

  dedupit & lt; - Function (x) {x & lt; -x [order (x $ Patid, -x $ RecID),] x & lt; - x [! Duplicate (x $ PatID),]}   

However, when I keep using the code dedupit (df) , then it is a new one with a duplicated record DF does not create dataframe. None of the final dataframe or intermediate dataframes produce what method of output dataframe is there any way?

You'll end up with a return (x) of your function.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -