need data to reproduce On Mon, May 27, 2013 at 6:00 AM, <[email protected]>wrote:
> Send R-SIG-Finance mailing list submissions to > [email protected] > > To subscribe or unsubscribe via the World Wide Web, visit > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > or, via email, send a message with subject or body 'help' to > [email protected] > > You can reach the person managing the list at > [email protected] > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of R-SIG-Finance digest..." > > > Today's Topics: > > 1. Extracting numeric data from a mixed data .csv file (dae) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Sun, 26 May 2013 14:53:49 -0700 (PDT) > From: dae <[email protected]> > To: [email protected] > Subject: [R-SIG-Finance] Extracting numeric data from a mixed data > .csv file > Message-ID: <[email protected]> > Content-Type: text/plain; charset=us-ascii > > I have a .csv file that contains 191 columns, some of which are numeric > and others are character data. > > I want to create an xts object, preserving the numerical data. > I am not concerned about saving the character data. > > The date field is a character field in the 3rd column of the the .csv file, > in the format %Y-%m-%d. > > These are the steps I took. I used some different variable names so > I could back up if I didn't get the result I was expecting: > > I am curious to know of other approaches, other than combining some of the > lines, or if there > are problems with this approach. > > ---code--- > > library("quantmod") > x = "mixed_data.csv" > x1.csv = read.csv(x, sep=',', as.is=TRUE) > x.dates = as.POSIXct(x1.csv[,3], format="%Y-%m-%d") > x2.csv = lapply(x1.csv,as.numeric) #generates a list with NAs for all chr > fields > x3.csv = data.frame(x2.csv) > x.zoo = zoo(x3.csv, order.by=x.dates) > x.xts = xts(x.zoo) > > ---end code--- > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/Extracting-numeric-data-from-a-mixed-data-csv-file-tp4668030.html > Sent from the Rmetrics mailing list archive at Nabble.com. > > > > ------------------------------ > > _______________________________________________ > R-SIG-Finance mailing list > [email protected] > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > > > End of R-SIG-Finance Digest, Vol 108, Issue 24 > ********************************************** > [[alternative HTML version deleted]] _______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
