Hello, For not too regular users of R, preparing the data is somehow a burden. Comming from iMacro in FireFox I get a badly designed csv, which I need to put into a daily R script. The data looks like that (e.g.): 22 Results,"35 Results","39 Results","2 Results","7 Results","23 Results","42 Results","36 Results","22 Results","28 Results" and R does this to it: V1 V2 V3 V4 V5 V6 V7 1 ???22 Results 35 Results 39 Results 2 Results 7 Results 23 Results 42 Results V8 V9 V10 1 36 Results 22 Results 28 Results I just need the numbers as a vector. Excel can do it with a few lines of VBA, but there must be a way to do it directly in R, would make things easier. Thanks a lot! jorgusch -- View this message in context: nabble.com/Slicing-cra**y-csv-files-tp24913849p24913849.html Sent from the R help mailing list archive at Nabble.com.
On Tue, 11-Aug-2009 at 01:39AM -0700, jorgusch wrote: |> |> Hello, |> |> For not too regular users of R, preparing the data is somehow a burden. |> |> Comming from iMacro in FireFox I get a badly designed csv, which I need to |> put into a daily R script. |> The data looks like that (e.g.): How did you get from here |> 22 Results,"35 Results","39 Results","2 Results","7 Results","23 |> Results","42 Results","36 Results","22 Results","28 Results" |> |> and R does this to it: to here? |> V1 V2 V3 V4 V5 V6 |> V7 |> 1 ???22 Results 35 Results 39 Results 2 Results 7 Results 23 Results 42 |> Results |> V8 V9 V10 |> 1 36 Results 22 Results 28 Results It's probably easy enough to do but we don't have anything repeatable to use. If I make a csv file from the text string and call it junk.csv, I can get a vector of numbers like this:> as.numeric(gsub("[A-z.]", "", names(read.csv("junk.csv"))))[1] 22 35 39 2 7 23 42 36 221 28>But there's probably more general ways if we knew more about your position. It's likely you could use the clipboard instead of the junk.csv text file. HTH |> |> I just need the numbers as a vector. |> |> Excel can do it with a few lines of VBA, but there must be a way to do it |> directly in R, would make things easier. |> |> Thanks a lot! |> jorgusch |> -- |> View this message in context: nabble.com/Slicing-cra**y-csv-files-tp24913849p24913849.html |> Sent from the R help mailing list archive at Nabble.com. |> |> ______________________________________________ |> R-help at r-project.org mailing list |> stat.ethz.ch/mailman/listinfo/r-help |> PLEASE do read the posting guide R-project.org/posting-guide.html |> and provide commented, minimal, self-contained, reproducible code. -- ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. ___ Patrick Connolly {~._.~} Great minds discuss ideas _( Y )_ Average minds discuss events (:_~*~_:) Small minds discuss people (_)-(_) ..... Eleanor Roosevelt ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
There was a couple of strange characters in the post so I am not sure that I understand exactly what the data looks like but if you are getting a vector of results that look like "22 Results","35 Results","39 Results","2 Results","7 Results","23 Results", "42 Results","36 Results","22 Results","28 Results" Then I think that something like this will work where x is your data. x <- c("22 Results","35 Results","39 Results","2 Results","7 Results","23 Results", "42 Results","36 Results","22 Results","28 Results") x1 <- strsplit(x, " ") x2 <- as.data.frame(do.call("rbind",x1)) (chiffres <- as.numeric(as.character(x2[,1])) --- On Tue, 8/11/09, jorgusch <hackl.schorsch at web.de> wrote:> From: jorgusch <hackl.schorsch at web.de> > Subject: [R] Slicing cra**y csv files > To: r-help at r-project.org > Received: Tuesday, August 11, 2009, 4:39 AM > > Hello, > > For not too regular users of R, preparing the data is > somehow a burden. > > Comming from iMacro in FireFox I get a badly designed csv, > which I need to > put into a daily R script. > The data looks like that (e.g.): > 22 Results,"35 Results","39 Results","2 Results","7 > Results","23 > Results","42 Results","36 Results","22 Results","28 > Results" > > and R does this to it: > ? ? ? ? ? > ???V1? ? ? > ???V2? ? ? > ???V3? ? ? ? V4? > ? ? ? V5? ? ? > ???V6? ? ? ? > V7 > 1 ???22 Results 35 Results 39 Results 2 Results 7 > Results 23 Results 42 > Results > ? ? ? ? ? V8? ? ? > ???V9? ? ? ? V10 > 1 36 Results 22 Results 28 Results > > I just need the numbers as a vector. > > Excel can do it with a few lines of VBA, but there must be > a way to do it > directly in R, would make things easier. > > Thanks a lot! > jorgusch > -- > View this message in context: nabble.com/Slicing-cra**y-csv-files-tp24913849p24913849.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org > mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide R-project.org/posting-guide.html > and provide commented, minimal, self-contained, > reproducible code. >__________________________________________________________________ Looking for the perfect gift? Give the gift of Flickr! flickr.com/gift