> spect2 <- insert(spect1, ats=pos, values=as.list(intensities)) > str(spect2) num [1:13112] -0.457 -0.457 0.300 1.781 -0.381 ...
/Henrik On Thu, Feb 21, 2008 at 9:26 AM, Henrik Bengtsson <[EMAIL PROTECTED]> wrote: > On Thu, Feb 21, 2008 at 4:30 AM, Dani Valverde <[EMAIL PROTECTED]> wrote: > > Hello, > > > I still having problems with insert() from R.utils package. I provide a > > code with no error: > > > > x <- seq(1:10909) > > x1 <- c(13112-10909) > > spect1 <- rnorm(10909) > > > > interpol <- approx(x,spect1,xout=c(seq(from=1, by=((10909 - 1)/(x1 -1)), > > length.out=x1))) > > pos <- round(interpol$x,0) > > intensities <- interpol$y > > > > str(spect1) > > str(pos) > > str(intensities) > > So what does these output? They are the ones that will give you a > lead to solving your problem, which I think is unrelated to insert(). > > /Henrik > > > > > > > Then, when I call: > > library(R.utils) > > > > spect2 <- insert(spect1,ats=pos,values=intensities) > > > > I have this error: > > > > > > Error in list("insert(spect1, ats = pos, values = intensities)" = > > <environment>, : > > > > [2008-02-21 13:27:49] Exception: Argument 'ats' and argument 'values' > > > > has different lengths: 2203 != 1 > > at throw(Exception(...)) > > at throw.default("Argument 'ats' and argument 'values' has different > > lengths: ", length(ats), " != ", length(values)) > > at throw("Argument 'ats' and argument 'values' has different lengths: > > ", length(ats), " != ", length(values)) > > at insert.default(spect1, ats = pos, values = intensities) > > at insert(spect1, ats = pos, values = intensities) > > > > You see that I still having the error, even calling the str() function > > before insert(). > > Here there is my sessionInfo(): > > > > R version 2.6.2 (2008-02-08) > > i386-pc-mingw32 > > > > locale: > > > LC_COLLATE=Spanish_Spain.1252;LC_CTYPE=Spanish_Spain.1252;LC_MONETARY=Spanish_Spain.1252;LC_NUMERIC=C;LC_TIME=Spanish_Spain.1252 > > > > attached base packages: > > [1] datasets stats graphics grDevices tcltk utils > > methods base > > > > other attached packages: > > [1] R.utils_0.9.8 R.oo_1.4.1 R.methodsS3_1.0.0 > > Hmisc_3.4-3 MASS_7.2-40 scatterplot3d_0.3-25 > > NMRTools_1.0.2 > > [8] svSocket_0.9-5 svIO_0.9-5 R2HTML_1.58 > > svMisc_0.9-5 svIDE_0.9-5 > > > > loaded via a namespace (and not attached): > > [1] cluster_1.11.9 grid_2.6.2 lattice_0.17-6 tools_2.6.2 > > > > Can you help? > > > > Best, > > > > Dani > > > > Daniel Valverde Saubí > > > > Grup de Biologia Molecular de Llevats > > Facultat de Veterinària de la Universitat Autònoma de Barcelona > > Edifici V, Campus UAB > > 08193 Cerdanyola del Vallès- SPAIN > > > > Centro de Investigación Biomédica en Red > > en Bioingeniería, Biomateriales y > > Nanomedicina (CIBER-BBN) > > > > Grup d'Aplicacions Biomèdiques de la RMN > > Facultat de Biociències > > Universitat Autònoma de Barcelona > > Edifici Cs, Campus UAB > > 08193 Cerdanyola del Vallès- SPAIN > > +34 93 5814126 > > > > > > > > En/na Henrik Bengtsson ha escrit: > > > > > > > Hi. > > > > > > On Feb 20, 2008 2:38 AM, Dani Valverde <[EMAIL PROTECTED]> wrote: > > > > > >> Hello, > > >> I am trying to insert a certain number of points into a certain > position > > >> of a vector with this code: > > >> x <- seq(1:10909) > > >> x1 <- c(13112-10909) > > >> spect1 <- rnorm(13112) > > >> interpol <- approx(x,spect1,xout=c(seq(from=1, by=((10909 - 1)/(x1 - > > >> 1)), length.out=x1))) > > >> pos <- round(interpol$x,0) > > >> intensities <- interpol$y > > >> > > > > > > Please provide reproducible code that does not give an error. > > > > > > > > >> spect2 <- insert(spect1,ats=pos,values=intensities) > > >> > > > > > > Is this the famous insert() in R.utils? Please give your > > > sessionInfo() to help others see what you are using. I repeat, please > > > provide us with sessionInfo(). > > > > > > > > >> "interpol" object is the result of interpoling the missing x values > with > > >> respect to spect1. "pos" object is a vector with the indexes where the > > >> values are to be placed (it is the rounded values of interpol$x) and > > >> "intensities" is a vector with the values to be inserted. I try to > > >> insert the values of "intensities" into the positions specified by > "pos" > > >> in the "x" vector using the insert() functions as shown in the code I > > >> paste, but I get this error: > > >> > > >> Error in list("insert(spect1, ats = pos, values = intensities)" = > > >> <environment>, : > > >> > > >> [2008-02-20 11:36:28] Exception: Argument 'ats' and argument 'values' > > >> has different lengths: 2203 != 1 > > >> at throw(Exception(...)) > > >> at throw.default("Argument 'ats' and argument 'values' has different > > >> lengths: ", length(ats), " != ", length(values)) > > >> at throw("Argument 'ats' and argument 'values' has different lengths: > > >> ", length(ats), " != ", length(values)) > > >> at insert.default(spect1, ats = pos, values = intensities) > > >> at insert(spect1, ats = pos, values = intensities) > > >> > > >> Can anyone help me on how can I solve it? I know that "pos" and > > >> "intensities" have the same length, so I don't know why I get this > > >> error. Any ideas will be welcome. > > >> > > > > > > I challenge that claim, because one of the first assertions insert() > > > (of R.utils) does is: > > > > > > if (length(ats) != length(values)) > > > throw("Argument 'ats' and argument 'values' has different > lengths: ", > > > length(ats), " != ", length(values)) > > > > > > Do the following before you call insert() to troubleshoot your data: > > > > > > str(spect1) > > > str(pos) > > > str(intensities) > > > > > > /Henrik > > > > > > > > >> Best, > > >> > > >> Dani > > >> > > >> -- > > >> Daniel Valverde Saubí > > >> > > >> Grup de Biologia Molecular de Llevats > > >> Facultat de Veterinària de la Universitat Autònoma de Barcelona > > >> Edifici V, Campus UAB > > >> 08193 Cerdanyola del Vallès- SPAIN > > >> > > >> Centro de Investigación Biomédica en Red > > >> en Bioingeniería, Biomateriales y > > >> Nanomedicina (CIBER-BBN) > > >> > > >> Grup d'Aplicacions Biomèdiques de la RMN > > >> Facultat de Biociències > > >> Universitat Autònoma de Barcelona > > >> Edifici Cs, Campus UAB > > >> 08193 Cerdanyola del Vallès- SPAIN > > >> +34 93 5814126 > > >> > > >> ______________________________________________ > > >> R-help@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@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.