First time in the forums, but basically i've been looking for a way to merge or create a new dataframe while doing a loop to look up for specific words.
Libraries used:
data.table
tidyverse
datasets
readxl
Below is an example of the data im using and what im trying to do:
This is the main dataframe from which im trying to do a "VLookUp"
Numbers_and_Text
1 流動資産
2 商品 1,115,181
3 流動資産合計 2,899,233
4 建物及び構築物(純額 ※1、※2 427,281
5 機械装置及び運搬具(純額 ※1 77,015
6 工具、器具及び備品(純額 ※1 11,897
Into the second dataframe which is acting as a dictionary:
A tibble: 6 x 3
日本語 English Espanol
1 投資活動によるキャッシュ・フロー Cash Flow from investing activities Flujos de caja de las acti~
2 財務活動によるキャッシュ・フロ Cash Flows from financing activities Flujos de caja de las acti~
3 営業活動によるキャッシュ・フロ Cash Flows from operating activities Flujos de efectivo por act~
4 出資金 Capital Capital
5 長期借入金の返済による支出 Repayment of Long term debt Reembolso de la deuda a la~
6 有形固定資産の取得による支出 Payments for purchase of property, plant and equipment Pagos por compra de propie~
The purpose of the second dataframe is to act as a dictionary, then look through the dictionary on to the first dataframe to then extract only the words im looking for into a new dataframe.
Select only the languages I want to use in the dictionary
jp <- language %>% select(日本語)
en <- language %>% select(English)
txt_joint1 <- merge(data, jp, by.x = "Numbers_and_Text", by.y = "日本語")
view(txt_joint1)
Doing this only gets me certain words and not all the words in the dictionary.
I've tried using the "str_replace_all" and putting all the words into a vector but its not working.
Is this the correct way to basically do a VLookUp from two dataframes and then putting the results into a new one? Is doing a loop a better and more efficient way?
Thanks and hope someone can help me with this.