I'm trying to create a dataframe by the use of function().
The situation: I have the following dataframe with the information: Code, Subcode & Description. Each code stands for an industry and the subcode for a specific industry inside.
    > head(industries.split)
  Code Subcode                                  Description
1   13      00                                AEROSPACE    
2   13      10    Engines, Components & Parts Manufacturers
3   13      20 Military & Commercial Aircraft Manufacturers
4   13      30        Missile & Missile Parts Manufacturers
5   13      40    Private & Business Aircraft Manufacturers
6   13      50                   Miscellaneous Aerospace   
> tail(industries.split)
    Code Subcode                                     Description
198   85      91                                 Wholesalers    
199   85      92                      Miscellaneous Companies   
200   86      00             REUTERS FUNDAMENTALS-SOURCED DATA  
201   86      10 Industrial/Commercial format; Industry group NA
202   86      20                   Utilities; Industry group NA 
203   86      30                  Bank format; Industry group NA
I want to combine the code with the subcode and exclude the subcode afterwards. For this, I wrote the following function, where name is a placeholder for the industry and code is the industry code.
Industry.Filter <- function(name, code){
  name <- industries.split %>%
    filter(Code == code)
  name[,1] <- paste(name[,1], name[,2],sep = "")
  name <- name[,-2]
}
The code works, but it doesn't store the value in a dataframe.
It only works when I store it seperately in a data frame:
aerospace <- Industry.Filter(aerospace, 13)
How I can use this function with out having aerospace <- in front of the function.
 
     
    