tag archives: R

fibonacci spiral – logarithmic spiral curve fitting to cactus areoles

[posted: ]  [0 comments]

the fibonacci sequence (0, 0, 1, 2, 3, 5, 8, 13, …) is a very interesting series of numbers which can be found anywhere from aesthetics to nature. for example, facial features which represent fibonacci ratios (or golden ratios) are generally considered beautiful. the shape of a nautilus housing corresponds to quarter circles of fibonacci-increased squares. the fibonacci principle. also, the number of single flowers in a sunflower spiral consists of two consecutive fibonacci numbers.

in my most recent “random curve fitting” experiment, i tried to fit a modified fibonacci spiral, or more generally, a logarithmic curve, to the arrangement of cactus areoles (wikipedia: “small light- to dark-colored bumps, out of which grow clusters of spines”):

fibonacci spiral – logarithmic spiral curve fitting to cactus areoles


[categories: nature, photo] [tags: , ]

light and dark – curve fitting to a winter landscape

[posted: ]  [0 comments]

i’ve spent quite some time working on curve fitting in R (open-source software for statistical computing), recently. while most of that work went into scientific data at university, i was also inspired to try other uses, and here’s a not-so-scientific by-product of spending time with R:

light and dark - curve fitting to a winter landscape

i used a winter landscape and fitted nonlinear curves to sunlit and shadowed treetops.
the result is quite aesthetic, isn’t it?

[categories: nature, photo] [tags: , ]

how to: insert pch data point symbols into text (and axis labels) in R

[posted: ]  [1 comment]

how to: insert pch data point symbols into text (and axis labels) in R the problem
i have two sets of data for one graph, and use two different data point symbols. to make the graph more intuitive, i’d like to add the symbols to the axis labels, e.g.

• percent loss of conductivity (%)
° stomatal conductance (%)

the addition of the correct symbol is apparently easy using legend(), but i want to add it directly to the axis label.

the solution
when plotting my data, i disable the automatic creation of axis labels (… xlab =””, ylab=””, …) and add my own label text later. in order to use symbols (bullet points and circles in my case; also applies to other symbols1), i eventually resorted to a combination of text(), Hershey Vector Fonts and graphical parameters such as cex (character expansion, for bigger font size), adj (string align) srt (string rotation) and xpd (plot/clipping adjustment).

code example: [more...]

  1. e.g. special characters, mathematical operators, cyrillic letters or greek letters – though there are easier ways for the latter. []
[category: computers & technology] [tags: , , ]

statistics with R: how to avoid the “sum not meaningful for factors” error

[posted: ]  [0 comments]

if you’re trying to calculate weighted means, create a weighted boxplot, or do something similar in R, and you get an error saying “sum not meaningful for factors”, it means that one of your data columns that should be a vector of numbers, is actually of the data type “factor”.
the data type can easily be checked in R using commands such as is.numeric(x), is.vector(x), is.factor(x) etc.

for me, the problem was a product of different decimal symbols, “.” being R’s standard, and “,” being the decimal character in austria as well as lots of other countries. when i imported the data, decimal numbers were falsely classified as text-strings, and thus the data type of the entire column was set to “factor”.

in order to avoid this problem, you can either change the locale of your data source (for example: “extras – options – international” in microsoft excel) to use the dot (“.”) as the decimal point, or use ...dec = ","... in the import command in R to specify your the decimal character of your input data, such as this:

    dataset <- read.table("clipboard", header = TRUE, dec=",")
[category: general] [tags: , ]