Hello,

Try reading your data with option stringsAsFactors = FALSE. It seems that your strings are being read as factors, which are coded as integers.

DataGoogle1 <- read.csv(file = "DataGoogle2.csv", header = T, stringsAsFactors = FALSE)


Hope this helps,

Rui Barradas

Em 18-08-2014 10:13, Omar André Gonzáles Díaz escreveu:
Hi all, i have this data.frame with 3 columns: "campaña", "visitas",
"compras".

This is the actual data.frame:

  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

And i want to replace all the entries on the "campaña" :

from this: "facebook-Ads1" or this: "faceBOOK-Ads1"--> to this: "FBAds".

These are my steps:

1) I load the CSV file into R:

DataGoogle1 <- read.csv(file = "DataGoogle2.csv", header = T)

2) and then use:

gsub("facebook-Ads1", "FBAds", DataGoogle1)

But the result is not what i'm expecting:

i get:

gsub(pattern = "facebook-Ads1", "FBAds", DataGoogle1)
[1] "c(2, 3, 4, 1, 5, 6, 7, 8, 9)"                "c(524, 487, 258, 8, 224,
147, 87, 863, 145)"
[3] "c(2, 24, 4, 7, 2, 7, 5, 23, 14)"

May you help me to understand why it is not working? Thanks! :D

        [[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.

Reply via email to