PureBytes Links
Trading Reference Links
|
1) Install the R-Math plug-in
2) Run your loop for / define your string, e.g. MyString="a,b,c,d";
3) Prepare this string for correct format in R:
StStr="<DQ>";RplStr=StStr+","+StStr;
MyStr = StStr + StrReplace(MyString,",",RplStr)+StStr;
RMathProcedure("RString<-c("+MyStr+")");
Once in R, you can manipulate this string-array any way you like (see below), and return it, or some element, back to AB.
As I've written in the R-Math manual, and repeated a few times before, if there are things that AFL cannot do, be it this or matrix calc, or whatever, 99% of them can now be achieved via R.
PS
More details, see for example Lam (2007), An Introduction to R:
x <- c("a","b","c")
mychar1 <- "This is a test"
mychar2 <- "This is another test"
charvector <- c("a", "b", "c", "test")
The function nchar returns the length of a character object, for example:
nchar(mychar1)
[1] 15
nchar(charvector)
[1] 1 1 1 4
The function substring returns a substring of a character object. For example:
x <- c("Gose", "Longhow", "David")
substring(x,first=2,last=4)
[1] "ose" "ong" "avi"
The function paste will paste two or more character objects. For example, to create a
character vector with: "number.1", "number.2", ...,"number.10" proceed as follows:
paste("number",1:10, sep=".")
[1] "number.1" "number.2" "number.3" "number.4"
[5] "number.5" "number.6" "number.7" "number.8"
[9] "number.9" "number.10"
The argument sep is used to specify the separating symbol between the two character
objects.
paste("number",1:10, sep="-")
[1] "number-1" "number-2" "number-3" "number-4"
[5] "number-5" "number-6" "number-7" "number-8"
[9] "number-9" "number-10"
Use sep="" for no space between the character objects.
--- In amibroker@xxxxxxxxxxxxxxx, "Conrad Joach" <consolejoker@xxx> wrote:
>
> Looking for something akin to a Split() function that is common in most languages today.
>
> So for a string:
>
> "a,b,c,d"
>
> It would return an array of length 4, with the string "a", "b", "c", "d".
>
> I don't see anything like this in AFL, has anyone written one with the built in string functions that do exist?
>
------------------------------------
**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.
TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com
TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/amibroker/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:amibroker-digest@xxxxxxxxxxxxxxx
mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|