Hi,
Not sure about your expected result. If you need a logical index as the new
variable:
##check str(Food)
Food[,-1] - lapply(Food[,-1],function(x) as.numeric(as.character(x)))
str(Food)
Food1 - within(Food,Healthy.food - GRASSI 20)
HFood - Food1[Food1$Healthy.food,-7]
dim(HFood)
#[1]
On 10/24/2011 12:35 AM, Philipp Fischer wrote:
Hello,
I am just starting with R and I am having a (most probably) stupid problem by
creating a new variable in a data.frame based on a part of another character
variable.
I have a data frame like this one:
A B
Hi
If you want to get rid of regular expressions at all and your A values
start AWI for Arctic and UFT for boreal you can
DF$D - ifelse(substr(DF$A, 1,1) == A, Arctic, Boreal)
Regards
Petr
Hello,
I am just starting with R and I am having a (most probably) stupid
problem
by creating a
... Well, this works in this simple case, but is too clumsy for a general
formulation of this problem: given a dictionary consisting of two
character vectors of unique names (or two columns in a data frame), x and
y, how does one convert a factor z with levels in x into the corresponding
Hi Bert
I am aware of factor features and frankly speaking I consider them quite
usefull despite of prevalent preference to character vectors. For the OP
question seems to me that ifelse construction is appropriate, based on his
statement he has 2 strings which shall be converted to another
Hello,
I am just starting with R and I am having a (most probably) stupid problem by
creating a new variable in a data.frame based on a part of another character
variable.
I have a data frame like this one:
A B C
AWI-test1 1 i
AWI-test5
Use regular expressions
?grepl
On Sunday, October 23, 2011, Philipp Fischer philipp.fisc...@awi.de wrote:
Hello,
I am just starting with R and I am having a (most probably) stupid problem
by creating a new variable in a data.frame based on a part of another
character variable.
I have a data
7 matches
Mail list logo