The format is like this.

Plot  species   Value

P1  ACERRUB   3
P2  MAGNVIR    2
P3  ARONARB   2
etc.

imported using x<-read.table(file="filename.txt")

I want to replace a list of values in the 2nd column with another list. For
example, I want to replace ARONARB with PHOTPYR.
list<-read.table(file="originalnames.txt")
replace<-read.table(file="replacementnames.txt")
I tried to use replace in this manner:

newx<-replace(x,list,replace)
however, I get the error message: error in replace, invalid subscript type.

I have tried transforming the above list and modifying the column names
(column 2), but to no avail.  I hope this clarifies a little.  Sorry about
that.




On 7/7/06, Marc Schwartz (via MN) <mschwartz@mn.rr.com> wrote:
>
> On Fri, 2006-07-07 at 11:20 -0400, Wade Wall wrote:
> > Hi all,
> >
> > I have a three columned list that I have imported into R.  The first
> column
> > is a plot (ex. Plot1), the second is a species name (ex ACERRUB) and the
> > third a numeric value.  I want to replace some of the second column
> names
> > with other names (for example replace ACERRUB with ACERDRU).  The
> original
> > and replacement values are in separate lists (not vectors), but I can't
> seem
> > to find the right function to perform this.  The replace function seems
> to
> > only want to work with numbers.
> >
> > Any clues?
> >
> > Wade
>
> Without seeing the code you are using, we can only guess a syntax error
> of some sort.  It works fine using the iris dataset:
>
> > head(iris)
>   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
> 1           5.1         3.5          1.4         0.2  setosa
> 2           4.9         3.0          1.4         0.2  setosa
> 3           4.7         3.2          1.3         0.2  setosa
> 4           4.6         3.1          1.5         0.2  setosa
> 5           5.0         3.6          1.4         0.2  setosa
> 6           5.4         3.9          1.7         0.4  setosa
> 7           4.6         3.4          1.4         0.3  setosa
> 8           5.0         3.4          1.5         0.2  setosa
> 9           4.4         2.9          1.4         0.2  setosa
> 10          4.9         3.1          1.5         0.1  setosa
>
> > iris$Species <- replace(iris$Species, iris$Species == "setosa",
>                          "NewValue")
>
> > head(iris)
>   Sepal.Length Sepal.Width Petal.Length Petal.Width  Species
> 1           5.1         3.5          1.4         0.2 NewValue
> 2           4.9         3.0          1.4         0.2 NewValue
> 3           4.7         3.2          1.3         0.2 NewValue
> 4           4.6         3.1          1.5         0.2 NewValue
> 5           5.0         3.6          1.4         0.2 NewValue
> 6           5.4         3.9          1.7         0.4 NewValue
> 7           4.6         3.4          1.4         0.3 NewValue
> 8           5.0         3.4          1.5         0.2 NewValue
> 9           4.4         2.9          1.4         0.2 NewValue
> 10          4.9         3.1          1.5         0.1 NewValue
>
>
> HTH,
>
> Marc Schwartz
>
>
>

	[[alternative HTML version deleted]]

