Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8384961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:32:45+00:00 2026-06-09T17:32:45+00:00

I just started using the R package called RMySQL in order to get around

  • 0

I just started using the R package called RMySQL in order to get around some memory limitations on my computer. I am trying to take a matrix with 100 columns in R (called data.df), then make a new table on an SQL database that has "100 choose 2" (=4950) columns, where each column is a linear combination of two columns from the initial matrix. So far I have something like this:

countnumber <- 1
con <- dbConnect(MySQL(), user = "root", password = "password", dbname = "myDB")
temp <- as.data.frame(data.df[,1] - data.df[,2])
colnames(temp) <- paste(pairs[[countnumber]][1], pairs[[countnumber]][2], sep = "")
dbWriteTable(con, "spreadtable", temp, row.names=T, overwrite = T)

for(i in 1:(n-1)){
for(j in (i+1):n){
    if(!((i==1)&&(j==2))){     #this part excludes the first iteration already taken care of
        temp <- as.data.frame(data.df[,i] - data.df[,j])
        colnames(temp) <- "hola"
        dbWriteTable(con, "spreadtable", value = temp, append = TRUE, overwrite = FALSE, row.names = FALSE)
        countnumber <- countnumber + 1
            }
        }
}

I’ve also tried toying around with the "field.types" argument of RMySQL::dbWriteTable(), which was suggested at RMySQL dbWriteTable with field.types. Sadly it hasn’t helped me out too much.

Questions:

  1. Is making your own sql database a valid solution to the memory-bound nature of R, even if it has 4950 columns?
  2. Is the dbWriteTable() the proper function to be using here?
  3. Assuming the answer is "yes" to both of the previous questions…why isn’t this working?

Thanks for any help.



[EDIT]: code with error output:

names <- as.data.frame(index)
names <- t(names)
#dim(names) is 1 409
con <- dbConnect(MySQL(), user = "root", password = "password", dbname = "taylordatabase")


dbGetQuery(con, dbBuildTableDefinition(MySQL(), name="spreadtable", obj=names, row.names = F))
#I would prefer these to be double types with 8 decimal spaces instead of text
#dim(temp) is 1 409
temp <- as.data.frame(data.df[,1] - (ratios[countnumber]*data.df[,2]))
temp <- t(temp)
temp <- as.data.frame(temp)
dbWriteTable(con, name = "spreadtable", temp, append = T)

The table is created successfully in the database (I will change variable type later), but the dbWriteTable() line produces the error:

Error in mysqlExecStatement(conn, statement, ...) : 
RS-DBI driver: (could not run statement: Unknown column 'row_names' in 'field list')
[1] FALSE
Warning message:
In mysqlWriteTable(conn, name, value, ...) : could not load data into table

If I make a slight change, I get a different error message:

dbWriteTable(con, name = "spreadtable", temp, append = T, row.names = F)

and

Error in mysqlExecStatement(conn, statement, ...) : 
RS-DBI driver: (could not run statement: Unknown column 'X2011_01_03' in 'field list')
[1] FALSE
Warning message:
In mysqlWriteTable(conn, name, value, ...) : could not load data into table

I just want to use "names" as a bunch of column labels. They were initially dates. The actual data I would like to be "temp."

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T17:32:47+00:00Added an answer on June 9, 2026 at 5:32 pm

    Having a query with 4950 rows is ok, the problem is that what columns you need.

    If you always “select * “, you will eventually exhaust all you system memory (in the case that the table has 100 columns)

    Why not give us some error message if you have encountered any problems ?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just started trying to visualize my data by using the ggplot2 package in
I just started using/learning Python and have some questions. I have a text file
I've just started using maven for trying to build a multi module project. Everything
Just started to play around with node.js, have some past experience with JavaScript but
I've been messing around with this for some time. I recently started using the
I just started using virtualenv in python. I'm installing several package(?) using pip on
I'm a Python beginner and have just started using packages. When you're calling a
I just started using Twitter Bootstrap http://twitter.github.com/bootstrap/scaffolding.html and I'm looking for the grey/blue navbar
I just started using Eclipse but already I have a small problem. At first
I just started using rapidxml. I 1st create an xml file to read from.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.