[R] I have a problem with R!!

Jim Lemon jim at bitwrit.com.au
Sun Aug 21 13:30:29 CEST 2011


On 08/21/2011 05:29 AM, nferreri at fceia.unr.edu.ar wrote:
> Dear all
>
> i´m working with a program i´ve made in R (using functions that others
> created)
>
> to run my program i need a sample. if i generate the sample using  for
> example, rnorm(n, mu, sigma) i have no problem
>
> but if i obtain a sample from a column in excel and i copy it, the program
> says that there is a mistake: it says "Error en `[.data.frame`(data,
> indices) : undefined columns selected"
>
> my program is:
>
> d<- read.delim("clipboard", header = T, dec = ",")
> #Para determinar los valores de las componentes del vector de capacidad es
> necesario definir primero las especificaciones y el valor objetivo, T, así
> como el máximo valor admitido para la proporción de producción no
> conforme, a cada lado de los límites de especificaciones#
> # Ingrese ahora el valor del límite inferior de especificaciones#
> LIE<- 13
> # Ingrese ahora el valor del límite superior de especificaciones#
> LSE<- 17
> # Ingrese ahora el valor objetivo#
> T<- 14.5
> # Ingrese ahora el máximo valor admitido para la proporción de producción
> no conforme a cada lado de los límites de especificaciones#
> MA<- 0.00135
> D<- min ((LSE-T), (T-LIE))
> compo1<- function(data, indices)
> {
> d<- data[indices]
> n = length (d)
> desvio<- sd(d)
> y<- rep(1:n)
> y[x<= mean(d)]<- 1
> y[x>mean(d)]<- 0
> RI1<- D/(3*desvio*2*mean(y))
> RI2<- D/(3*desvio*2*(1-mean(y)))
> return (min (RI1, RI2))
> }
> compo2<- function(data, indices)
> {
> d<- data[indices]
> c2<- (abs(mean(d) - T))/D
> return (1-c2)
> }
> compo3<-function(data, indices)
> {
> d<- data[indices]
> n<- length (d)
> y<- rep(1:n)
> y[d<  LIE]<- 1
> y[d>= LIE]<- 0
> INFE<- mean (y);
> y<- rep(1:n)
> y[d>  LSE]<- 1
> y[d<= LSE]<- 0
> SUPE<- mean (y);
> PPI<- (1 - INFE)/(1-MA)
> PPS<- (1 - SUPE)/(1-MA)
> return (min (PPI, PPS))
> }
> save(file = "compo1.RData")
> save(file = "compo2.RData")
> save(file = "compo3.RData")
> compos<- function(data, indices)
> {
> d<- data[indices]
> capacidad<- c(compo1(d), compo2(d), compo3(d))
> return(capacidad)
> }
> save(file = "compos.RData")
> require (boot)
> vectorcapacidad<- boot (d, compos, R = 3000)
>
> ETC. ETC.
>
>
>
> WHEN I START MY PROGRAM WRITING:
> d<- rnorm (n, mu, sigma)
>
> I HAVE NO PROBLEM. BUT WHEN I READ A VECTOR FROM EXCEL, R TELLS ME
> "Error en `[.data.frame`(data, indices) : undefined columns selected"
>
>
> CAN YOU HELP ME???? THANK YOU VERY MUCH!!!!!
>
> NOEMI FERRERI, ROSARIO, ARGENTINA
> SCHOOL OF INDUSTRIAL ENGINEERING
>
Hi Noemi,
Without some sample data, I can only guess, but I would first try saving 
the Excel spreadsheet in CSV format and then reading the data in with 
read.csv. This might solve your problem.

Jim



More information about the R-help mailing list