[R] citation() command doesn't work in R.3.1.1

2014-08-06 Thread Sverre Stausland
citation() Error: $ operator is invalid for atomic vectors In addition: Warning message: In packageDescription(pkg = package, lib.loc = dirname(dir)) : no package 'base' was found sessionInfo() R version 3.1.1 (2014-07-10) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1]

[R] Set system font in R package Cairo in Mac OS X

2013-11-10 Thread Sverre Stausland
Because of the issue raised in https://stat.ethz.ch/pipermail/r-help/2013-November/362896.html, I am switching to R on Mac OS X (10.6.8) to create some plots. Using CairoPDF(), however, the commands I use in Windows (7) to select my fonts don't have any effect on Mac OS X, where the output .pdf

[R] Using Unicode inside R's expression() command

2013-11-09 Thread Sverre Stausland
I'm using 'expression()' in R plots in order to get italicized text. But it appears as if I cannot use Unicode symbols inside 'expression' outside of ASCII characters. Is there some way I can work around this? My goal is to get the 'fi' ligature in various labels in my R barplots (together with

[R] Reorder in decreasing order

2012-07-22 Thread Sverre Stausland
reorder() is probably the best way to order the levels in a vector without manually specifying the order. But reorder() orders by default in an increasing order: The levels are ordered such that the values returned by ‘FUN’ are in increasing order. Is there a way to do what reorder() does, but

Re: [R] Reorder in decreasing order

2012-07-22 Thread Sverre Stausland
. - Original Message - From: Sverre Stausland john...@fas.harvard.edu To: r-help@r-project.org Cc: Sent: Sunday, July 22, 2012 12:27 PM Subject: [R] Reorder in decreasing order reorder() is probably the best way to order the levels in a vector without manually specifying the order

Re: [R] Reorder in decreasing order

2012-07-22 Thread Sverre Stausland
B B F A A F C B A [39] E E D E E D D D D D E D D C E E E E D D C C E D C C E E C C C C C C Levels: A B C D E F A.K. - Original Message - From: Sverre Stausland john...@fas.harvard.edu To: arun smartpink...@yahoo.com Cc: R help r-help@r-project.org Sent: Sunday, July 22, 2012

Re: [R] Remove names and more from list with capture.output()

2011-11-15 Thread Sverre Stausland
...@comcast.net wrote: On Nov 14, 2011, at 11:49 PM, Sverre Stausland wrote: Hi R users, I end up with a list object after running an anova: lm(speed ~ 1 + dist + speed:dist, data = cars) - Int lm(speed ~ 1 + dist, data = cars) - NoInt anova(Int, NoInt) - test test - test[c(Df, F, Pr(F))][2,] is.list

[R] Remove names and more from list with capture.output()

2011-11-14 Thread Sverre Stausland
Hi R users, I end up with a list object after running an anova: lm(speed ~ 1 + dist + speed:dist, data = cars) - Int lm(speed ~ 1 + dist, data = cars) - NoInt anova(Int, NoInt) - test test - test[c(Df, F, Pr(F))][2,] is.list(test) [1] TRUE test Df FPr(F) 2 -1 18.512 8.481e-05

[R] update() ignores object

2011-08-15 Thread Sverre Stausland
Hi all, I'm extracting the name of the term in a regression model that dropterm specifies as the least significant one, and I'm assigning this name to an object. However, when I use update(), it ignores this object. Is there a way I can make it not ignore it? A reproducible example is below:

Re: [R] update() ignores object

2011-08-15 Thread Sverre Stausland
to a string, pase it with your term, and then reconvert it to a formula: update(my.lm,formula(paste(.~.-, my.object))) There may be a more elegant way via substitute(), but I think this works. Cheers, Bert On Mon, Aug 15, 2011 at 1:44 PM, Sverre Stausland john...@fas.harvard.edu wrote: Hi

[R] embedFonts() does not embed fonts?

2011-08-09 Thread Sverre Stausland
Dear helpers, I'm trying out the embedFonts() to embed fonts into my pdf files. However, when I inspect the new pdf with a program designed to look for embedded fonts, I see that the fonts have in fact not been embedded. Below are my calls. R version 2.13.1 (2011-07-08) Copyright (C) 2011 The R

