[R] Simple loop

2011-05-03 Thread Woida71
Hello everybody,
I am beginning with loops and functions and would be glad to have help in
the following question:
If i have a dataframe like this
Site  Prof  H
1  1 24
1  1 16
1  1 67
1  2 23
1  2 56
1  2 45
2  1 67
2  1 46
And I would like to create a new column that subtracts the minimum of H from
H, but for S1 and P1
only the minimum of the data points falling into this category should be
taken.
So for example the three first numbers of the new column write: 24-16,
16-16, 67-16
the following numbers refering to Site1 and Prof2 write: 23-23, 56-23,
45-23.
I think with two loops one refering to the Site, the other to the Prof, it
should be possible to automatically
create the new column.
Thanks a lot for any help.

--
View this message in context: 
http://r.789695.n4.nabble.com/Simple-loop-tp3492819p3492819.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Creating dataframes

2011-05-13 Thread Woida71
I would like to create a certain number of dataframes out of one dataframe
where each of the dataframes
is related to a factor. This should be possible with a loop or a function,
as is very clumsy to do it manually
when there are quite a lot factors. 

For example having a dataframe called "exmpl":

SiteValue
1   12
1   15  
1   18
1   21  
1   12
1   13
2   15  
2   12
2   58
2   62
2   22
2   65
2   29
3   21
3   55
3   11
3   98

I would like to create 3 dataframes, where  
"exmpl_01" equals:
1   12
1   15  
1   18
1   21  
1   12
1   13

"exmpl_02" equals:
2   15  
2   12
2   58
2   62
2   22
2   65
2   29

"exmpl_03" equals:
3   21
3   55
3   11
3   98

Thanks for any help.
Walter

--
View this message in context: 
http://r.789695.n4.nabble.com/Creating-dataframes-tp3520509p3520509.html
Sent from the R help mailing list archive at Nabble.com.

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