[R] Proper Paste for Data Member

David Winsemius dwinsemius at comcast.net
Tue Jul 14 20:39:14 CEST 2009


On Jul 14, 2009, at 2:19 PM, David Winsemius wrote:

>
> On Jul 14, 2009, at 2:02 PM, Idgarad wrote:
>
>> I imported a spreadsheet into a variable sh
>>
>> e.g. sh$aaaa, sh$bbbb, etc...
>>
>> doing the following:
>>
>> tsSource <- ts(paste("sh$",NAMEVARIABLE,sep="") ... )
>
> From prior experience, my guess is that you want collapse= rather  
> than sep=

The obvious error of using the wrong parameter caught my eye first,  
but you may be going about this entirely wrong. Do you want to  
reference the entire dataframe? What is the structure of NAMEVARIABLE?  
Did you create it somehow.
>
>>
>> fails. The paste isn't evaluating properly. What is the proper way to
>> concatenate a data source with a member name such that they evaluate
>> properly.
>>
>> actual code below:
>> doEnv <- function(SOURCEDATA,REGDATA,HOUR,ENVNAME,REPORTNAME) {
>> print(SOURCEDATA)
>> print(REGDATA)
>> print(HOUR)
>> print(ENVNAME)
>> print(REPORTNAME)
>> # blah blah blah ...
>>
>> #Raw Data
>> channel1 <- odbcConnectExcel("Q:/metrics.xls")
>> sqlTables(channel1)
>> sh1 <- sqlFetch(channel1, "Actuals$")
>> close(channel1)

So at this point, what do you get with:

str(sh)

>>
>> # Something here is borked like the Chef himself....
>> tsSource<-ts(paste("sh1$",ENVNAME,sep=""),start=c(2004,1),freq=52)

And what are you trying to achieve?

>> print(tsSource)
>> plot(tsSource,col="grey",type="n")
>> return("AUTOBOT") # I use AUTOBOT or DECEPTICON for generic pass  
>> fail return
>> values. Yes I am a geek...
>> }
>>
>> 	[[alternative HTML version deleted]]
>>
>> ______________________________________________

David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list