Hello,

Your function works,

> sapply(1:12, Jahreszeit)

[1] "Winter" "Winter" "Fruehling" "Fruehling" "Fruehling" "Sommer"

[7] "Sommer" "Sommer" "Herbst" "Herbst" "Herbst" "Winter"

but not with your data? We don't know what your data looks like. Post an

example using ?dput

dput( head(dat, 30) ) # paste the output of this in a post

Hope this helps,

Rui Barradas

Em 16-10-2012 10:26, bambus escreveu:

> hey

> I'd like to divide my data into four seasons. for this I made a function:

>

> Jahreszeit <- function(x) {

> if (x<=02 || x==12) {return("Winter")

> }else{

> if (x>=03 && x<=05) {return("Fruehling")

> }else{

> if (x>=06 && x<=08) {return("Sommer")

> }else{

> if (x>=09 && x<=11) {return("Herbst")

> }}}}}

>

> Now, I have some trouble to apply this function.

> I tried lapply(), sapply() and tapply() but everytime i get for every month

> just "Winter". which isn't right.

> Does someone now an explanation?

> if i try it with some random vector it does work but not with my data.

> Please, I need help...has anyone an idea? thx

>

>

>

>

>

> --

> View this message in context:

http://r.789695.n4.nabble.com/data-dividing-tp4646314.html> Sent from the R help mailing list archive at Nabble.com.

>

> ______________________________________________

>

[hidden email] 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.

______________________________________________

[hidden email] mailing list

https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide

http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.