I want to update specific rows in a CSV file that has dates with a data frame that I created in R.
01/04/20, Asset, Position, Price, Mark-to-Market
0, PORTFOLIO, NA, NA, 1000000
1, CASH, NA, NA, 1000000
02/04/20, Asset, Position, Price, Mark-to-Market, Position prior, Transaction, TC spent
0, PORTFOLIO, NA, NA, 999231, NA, NA, NA
1, CASH, NA, NA, 509866, NA, NA, NA
2, FUTURES, 500, 2516, 1258250, 0, 500, 629
3, VXc1, -5931, 47, -279795, 0, -5931, 140
, Total, Buys:, 1, Sells:, 1, TC spent:, 769
There are approximately 1000+ rows.
However, I am unable to read this CSV file using the following codes. Can anyone help me with this?
df4 <- read.csv("filename.csv")
Further, I have to add two columns (2 and 3) from df3 mentioned below in the rows of df4 that have dates (except the first row). Can anyone help me with this as well?
The code to get df3 is as follows. However, I don't know how to add the rows to df4 selectively in R.
df1 <- read.csv("filename1.csv")
df2 <- read.csv("filename2.csv")
df3 <- cbind(df2[,c(1)], df1[,c(3)], df2[,c(3)])