Hello,

Sorry, that should be


T <- function(x){
        ifelse(x > = 1, "Combustion", "Petroleum")
}



Rui Barradas

Em 29-07-2013 09:32, Rui Barradas escreveu:
Hello,

Try the following.

T <- function(x){
     ifelse(pah1$P > = 1, "Combustion", "Petroleum")
}

T(pah1$P[1:83])


Hope this helps,

Rui Barradas

Em 29-07-2013 06:35, javad bayat escreveu:
Dear R users;
I am MSc student and I want to write my own function, but it cant be
completed. please help me for solve it. here is my code:

pah1$P = (pah1$Fluoranthene/pah1$Pyrene)
T = function(x){
for (i in 1:length(pah1$P))
if (i >= 1)
print("Combustion")
if (i < 1)
print("Petroleum")
}
T(pah1$P[c(1:83),])

I wish that R gives me a column that if value greater or equal to one
give
"Combustion"  and if value is less than one give "Petroleum".
but my function dose not work.
thank you so much for your help.

    [[alternative HTML version deleted]]

______________________________________________
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.

______________________________________________
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.

Reply via email to