On Dec 4, 2009, at 11:55 AM, Allen L wrote:
Dear R forum,
I want to replace all the elements in a data frame (dd) which match
the
character "x" with "0".
What's the most elegant way of doing this (there must be an easy way
which
I've missed)? I settled on the following loop:
for(i in 5:
Here a way of doing it:
for (i in 5:12){
# convert to character so you can substitute 'x'
a <- as.character(dd[,i])
a[a == 'x'] <- '0' replace with zero
dd[,i] <- as.numeric(a)
}
On Fri, Dec 4, 2009 at 11:55 AM, Allen L wrote:
>
> Dear R forum,
> I want to replace all the eleme
Dear R forum,
I want to replace all the elements in a data frame (dd) which match the
character "x" with "0".
What's the most elegant way of doing this (there must be an easy way which
I've missed)? I settled on the following loop:
>for(i in 5:12){# These are the column of dd I am
3 matches
Mail list logo