Ask Your Question

Dan-Erik's profile - activity

2019-12-16 11:53:50 +0200 received badge  Popular Question (source)
2019-12-16 11:53:50 +0200 received badge  Notable Question (source)
2019-12-16 11:53:50 +0200 received badge  Famous Question (source)
2016-06-23 00:23:28 +0200 received badge  Famous Question (source)
2015-07-13 08:03:28 +0200 received badge  Famous Question (source)
2015-07-08 20:18:33 +0200 received badge  Notable Question (source)
2015-07-08 20:18:33 +0200 received badge  Popular Question (source)
2015-01-13 18:08:18 +0200 received badge  Popular Question (source)
2015-01-13 18:08:18 +0200 received badge  Notable Question (source)
2014-12-10 14:48:17 +0200 commented answer Cannot allocate memory?

Uh... Sorry, I'm starting to be a bit unsure about this. I mean, I use many different programs and R is the only thing so far that has displayed any errors. But I thought I would try the rstudio you recommended, and during installation it gives the same error: failed to allocate memory. Not sure what it means, but maybe something else went wrong in my last package upgrade... Still, this is also R-related software, so the problems are entirely focused around R.

2014-12-10 14:08:29 +0200 commented answer Cannot allocate memory?

I have updated the original post as per your instructions as far as I could. My example may be a bit lengthy, but it is the thing I know will produce an error with some certainty. I have run smaller snippets of code, but it seems sometimes it works and sometimes it doesn't.

2014-12-10 13:40:22 +0200 commented answer Cannot allocate memory?

In your reproduction attempt you are only trying 1+1. I have no problems running simple code snippets. What causes problems is for example generating a ggplot from a large dataset. I don't know the lower limits, but what definitely doesn't work is a density plot of 16 million row dataset in 3 columns. Many things more simple than this will work fine. (EDIT: For clarification, I did get the error message for the 28 kB package, but after a couple of reboots of sage I have now managed to install it, so I'm not sure where the limit is, if it's something like total allocated memory rather than just memory for a specific operation).

2014-12-10 08:47:19 +0200 asked a question Cannot allocate memory?

I use the sagemath package distributed with Ubuntu. Recently, it was automatically suggested that I update this package, which I did. After that I have had a lot of problems.

I use sage almost exclusively as an R interface. All my problems are with R. After the upgrade, I will frequently get a message like "R Interpreter crashed -- automatically restarting." - except that it never restarts automatically I have to manually restart the entire sage notebook server.

I have also had several messages like R cannot allocate 125 MB memory for an array... Where I have 4 GB RAM so it shouldn't be a problem at all and I could run this code before the upgrade without problem. Just now, I tried to run install.packages() but got the error " system call failed: Cannot allocate memory". This is for a 28 kB package, so I should be able to run it on an old 286 computer for christs sake.

1) Does anyone have any suggestions on how to solve these memory limitations?

2) Alternatively, how can I "downgrade" and get my previous version of sage back? Because in my previous version I had no problems at all.

EDIT: Ubuntu version from /etc/issue = Ubuntu 14.04.1 LTS

Package: sagemath-upstream-binary
Priority: extra
Section: math
Installed-Size: 3102314
Maintainer: Jan Groenewald <>
Architecture: amd64
Version: 6.4.1
Recommends: openssl, build-essential, gfortran, imagemagick, dvipng, texlive, texlive-pictures, icedtea-plugin, bash, python
Suggests: m4, openssh-client, git
Depends: libc6, libexpat1, libfontconfig1, libgcc1, libssl1.0.0, libstdc++6, libgfortran3, libgomp1, libquadmath0
Pre-Depends: dpkg (>= 1.15.6~)
Filename: pool/main/s/sagemath-upstream-binary/sagemath-upstream-binary_6.4.1_amd64.deb
Size: 483102424
MD5sum: 26845d5ae2d46f2f2687693fd7819a7e
SHA1: f06b711ffd514d5d9738925d50bca212f8241f80
SHA256: 6c34bc35af4f7a0c166b3bf9bbe9c68ecfd1f5a2f7b71523abb79a9326ca40be
Description-en: Sage is a free open-source mathematics software system
 Sage is a free open-source mathematics software system licensed under the GPL. It combines the power of many existing open-source packages into a common Python-based interface.
 Mission: Creating a viable free open source alternative to Magma, Maple, Mathematica and Matlab.
 This package is a wrapper around an upstream pre-built binary for Ubuntu 14.04.
