[R] help with tapply or other apply

peterko lanikpeter at gmail.com
Sun May 2 12:26:22 CEST 2010


Hi, my data looks this:
  id       forma     program   kod                         obor                  
rocnik
1 10001 kombinovaná  Matematika M1101                   matematika      1
2 10002   prezenční Informatika N1801       teoretická informatika      1
3 10002   prezenční Informatika B1801           obecná informatika      3
4 10003   prezenční Informatika M1801           softwarové systémy      5
5 10004   prezenční Informatika B1801           obecná informatika      2
6 10005 kombinovaná Informatika P1801 diskrétní modely a algoritmy      2
        stav     ukrok
1   zanechal 2002/2003
2    studuje          
3 absolvoval 2008/2009
4 absolvoval 2005/2006
5   zanechal 2007/2008
6   zanechal 2004/2005

data$ukrok is a factor
data$rocnik is numeric

I want to create new column (data$z) and in this column have to be  
as.numeric(first 4 char of column(data$ukrok))-data$rocnik   ---- by the
rows
If ukrok is empty it means 2009.
I know how to do it by cycle FOR , but this is not rigth way. I have too
many observation, and this way is soo slowly.
Know someone how to do it using function TAPPLY ? or another apply function
??? 
-- 
View this message in context: http://r.789695.n4.nabble.com/help-with-tapply-or-other-apply-tp2122683p2122683.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list