i have dataset in csv separators displayed below.
no_cand";"ds_cargo";"cd_cargo";"nr_cand";"sg_ue";"nr_cnpj";"nr_cnpj_1"; clodoaldo josÉ de ramos";"deputado estadual";"7";"22111";"pb";"08126218000107";"encargos financeiros e taxas bancárias"; i using function read.csv2 options
mydataframe <- read.csv2("filename.csv",header = t, sep=";", quote="\\'", dec=",", stringsasfactors=f, check.names = f, fileencoding="latin1") the code reads in data, quotes.
i have tried delete quotes using
mydataframe[,] <- apply(mydataframe[,], c(1,2), function(x) { gsub("\\'", "", x) }) but doesn't work.
any ideas on how import data getting rid of these quotes?
many thanks.
to delete quotes, use lapply , gsub follows.
mydataframe[] <- lapply(mydataframe, function(x) gsub("\"", "", x)) lapply iterates on columns of data frame , returns list; having mydataframe[] on lhs of assignment, assign results data frame without losing attributes (dimensions, names, etc). also, don't have single quotes ' in data, searching them won't achieve anything.
Comments
Post a Comment