Description-md5: 0a4e6e212377f9056703508d29d73269

Example code that produces memory allocation error for me:

# Important notice:
# When running this through Sage, have to divide the code into 3 or more cells, because R interface
# will only accept short code snippets.
# Error will then appear in either first or last cell (creating data frames OR plotting data)

xvar <- c(rnorm(15000000, mean = -1), rnorm(15000000, mean = 1.5))
yvar <- c(rnorm(15000000, mean = 1), rnorm(15000000, mean = 1.5))
zvar <- as.factor(c(rep(1, 15000000), rep(2, 15000000)))
xy <- data.frame(xvar, yvar, zvar)
#placeholder plot - prints nothing at all
empty <- ggplot()+geom_point(aes(1,1), colour="white") +
       plot.background = element_blank(), 
       panel.grid.major = element_blank(), 
       panel.grid.minor = element_blank(), 
       panel.border = element_blank(), 
       panel.background = element_blank(),
       axis.title.x = element_blank(),
       axis.title.y = element_blank(),
       axis.text.x = element_blank(),
       axis.text.y = element_blank(),
       axis.ticks = element_blank()
#scatterplot of x and y variables
scatter <- ggplot(xy,aes(xvar, yvar ...
2014-05-06 06:55:20 +0200 commented question How can I import CSV files in Sagemath Cloud?

The project ID I guess is f933d7f4-4150-4b5c-8863-d68f50460591. Sorry for late reply, I just went back to my native sage installation and forgot about this... I am using Chromium in the Ubuntu linux environment. Specifically Version 33.0.1750.152 Ubuntu 13.10 (256984).

2014-04-16 13:04:49 +0200 answered a question How can I import CSV files in Sagemath Cloud?

This is not an answer, but a workaround. Putting it here just in case no one comes up with a real solution.

Since I own a webserver, I put the file there. Then I can call it from R and import the data. Quite different from using files within the sagemath cloud, but it works to import the data into my cloud worksheet.

data <- read.csv(file="", header=TRUE, sep=';')
2014-04-16 07:56:50 +0200 received badge  Organizer (source)
2014-04-16 07:46:07 +0200 asked a question How can I import CSV files in Sagemath Cloud?

I was trying out Sagemath Cloud. Looks great, good job. But I have a problem because I can't figure out how to import CSV files with data.

I am using R (%default_mode r) to do some basic statistics and stuff in a worksheet. I already have the script working on my local machine, but I wanted to try it in the Cloud too.

What I did was that I drag-and-dropped a couple of CSV files into a project. Seems to work fine; the files appear in the drag-and-drop area, and a progress indicator goes to full and then a green check-mark appears. But after that, the files are not present in the Files section, there is only my worksheet. In the Log section, there is only mention of me opening the worksheet, it says nothing about successfully uploading files. When I try to run an import command in the worksheet, I get "No such file or directory".

The import command I used:

data <- read.csv("filename.csv", header=TRUE, sep=';')


This question has an answer for how to do it in Python. But I am doing it from R, and I reckon the python function os.environ() is not available.


If I go to the terminal line under Files and type "ls -A" I can get a full list of files in my project, but the CSV files that I dragged-and-dropped are not in the list.

2013-05-27 07:55:02 +0200 commented answer Code length limit in cells?

I do like Sage better, but I am also getting into Python coding, so I figure Sage will be a good base for all my needs. My goal is to leave Wolfram Mathematica completely behind me, and go with open source alternatives instead.

2013-05-23 14:37:30 +0200 received badge  Self-Learner (source)
2013-05-23 14:37:30 +0200 received badge  Teacher (source)
2013-05-23 01:54:38 +0200 answered a question Code length limit in cells?

There is no need to change any code, as kcrisman suggested in his answer. The R code always runs, but when the code is longer than 1024 characters R code is run as a script file instead of as a command line, and then Sage fails to detect any output that is generated.

The workaround that I found is to save output from long code snippets into a known file, e.g. "~/temp.png" for plots. Then you can use the next cell to draw a dummy plot, and then write your previously created plot onto the canvas. Since this plot is generated from a shorter code (less than 1024 characters), Sage will be able to detect the output that is generated the second time around. Here is the code I used:

png("~/output.png", width=1800, height=1000)
# do fancy plot stuff here
# <---- I used a second cell from here ---->
x <- readPNG("~/output.png")
png("tmp.png", width=1800, height=1000)
plot(1:2, type="n", axes=F, xlab="", ylab="")
# rasterImage() prints on the plot. The plot goes from x = c(1,2) to y = c(1,2).
# So we tell rasterImage() to print within that x/y (i.e. "1,1,2,2") to keep
# the plot scaled correctly.
rasterImage(x, 1, 1, 2, 2)

You could of course do it like a function or something. But since it only applies on rare occasions when plot arguments are so long that the code length exceeds 1024 characters, I have only done it as a special cell on its own.

2013-05-22 11:56:40 +0200 commented answer Code length limit in cells?

variable_1 <- "a" followed by lots of comments (around 2000 bytes) and then variable_2 <- 2 in the same cell assigns the correct values to both variables. The code is executed by R, and if I use a second cell to print the variables, then I get a correct output. However, anything that produces output (print("a") or plot(1:20)) just terminates without an error message.

2013-05-22 11:50:34 +0200 commented answer Code length limit in cells?

Here's the thing: changing from 1024 to 2048 made it work, once. But then I installed my optional R packages with r.install_packages() in Sage, and after that it stopped working. I'm thinking the r.install_packages() function may have changed the value back to default?

2013-05-22 11:46:48 +0200 commented answer Code length limit in cells?

After `sage -b` with the 2048 change, I was able to run the code in the example above, with a comment twice the size. But the second time I tried, it didn't work any more. I had a look at my code, and it seems like the problem is more complex than I thought. I had cells with 1580 characters total that successfully compiled BEFORE the 2048 change in the code, but those cells didn't produce output, they just stored data in variables. And I am still not able to show my fancy plot with lots of options that is a cell of around 1800 characters. The 1580 character cell with no output compiles fine though, and the variables do contain what they are supposed to be.

2013-05-22 10:55:39 +0200 commented answer Code length limit in cells?

(edited) OK. I am running `sage -b` to rebuild Sage after changing the from 1024 to 2048. I'm not that familiar with R to begin with (trying to learn); could I load an R script from a file instead of changing the underlying code of Sage? If it is possible to load R code as a script from file for long commands such as this; will Sage still detect that a PNG is produced and show it in the interface? My main reason for using R through Sage is that the user interface is superior to anything else in my opinion, but if plot output doesn't show up then that advantage is nullified...

2013-05-22 09:13:26 +0200 received badge  Student (source)
2013-05-22 07:40:42 +0200 received badge  Supporter (source)
2013-05-22 06:43:26 +0200 received badge  Editor (source)
2013-05-22 06:35:47 +0200 asked a question Code length limit in cells?

I have a worksheet that is set to R code. Then I do a bunch of stuff, and at the end I want to produce a nice looking plot. To make the plot look nice, I am setting lots of options, which makes it become a huge block of text.

It seems there is some sort of limit on the length of code that a cell may contain? If I do this:


Then I get no output, no png is produced, nothing at all and no error message either. However, if I do the same, but remove the commented lines (starting with #) then I do get a plot.

For more details, I started out by asking this question on StackExchange also. But I figure this question might belong here instead...

How do I set Sage to accept cells with longer text contents, so I can do my plots with all the options I want?

EDIT (for reproducibility):

It seems the limit is around 1000 characters. The following code can be pasted in a cell, and produces nothing, but if you remove one single character anywhere then you will get a plot output: