Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Dividing columns in R

I have the following dataset and I want to divide the "Dose" and "Count" columns by 100 and I want my new dataset to include the "Visit" column as well.
However, using the code below, my new dataset does not have the "Visit" column.
What if I want to divide only the "Dose" column by 100?
I uploaded my dataset into R and called it data.

"data_new=data[,2:ncol(data)]/100"

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The reason you’re not preserving the untouched columns in your new data frame is because you’re only assigning the selected columns on which you’ve applied the vectorized division operation back to what you expect (at least based on how you’re naming it) is a data frame.

data$dose <- data$dose / 100
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading