This project is read-only.

Retrieve R List and convert it to String()

Oct 18, 2012 at 1:42 PM

Hello all,

as my title states, i would like a way of retrieving an R's List, and converting it to String()

I made a function in R that in the end combines everything on a list, so when i call this R's function from Vb.NET i retrieve a List (Generic Vector).

Now, i would like to be able to show the results of the Generic Vector on VB, hence i have to convert the list to String()

How can i do that? i've tried a million things but none works..

The last thing i tried is this: I have a VB.NET function that returns an object()

 "Public Function EstimateEffort(ByVal dblActualEffort() As Double) As Object()
Dim ActualEffort As NumericVector = Rdo.CreateNumericVector(dblActualEffort)

Rdo.Evaluate("source(""" & (strFunctions & "Mean Model\Mean.Model.Function").Replace("\", "\\") & """)")
Rdo.SetSymbol("ActualEffort", ActualEffort)

Dim Result = Rdo.Evaluate("ActualEffortResult <- MeanModelFunction(ActualEffort)")

Return Result.AsVector.ToArray
 End Function"

and i use it like this: "CType(EstimateEffort(EffortArray(i).ToArray), String())"

But it tells me it is unable to convert Object() to String()


What do i do?

Oct 26, 2012 at 11:32 PM


I use VB very little, but it seems you are trying to cast to string(s) something that is not string(s). I do not know the behavior in VB, not even sure in C# as I'd avoid doing this.

If you expect a CharacterVector (i.e. array of strings) why don't you wrap/modify your script to have an R function that already returns a numeric vector or even a character vector? This is after all easier to do than in .NET languages.

hope this helps.

Oct 27, 2012 at 7:56 AM
Edited Oct 27, 2012 at 7:57 AM

Here's the problem with that:

Let's say i have an R Function along the lines of this:


"SomeFunction"<- function(SomeArray, SomeOtherArray)
FirstThing <- abs(SomeArray-SomeOtherArray)/SomeArray

SecondThing <- abs(SomeArray-SomeOtherArray)/SomeOtherArray

ThirdThing <- abs(SomeArray-SomeOtherArray)

FourthThing <- (SomeArray-SomeOtherArray)

FifthThing <- abs(SomeArray-SomeOtherArray)^2

SixthThing <- SomeOtherArray/SomeArray



This "list" command makes R to show a list of strings (not characters). For example it could show:

One    two    three

 1        24      40

52       42      87

28       37      46

Now this is a list of 4 strings, with the first being "One    two    three".

Can i retrieve this list from R and convert it to String() or List (of String) or something similar?