2

is there any way how to create something like data.frame object in R that would point to specific table in MySQL database and would behave like data.frame? I haven't been able to find any mention about it.

As an example, let us say, I have a table called customers and columns names, heights, weights and I would like some function, that would create variable customer and I could access the respective columns in data.frame-like way, i.e. customer$heights, etc.

My problem is that I am working with very large datasets and operating over database is much faster and one might actually hack some descriptive statistics in SQL to be used with such pointer variable, for example sum, average, etc...

Thanks for answer. T.

1 Answer 1

5

Yes, external pointers can do that, and the RODBC package uses it. See the "Writing R Extensions" manual for an introduction to external pointers.

The ff, bigmemory and mmap package may give you ideas about how to make external data appear internal to R. It can be done, but it's not a quick hack for a rainy afternoon.

And in general, one is generally best off doing as much computation 'near the data' as possible. Were you using PostgreSQL, you could try the embedded Pl/R extension for it. To my knowledge, no such extension exists for MySQL.

Sign up to request clarification or add additional context in comments.

1 Comment

+1. I gather your last sentence should be 'no such extension exists for MySQL' though? My pedantic side just keeps reading it over and over.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.