[R] insert() function

From: Dani Valverde <daniel.valverde_at_uab.cat>
Date: Wed, 20 Feb 2008 11:38:14 +0100


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

spect2 <- insert(spect1,ats=pos,values=intensities)

"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.
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_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.
Received on Wed 20 Feb 2008 - 10:45:04 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 20 Feb 2008 - 12:30:15 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive