[R] I have a problem with R!!
David L Carlson
dcarlson at tamu.edu
Mon Aug 22 21:46:51 CEST 2011
When you read Excel data from the Windows clipboard, the delimiter is a tab,
not a comma.
----------------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Petr PIKAL
Sent: Monday, August 22, 2011 3:18 AM
To: nferreri at fceia.unr.edu.ar
Cc: r-help at r-project.org
Subject: Re: [R] I have a problem with R!!
Hi
Your code is rather baroque and it is difficult to see what is exactly
going on without having appropriate data. I does not consider your process
of reading data from Excel problematic.
Maybe the difference is in that
d<- rnorm(whatever)
produces vector while
d<- read.delim("clipboard", header = T, dec = ",")
produces data frame
you can subset vector by
d[indices]
but doing the same with data.frame you try to subset columns which, in
your case should not be what you want.
at least showing us
str(data.readed.from.Excel)
can help us to help you.
Regards
Petr
>
> 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
>
> ______________________________________________
> 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.
______________________________________________
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