I have a csv file containing information on available beds in UK hospitals. The download link for the file is here:
The file is a combination of characters and integers so, with my very limited knowledge of R, It doesn't seem strait-forward for me to use ceiling() or floor() to round up.
The data I want to round up is all of these:
Basically any number which is not whole within this file I want to be made a whole number.
So far all I have done is read the file into R like so:
NHS_Data <- read.csv(file="data.csv", header=TRUE, sep=",")
Which looks like this:
Now I'm afraid I'm stuck - Can anybody help?
Many thanks, George
You have a bit more going on in the CSV
than just rounding up. R dislikes having numbers in the column names and dashes -
. So, it will likely bring them in as "X.2009.10"
or something similar.
You will need to be aware of this.
Based on what you have above you would start as you did:
NHS_Data <- read.csv(file="data.csv", header=TRUE, sep=",")
Then you will identify the column you want to raise or lower and wrap it in ceiling
or floor
like so:
NHS_Data$X.2009.10 <- floor(NHS_Data$X.2009.10)
This tells it to save into the data frame NHS_Data
at the location of the column X.2009.10
each row of X.2009.10
at the largest whole integer below your floating number in the same cell.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.