editing import data, strings
If you know all your data should be numeric, you could perhaps try
something like this:
apply(a, 2, function(x) as.numeric(gsub(" ", "", x)))
but it can't be tested without your actual data. (Look at dput() for
the best way to send data by email)
Michael
On Fri, Feb 17, 2012 at 12:24 PM, gaja <gajahorvat at hotmail.com> wrote:
Regards.
I'm a beginner in programing, so I have a basic question for you.
If someone could help me please..
I want to create a function, which will be able to export files from excel.
I tried with
a <- read.csv(file, sep =",", as.is = TRUE, row.names = 1, header = TRUE),
.. but instead of numbers, it gives me strings for example: "299,311".
I can handle this string for example:
b <- "299,311"
as.numeric(gsub(",", "", b))
299311
Now, I?m interested how to inport it from that file,.
I tried with
a <- read.csv(file, sep =",", as.is = TRUE, row.names = 1, header = TRUE)
a <- gsub(",", "", a)
a <- as.numeric(a)
But it doesn't work.
I used search engine on forum, but didn't find any function that I could
help with.
I would be very gratefull if someone could help me.
Gaja
--
View this message in context: http://r.789695.n4.nabble.com/editing-import-data-strings-tp4397899p4397899.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________ R-help at 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.