[tech-spec] One morsel for another...

  • From: "Vincent C. Fulco" <vfulco@xxxxxxxxxxxxx>
  • To: tech-spec@xxxxxxxxxxxxx
  • Date: Fri, 08 Apr 2005 15:21:26 -0400

Been trying to construct a list of tickers to feed into the priceIts function and yes I could just use the c("ticker1", "ticker2") input manually in the download function to gather a group but would prefer to set it up as a list to draw from so I can manipulate the list whenever I want.

using paste() in a number of ways, i can add the comma to the ticker but it always occurs inside the quotes separating each ticker (either before or after the ticker depending on how i set it up) while I am looking to separate each ticker in the vector...

getting this...

# tickerlist.one is matrix of tickers in character format...
    1      2      3      4      5      6      7      8      9     10
 "AIG"    "C" "CSCO"  "FDX"   "GE"   "GM"  "IBM" "INTC"   "IP"  "JNJ"
#
tickerlist.one<-paste(tickerlist.one, sep=",")

[1] "AIG," "C," "CSCO," "FDX," "GE," "GM," "IBM," "INTC," "IP,"
[10] "JNJ," "KO," "MER," "MMM," "MSFT," "PFE," "WMT," "XOM,"


when, of course, i want

"AIG", "C", "CSCO"...

tried a number of different methods & functions, even creating a matrix of commas and trying to mesh the two sets together using matrix addition. Don't laugh...

Anyway, i humbly offer a function that i found while searching in the hopes someone can drop a line of code to push my project forward-

formatC() which can do a number of things including formatting how much space can be allocated to either side of the data point...Of course, the formatting is a bit rough since I "pushed" the data to one side or the other of the quotes...anyway, I thought it was an unusual way to manipulate text.

I.E.-

 ticker.list1[,1:10]
     1      2      3      4      5      6      7      8      9     10
 "AIG"    "C" "CSCO"  "FDX"   "GE"   "GM"  "IBM" "INTC"   "IP"  "JNJ"
> formatC(ticker.list1[,1:10], wid=5)

1 2 3 4 5 6 7 8 9 10
" AIG" " C" " CSCO" " FDX" " GE" " GM" " IBM" " INTC" " IP" " JNJ"


> formatC(ticker.list1[,1:10], wid=-5)
1 2 3 4 5 6 7 8 9 10
"AIG " "C " "CSCO " "FDX " "GE " "GM " "IBM " "INTC " "IP " "JNJ "
>


Thanks for your time.

Vince


Other related posts:

  • » [tech-spec] One morsel for another...