Created
December 21, 2017 16:27
-
-
Save chasemc/5cd42c9583b2a56140e676688fc59065 to your computer and use it in GitHub Desktop.
Convert percent values saved as string to double Raw Raw
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Read in data | |
party_ready <- read_csv("Data/party_ready.csv") | |
#Copy data | |
party_time <- party_ready | |
#Get columns with percents | |
columns_with_pct <- grep("pct",colnames(party_time)) | |
#Convert percents as strings to percents as double | |
for (i in columns_with_pct){ | |
party_time[,i]<-as.numeric(sapply(party_time[,i],function(x) gsub("%","",x))) | |
} | |
#variable "party_time" now contains the converted data frame |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment