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.


enter image description here

>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

Leave a Reply