Re: [R] embedFonts() does not embed fonts?

2011-08-09 Thread Sverre Stausland
Some of you might see that there's a tiny mistake in the embedFonts() call. fontpaths = C/Windows/Fonts should of course be fontpaths = C:/Windows/Fonts. I fixed this, but it didn't change the fact that the new .pdf does not have its fonts embedded. Sverre On Tue, Aug 9, 2011 at 4:48 PM, Sverre

[R] Extract names from vector according to their values

2011-08-02 Thread Sverre Stausland
Dear helpers, I can create a vector with the priority of the packages that came with R, like this: installed.packages()[,Priority]-my.vector my.vector base boot class cluster codetools base recommended recommended recommended recommended compiler

[R] Extract rows from a matrix according to value in column

2011-08-02 Thread Sverre Stausland
Dear helpers, I'm trying to extract certain rows from a matrix according to the values the rows have in a certain column. I've been googling for a while without result. Here's a reproducible example of a matrix (and the one I was playing with initially): myrepo-getOption(repos)

Re: [R] gsub() with unicode and escape character

2011-07-17 Thread Sverre Stausland
required by the posting guide. Most likely this is a limitation of the locale you used (and failed to tell us about) on the OS you used (...). On Sat, 16 Jul 2011, Sverre Stausland wrote: Dear helpers, I'm trying to replace a character with a unicode code inside a data frame using gsub

[R] gsub() with unicode and escape character

2011-07-16 Thread Sverre Stausland
Dear helpers, I'm trying to replace a character with a unicode code inside a data frame using gsub(), but unsuccessfully. data.frame(animals=c(dog,wolf,cat))-my.data gsub(o,\u0254,my.data$animals)-my.data$animals my.data$animals [1] dɔg wɔlf cat It's not that a data frame cannot have

Re: [R] Export Unicode characters from R

2011-07-15 Thread Sverre Stausland
 funny.g- \u1E21  funny.g [1] ḡ  data.frame (funny.g) -  funny.g  funny.g$funny.g [1] ḡ Levels:U+1E21 I think the problem is in the data.frame code, not in writing. Data.frames try to display things in a readable way, and since you're on Windows where UTF-8 is not really

Re: [R] Export Unicode characters from R

2011-07-15 Thread Sverre Stausland
murdoch.dun...@gmail.com wrote: On 15/07/2011 1:42 PM, Sverre Stausland wrote:      funny.g- \u1E21      funny.g  [1] ḡ      data.frame (funny.g) -    funny.g      funny.g$funny.g  [1] ḡ  Levels:U+1E21  I think the problem is in the data.frame code, not in writing. Data.frames

[R] Export Unicode characters from R

2011-07-14 Thread Sverre Stausland
Dear helpers, I am not able to export Unicode characters from R. Below is an example where the Unicode character is correctly rendered as long as I am stay within R. When I export it, the character appears only with its basic code, and the same happens when I import it back into R . I'm using R

[R] Extract only the values from a row

2011-07-11 Thread Sverre Stausland
Dear helpers, how can I extract only the values from a row in a data frame? Using [X,] doesn't do the trick: data.frame(letters[1:10],letters[11:20])-my.data my.data[1,] letters.1.10. letters.11.20. 1 a k I would like to be able to extract only the values a and k

Re: [R] Extract only the values from a row

2011-07-11 Thread Sverre Stausland
Great - thanks for the explanation and for the solution using stringsAsFactors=FALSE in the data.frame function Sverre On Mon, Jul 11, 2011 at 3:57 PM, Sarah Goslee sarah.gos...@gmail.com wrote: Hi Sverre, On Mon, Jul 11, 2011 at 12:48 PM, Sverre Stausland john...@fas.harvard.edu wrote

[R] Interpreting the coefficient of an interaction between continuous variables in a regression model

2011-03-03 Thread Sverre Stausland
Hello, my question is triggered by an actual model I am running, but I will pose it as a very general question with a hypothetical example. Take the following regression model: I have a binomial dependent variable Happiness, whose two values are 0 (=unhappy) and 1 (=happy). My two independent