[R] StrSplit
Santosh Srinivas
santosh.srinivas at gmail.com
Sat Oct 9 18:18:18 CEST 2010
Newbie question ...
I am looking something equivalent to read.delim but which accepts a text line as parameter instead of a file input.
Below is my problem, I'm unable to get the exact output which is a simple data frame of the data where the delimiter exists ... coming quite close though
I have a data frame with 10 lines called MF_Data
> MF_Data [1:10]
[1] "Scheme Code;Scheme Name;Net Asset Value;Repurchase Price;Sale Price;Date"
[2] ""
[3] "Open Ended Schemes ( Liquid )"
[4] ""
[5] ""
[6] "AIG Global Investment Group Mutual Fund"
[7] "106506;AIG India Liquid Fund-Institutional Plan-Daily Dividend Option;1001.0000;1001.0000;1001.0000;02-Oct-2010"
[8] "106511;AIG India Liquid Fund-Institutional Plan-Growth Option;1210.4612;1210.4612;1210.4612;02-Oct-2010"
[9] "106507;AIG India Liquid Fund-Institutional Plan-Weekly Dividend Option;1001.8765;1001.8765;1001.8765;02-Oct-2010"
[10] "106503;AIG India Liquid Fund-Retail Plan-DailyDividend Option;1001.0000;1001.0000;1001.0000;02-Oct-2010"
Now for the lines below .. they are delimted by ; ... I am using
tempTxt <- MF_Data[7]
MF_Data_F <- unlist(strsplit(tempTxt,";", fixed = TRUE))
tempTxt <- MF_Data[8]
MF_Data_F1 <- unlist(strsplit(tempTxt,";", fixed = TRUE))
MF_Data_F <- rbind(MF_Data_F,MF_Data_F1)
But MF_Data_F is not a simple 2X6 data frame which is what I want
More information about the R-help
mailing list