[R] Odp: data frame titles

Petr PIKAL petr.pikal at precheza.cz
Wed Jun 4 13:11:47 CEST 2008


Hi

r-help-bounces at r-project.org napsal dne 04.06.2008 10:57:26:

> I'm new to R so please forgive the newbie question; but i can't seem to 
> find a definitive answer to this.
> 
> I am wanting to do a PLS regression on some data. Which takes a formula 
> of the type
> "responseACC ~ dataACC"
> 
> where dataACC is multivariate in nature and responseACC is a single 
value.

Really? From which package? AFAIK in package pls you have to enter formula
plsr(response~terms, data.frame)

> 
> I have imported my data from a csv file into a dataframe called for 
> arguments sake df.
> This file has no headers in it so I get column names X1.....X83
> 
> I then create a new data frame which says
> data.frame(dataACC = df[1:82], responseACC = df[83])

You probably want
data.frame(dataACC = df[,1:82], responseACC = df[,83])

> 
> When I look at the names of this though I get...
> 
> dataACC.X1 ..... dataACC.X82 and then X83
> 
> When I pass this to the PLS algorithm I get the error
> 
> "variable responseACC not found"
> 
> So a few questions, Am I doing this in the right way in general? why is 
> the responseACC not being associated as the name of df[83]?
> 
> Thirdly, If I want to generate my own array of values in order to do get 

> a predicted response based on my initial PLS regression, will it matter 
> that the array data will not have header values (eg dataACC.X1 etc)? if 
> so what the best way of appending the header data?

see ?names

Regards
Petr

> 
> Thanks for any help you can lend
> 
> Chris
> 
> ______________________________________________
> 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.



More information about the R-help mailing list