Hi,
If I understand you well, the problem is that DataGoogle2 is a 1-column
data.frame and this is expected based on your code!
I think you want something like this to change the 1st column of the
data.frame:
DataGoogle2 <- DataGoogle1
DataGoogle2$Campaña <- gsub("facebook-Ads1", "FBAds", DataGoogle2$Campaña)
HTH,
Ivan
--
Ivan Calandra
University of Franche-Comté
Laboratoire Chrono-Environnement
Bureau ATER -107L
16, Route de Gray
25030 Besançon Cedex, France
ivan.calan...@univ-fcomte.fr
+33 (0) 381 66 20 60
http://chrono-environnement.univ-fcomte.fr/spip.php?article1830
Le 19/08/14 11:21, Omar André Gonzáles Díaz a écrit :
Hi all,
please, i'm trying to understand how using "Gsub" for some search and
replace of text, makes my data frame lost it's format.
This is my code:
<code>
DataGoogle1 <- read.csv(file = "DataGoogle2.csv", header = T,
stringsAsFactors = F)
head(DataGoogle1)
</code>
Result 1:
Campaña Visitas Compras
1 facebook-Ads1 524 2
2 faceBOOK-Ads1 487 24
3 fcebook-ads12 258 4
4 Email1 8 7
5 mail1 224 2
6 referral1 147 7
Then i apply the GSUB function like this:
<code> DataGoogle2 <- as.data.frame(gsub("facebook-Ads1", "FBAds",
DataGoogle1$Campaña)) </code>
And the result is:
DataGoogle2
gsub..facebook.Ads1....FBAds...DataGoogle1.Campaña.
1 FBAds
2 faceBOOK-Ads1
3 fcebook-ads12
4 Email1
5 mail1
6 referral1
...
The Search and Replace works, but my data.frame does not. Even if i use:
"as.data.frame" before of the "gsub" function. Please, tell me what can i
do... Cheers!
[[alternative HTML version deleted]]
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.