Hi,
I have a dataframe. Dataframe contains 4 columns. Now I want to add 2 columns at the end of another 2 columns. So, my final dataframe must contain only 2 columns.
Dataframe looks like
id name parent_key ingredients
1 H00607 Nafcillin H00091 Cyclosporine
2 H01059 Norfloxacin H00091 Cyclosporine
3 H09128 Brexpiprazole H00091 Cyclosporine
4 H09039 Eliglustat H00091 Cyclosporine
I am writing this code
id_name <- data.frame(id = c(all_data[,"id"], all_data[,"parent_key"]),
name = c(all_data[,"name"], all_data[,"ingredients"]))
My code is converting 4 columns into 2 columns. But, it is also converting cell values
into integer
format! The output of my code is
id name
1 240 565
2 467 600
3 804 99
4 775 273
5 646 336
6 792 436
7 739 437
Could you tell me, why this is happening and how can I solve this issue?
My expected output is like
id name
1 H00607 Nafcillin
2 H01059 Norfloxacin
3 H09128 Brexpiprazole
4 H09039 Eliglustat
5 H00091 Cyclosporine
6 H00091 Cyclosporine
7 H00091 Cyclosporine
8 H00091 Cyclosporine