Hi Michael,
check ?save
Regards,
Albert-Jan
~~
All right, but apart from the sanitation, the medicine, education, wine, public
order, irrigation, roads, a
fresh water system, and public health, what have the Romans ever don
Hello,
I am trying to make a plot using the code below. The plot is divided into two
parts, using facet_grid. I would like the vertical axis (labelled 'place') to
be different for each location (=part). So in the upper part, only places 'n'
through 'z' are shown, while in the lower part, only p
Hi,
I am using maptools to plot air quality data on a map. Each measurement point
is mapped to a postal code area. This yields pictures with discrete borders,
like so:
http://dl.dropbox.com/u/27415200/baincome.png
The problem is that the size of a postal code area doesn't mean much in this
cont
depth == max(df$diepte)) {
x <- getTotals(df, depth)
} else {
x <- getTotals(x, depth)
}
}
Cheers!!
Albert-Jan
~~
All right, but apart from the sanitation, the medicine, education, wine, public
order, irrigation, roads, a fresh water system, and public health, wh
Hi,
I have a hierachical code system such as the example below (the printed data
are easiest to read). I would like to write a function that returns an
'imputed' data frame, ie. where the the parent values are calculated as the sum
of the child values. So, for instance, STAT.01.01.06 is the s
Hello,
I would like to overload the "+" operator so that it can be used to concatenate
two strings, e.g "John" + "Doe" = "JohnDoe".
How can I 'unseal' the "+" method?
> setMethod("+", signature(e1="character", e2="character"), function(e1, e2)
> paste(e1, e2, sep="") )
Error in setMethod("+", s
Hello,
I'd do:
ave(testvec, FUN=cumsum)+1
But in R everything can be done in a trillion different ways. ;-)
Cheers!!
Albert-Jan
~~
All right, but apart from the sanitation, the medicine, education, wine, public
order, irriga
Hello!
library(gsubfn)
test <- c('filename_1_def.pdf', 'filename_2_abc.pdf')
gsubfn("(.+_)([a-z]+)(\\.pdf)", "\\2", test)
Cheers!!
Albert-Jan
~~
All right, but apart from the sanitation, the medicine, education, wine, public
Hello,
How can I generate an overview/vector of all the methods winthin an S4 class?
Similar to dir() in this Python code:
>>> class SomeClass():
def some_method_1(self):
pass
def some_method_2(self):
pass
>>> dir(SomeClass)
['__doc__', '__module__', 'some_method_1', 'some_method_2']
>>>
t from the sanitation, the medicine, education, wine, public
order, irrigation, roads, a fresh water system, and public health, what have
the Romans ever done for us?
~~
From: jim holtman
>To: Albert-Jan Roskam
>Cc: R Mai
Hello,
I am trying to write some code that dumps R objects to the harddisk in a binary
format so they can be quickly re-used later. Goal is to save time. The objects
may be quite large (e.g. classes for a GUI). I was thinking that save() and
load() would be suitable for this (until now I only
Hi,
I have a long data file with time data that change to wide format using
reshape.
The data contain Values and Factors. Some values are missing but can be
obtained
by multiplying value of year T-1 with Factor of year T. Sometimes, multiple
succesive years have no values, so the calculated v
But isn't this version of which() typo-proof?
> x <- iris[-which(c("Sepal.Length", "SSSepal.Width") %in% names(iris))]
Btw, I prefer the following, ie. simply assigning to NULL. Much easier notation.
> y <- iris
> y$Sepal.Width <- y$SSSepal.Width <- NULL
Cheers!!
Albert-Jan
~~~
f$varname).
>>
>> df[,"varname",drop=FALSE] is a one-column df (same as df$varname).
>>
>> df$newVarname<- df["varname"] inserts a new component
>> into df, the component being a one-column data.frame,
>> not the column in that data.fra
Hello,
Is the following a bug? I always thought that df$varname <- does the same as
df["varname"] <-
> df <- data.frame(weight=round(runif(10, 10, 100)), sex=round(runif(100, 0,
1)))
> df$pct <- df["weight"] / ave(df["weight"], df["sex"], FUN=sum)*100
> names(df)
[1] "weight" "sex""pct"
Hi,
I'm using reshape to cast molten data. When I use the following command, R
either crashes (when I use Notepad++) or gives an error (when I use Rgui or
source()), BUT the error occurs not always, maybe only on half the attempts:
w <- cast(v, id + code + productname + year + begin + end + spec
r-project.org] On Behalf Of Marc Schwartz
> Sent: Thursday, May 26, 2011 2:15 PM
> To: Albert-Jan Roskam
> Cc: R Mailing List
> Subject: Re: [R] NaN, Inf to NA
>
> On May 26, 2011, at 3:18 PM, Albert-Jan Roskam wrote:
>
> > Hi,
> >
> > I want to recode
Hi,
I want to recode all Inf and NaN values to NA, but I;m surprised to see the
result of the following code. Could anybody enlighten me about this?
> df <- data.frame(a=c(NA, NaN, Inf, 1:3))
> df[is.infinite(df) | is.nan(df)] <- NA
> df
a
1 NA
2 NaN
3 Inf
4 1
5 2
6 3
>
Thanks!
Thanks, we tried it, but it didn't solve the problem. Some more info (mostly
strings of ) was shown in the Dos box, but that was all.
Cheers!!
Albert-Jan
~~
All right, but apart from the sanitation, the medicine, educati
Hello,
I want to run an r script that contains code for a gui (rgtk) on the command
line (windows 2000, 32 bits) using R2.10.1, but the Gui disappears a few
miliseconds after I started the program. What switch should I use to prevent
this? I tried r.exe, rterm.exe and rscript.exe with various c
0), year=c(2001, 2000, 2000, 2000, 1999, NA))
apply(df,1,match,x=1)
[1] 3 2 2 2 1 NA
___
Patrick Breheny
Assistant Professor
Department of Biostatistics
Department of Statistics
University of Kentucky
On 05/04/2011 07:52 AM, Albert-Jan Roskam wrote:
> Hello,
>
&g
Hello,
A simple question perhaps, but how do I, within each row, find the first
occurence of the number 1 in the df below? I want to use this position to
programmatically create the variable 'year'. I'v come up with a solution, but I
find it downright ugly. Is there a simpler way? I was hoping
Hi Jeff,
Ah, thanks a lot! Yes, meanwhile I also switched to csv. This still requires
knowledge about the regional settings (Sys.getlocale), but it's a lot more
transparent.
I'm quite new to R and I must say that stuff like this is eating up a LOT of my
time. All those invisible data type co
Hello,
How can I tell RODBC to scan all the records of an xls file to determine the
data type? If the first n records happen to be empty Rodbc assumes a character,
and any numbers are made . And if, for instance, the first n records
contain
numbers, and later they also contain characters, thos
Hello,
I'm using R2.10 on Windows 2000 and I'm having trouble installing the 'hash'
library. This is the error I get:
> library(hash)
_ _
___ _ __ ___ _ __ __| | __ _| |_ __ _
/ _ \| '_ \ / _ \ '_ \ / _` |/ _' | __/ _' |
| (_) | |_) | __/ | | |
Hi,
I have a function myFun which I want to call multiple times, using different
argument lists.
myFun("v1", "2009", 1)
myFun("v2", "2008", 1)
myFun("q", "2001")
How can I easily do this in R? Should I use mapply?
I unsuccessfully tried something like:
x <- list(c("v1", "2009", 1), c("v2", "200
Got it, after rtmíng I realized I had to use xtfrm:
ord <- order(c(idvars, -xtfrm("t")))
myData[ord, ]
It's downright ugly, as it confronts the user with some implementation detail
(cf SAS or SPSS), but well, it works.
Cheers!!
Albert-Jan
Hi,
I have a data frame with variables a, b, c (character vars) and t (time var,
could be represented as POSIXct or character, depending on which is most
useful.
The format is "-mm-dd hh:mm:ss CET"). Now, I want to sort the data frame in
ascending order by a, b, c and then in descending or
rrigation, roads, a fresh water system, and public health, what have
the Romans ever done for us?
~~
--- On Thu, 8/5/10, Romain Francois wrote:
From: Romain Francois
Subject: Re: [R] Sciviews-K -- object 'httpdPort' no
Hi,
I'm trying to install Sciviews-K on Linux Ubuntu 9.10 (karmic) but I'm not able
to establish the connection between Komodo and R. Here;s the error I get, plus
some diagnostic info:
R version 2.9.2 (2009-08-24)
R is SciViews ready!
Error in get(name, envir = asNamespace(pkg), inherits = FALS
//www.mail-archive.com/r-help@r-project.org/msg73565.html
http://www.mail-archive.com/r-help@r-project.org/msg75308.html
Friedrich Schuster
Dompfaffenweg 6
69123 Heidelberg
On Monday 26 July 2010 05:52:13 pm Albert-Jan Roskam wrote:
> Hello,
> �
> Does anybody know if the OOP module (Cha
Hello,
Does anybody know if the OOP module (Chambers & Temple Lang) is going to
replace the the S4 (and the S3) class system?
http://www.omegahat.org/OOP/oop.pdf
Cheers!!
Albert-Jan
~~
All right, but apart from the sanitation
Hi,
I am trying to write some code that tracks changes that may have been made
after a dataframe has been edited using fix(). But if I edit only the first
cell (row 1, col 1) of the dataset below, it is like many records were edited.
What is the explanation for this error?
require(R.util
a fresh water system, and public health, what have
the Romans ever done for us?
~~
--- On Thu, 7/22/10, Albert-Jan Roskam wrote:
From: Albert-Jan Roskam
Subject: [R] check menu button (tcltk)
To: "R Mailing List"
Date:
Hi,
I am making a mock user interface in tcltk and I would like to add a 'check
menu button' such as shown here:
http://zetcode.com/tutorials/pygtktutorial/images/checkmenuitem.png
Does anybody know how to do this? I am quite new to R.
Cheers!!
Albert-Jan
~~~
Hi R experts,
The fix() function canbe used to edit normal functions. I would like to know
whether it's also possible to use something similar to edit a method of an S4
class. In other words, is there a fix-like function that allows me to edit
method definitions without having to go back to th
Hi,
I've been looking for a package that reads and/or writes in the sdmx
statististical (meta)data format (http://sdmx.org/) but I couldn't find any.
Does anybody know whether this is available?
Cheers!!
Albert-Jan
~~
All rig
I've used www.pastebin.com before, with C as the code.
Cheers!!
Albert-Jan
~~
All right, but apart from the sanitation, the medicine, education, wine, public
order, irrigation, roads, a fresh water system, and public health, wh
require(pkg) || install.packages(pkg)
Cheers!!
Albert-Jan
~~
All right, but apart from the sanitation, the medicine, education, wine, public
order, irrigation, roads, a fresh water system, and public health, what have
the R
Hi,
R has a number of functions to aid documentation:
prompt (for functions)
promptMethods
promptClass
package.skeleton
My question: does package.skeleton generate the basis for a documentation for
functions, methods and (S4) classes? Or only for (generic) functions? I cannot
this this here b
Hi,
I am writing a program that returns the a vector of the most recent R files in
a given dir.
The files are named like "f1.R", "f2.R", and sometimes "f3a.R". I want to use
the resulting
vector to easily source() all the most recent file versions of a given dir.
Here's what I've cooked up till
> df <- data.frame(x = runif(10), y = runif(10), z = runif(10))
> colnames <- names(df)
> df2 <- df[!colnames %in% c("x", "y")]
> df2
Cheers!!
Albert-Jan
~~
All right, but apart from the sanitation, the medicine, education, wine,
ds, a fresh water system, and public health, what have
the Romans ever done for us?
~~
--- On Thu, 5/20/10, Martin Morgan wrote:
From: Martin Morgan
Subject: Re: [R] getSubClasses()?
To: "Albert-Jan Roskam"
Cc:
Hi,
Is there a built in function that returns a character vector of all subclasses
of a given superclass?
showClass(Class = "SomeClass") contains the info that I want, but I don't know
how to access it.
getSubClasses <- function(superClass) return(setdiff(getClasses(.GlobalEnv),
superClass))
Hi R friends,
I'm still studying S4 classes and I have a question about slot assignment. Why
would I have to use a special setter method [example 2 below] if I can assign
data to a slot directly when I call new() [example 1 below]?
## first way to do it (the idiosyncratic way?)
setClass(Class
Hi,
Check the functions merge_all and merge_recurse from the reshape package.
I think you're looking for the latter function.
Cheers!!
Albert-Jan
~~
All right, but apart from the sanitation, the medicine, education, wine, pu
: Gabor Grothendieck
Subject: Re: [R] re.findall equivalent?
To: "Albert-Jan Roskam"
Cc: "R Mailing List"
Date: Friday, April 30, 2010, 6:13 PM
UNIX grep selects out lines in a file and R grep similarly selects out
components of a vector of strings. On the other hand
Hi,
The regular expression (grep) below does not behave at all like the equivalent
in Python. Also, I would be happy if somebody could tell me what the R
equivalent for Python's re.findall is. The regex filters out any numbers not
enclosed by square brackets, including fractions (with either co
ds, a fresh water system, and public health, what have
the Romans ever done for us?
~~
--- On Thu, 4/29/10, Albert-Jan Roskam wrote:
From: Albert-Jan Roskam
Subject: [R] UpdateLinks = FALSE
To: "R Mailing List"
Hi,
I'm reading 100s of excel files and many of them contain links to external
files (I hate that, but that aside). Every time such a file is opened, a menu
pops up asking if I want to update the links. I never want to update the links.
I used the macro recorder to see what code would be neede
Hi,
There's probably an easier or more readable way to do it, but:
df <- data.frame(cbind(letters, var= runif(26, 2, 3)))
df[df$letters[grep("[G]", df$letters, ignore.case=TRUE)],]
Cheers!!
Albert-Jan
~~
All right, but apart fr
return() oddity
To: "Albert-Jan Roskam" , "R Mailing List"
Date: Tuesday, April 27, 2010, 3:45 PM
It's not a bug. It's the intended behavior.
Sprintf by itself returns a formatted character string and doesn't print
anything. Without the return statement, the
Hi,
If I use sprintf and return inside a function, sprintf doesn't print anything
anymore. See the non-sense example below.
> x <- function() { a <- 888
+ sprintf("xxx %s", a) }
> x()
[1] "xxx 888"
> x <- function() { a <- 888
+ sprintf("xxx %s", a)
+ return(a) }
> x()
[1] 888
Is this a bug?
Hi,
I'm having trouble seeing the added value over functions defined by setGeneric
vis-a-vis
methods defined by inheritance and polymorphism. setGeneric offers a 'clean'
call to a generic function, ie. no need to call new(), so less typing to do for
the user. But such explicit calls can also be
Hi,
I'm having trouble seeing the added value over functions defined by setGeneric
vis-a-vis
methods defined by inheritance and polymorphism. setGeneric offers a 'clean'
call to a generic function, ie. no need to call new(), so less typing to do for
the user. But such explicit calls can also be
Hi,
I'm new to R and S4 classes. I defined a class with two methods (myMethod1 and
myMethod2). I want to call myMethod1 within myMethod2. Why does the code below
not work? The name 'myMethod1' doesn't appear to have meaning inside myMethod2,
even though the two methods belong to the same clas
Hi,
I would like to recursively loop through al subfolders of a directory and do
stuff with certain file types in those dirs. Is there a package/function that
could do this? So it's more than Sys.glob. I'm looking for equivalent of
Python's os.walk *) and I don't want to reinvent the wheel.
Hi,
I have created the Boolean function below to evaluate if a given cell in an
Excel file contains a formula. I have to process hundreds of excel files and I
want to filter out any
cells that contain formulae.
Now I want to use the isXlsFormula function below when I loop through all the
cell
Thu, 3/25/10, Sharpie wrote:
From: Sharpie
Subject: Re: [R] Abstract classes
To: r-help@r-project.org
Date: Thursday, March 25, 2010, 5:02 PM
Albert-Jan Roskam wrote:
>
> Hi R lovers,
>
> I'm looking for more information about, and implementations of abstract
> classes.
Hi R lovers,
I'm looking for more information about, and implementations of abstract
classes. After reading "Head First Design Patterns" (O'Reilly). I want to know
whether I could use this to build an interface, i.e. a placeholder for all
possible methods in the underlying subclasses. The final
Hi,
Is eval always used in conjunction with parse? Based on other languages, I'd
expect the expression already to work without the use of parse(), but indeed it
doesn't, or at least not as intended. Just a newbie question..
Cheers!!
Albert-Jan
~~~
model. It also tells you which properties are accessible. There
are a few hundreds of them.
On 3/9/2010 4:35 PM, Albert-Jan Roskam wrote:
> Hi,
>
> I would like to make a program that reads excel files, and writes the cells
> of which contents is not a formula to another file. I
Hi,
I would like to make a program that reads excel files, and writes the cells of
which contents is not a formula to another file. I don't think this is possible
with RODBC, but it may be possible with rcom.
I read the documentation of the rcom package, but I was hoping somebody knows a
g
Hi Rob,
I just started reading about classes (and also learning R), so I apologize if
the following code is confusing you more. I simplified the code somewhat in
order to better understand what's going on. I was wondering: are you
deliberately reimplementing the builtin update() function?
s
~~
--- On Mon, 3/8/10, Martin Morgan wrote:
From: Martin Morgan
Subject: Re: [R] setClass or setValidity?
To: "Albert-Jan Roskam"
Cc: r-help@r-project.org
Date: Monday, March 8, 2010, 10:56 PM
On 03/08/2010 07:18 AM, Albert-Jan Roskam wrote:
> Sorry: there was an erro
he face of ambiguity, refuse the temptation to guess.
~~
--- On Mon, 3/8/10, Albert-Jan Roskam wrote:
From: Albert-Jan Roskam
Subject: [R] setClass or setValidity?
To: r-help@r-project.org
Date: Monday, March 8, 2010, 4:14 PM
H
Hi,
I'm reading up on S4 classes *). There seem to be at least two ways of input
validation:
setClass() (using the 'validity' argument) and setValidity(). Is it a matter
of taste which function is used? Or should more complex validation code better
be put in a setValiditity call?
*) A (Not
.
~~
--- On Tue, 3/2/10, Henrique Dallazuanna wrote:
From: Henrique Dallazuanna
Subject: Re: [R] simple data transformation question
To: "Albert-Jan Roskam"
Cc: r-help@r-project.org
Date: Tuesday, March 2, 2010, 2:45 PM
Try this:
reshape(cbind(id = as.numeric(dtf$var), dtf, time = wit
Hi all,
I have a (hopefully) simple newbie-level question.
# I have data like this:
dtf <- data.frame(read.table(textConnection("var value
company 9887.1
company 91117.0
blaah 91.1
etc 11
etc 97111"), header=TRUE))
# I would like to have output like this (the index number may
Hi Brandon,
I just read this book, which I am sure you will be interested in:
http://www.amazon.com/SAS-SPSS-Users-Statistics-Computing/dp/0387094172
Cheers!!
Albert-Jan
~~
In the face of ambiguity, refuse the temptation to gue
I though duck-typing was about type-independency?
I could feed the bird object bread() or carrots(), or any other method, and
that's okay as long as the bird doesn't die. And since ducks don't like carrots
[at least, afaik]
Quaaack! ;-)
Albert-Jan
~~~
> "The best way to spread information is to tell someone that it is a secret,
> the best way to keep it secret is to put it in > a manual."
==> Nice quote. ;-) The problem is not that there's too little information,
rather there's so much. That's probably because R is so powerful, but it makes
Hi
I'm using R v2.8 under Windows*) and I'm trying to install a new package (local
zip file), but I get the message below. I followed some advice at
http://cran.r-project.org/bin/windows/base/rw-FAQ.html (4.2 onwards), but to no
avail. How can I tell R to save the help files to an alternative
Hi,
I used pdftk (pdf toolkit) before. A quick glance at the features seems to tell
that it does *not* support what you are looking for, but it may nonetheless be
a useful starting point:
http://www.accesspdf.com/pdftk/ .
The nice thing is that it's a command-line tool.
Cheers!!
Albert-Jan
, 1/3/10, Gabor Grothendieck wrote:
From: Gabor Grothendieck
Subject: Re: [R] plot question
To: "Albert-Jan Roskam"
Cc: r-help@r-project.org
Date: Sunday, January 3, 2010, 10:10 PM
I gather that each row defines one series, right? In that case try this:
Lines <- "date
Hi,
I am new to R so forgive me if the following query is somewhat simple. I have
a small tab-separated file with n records of glucose values, one record per
day, seven measurements per day. It looks like this:
date sober no vm nm va na vs
20091229 NA 6.8 NA 2.
Hi,
I've just been browsing for IDEs for R, see e.g.
http://www.linuxlinks.com/article/20080413133953606/R.html
It's probably highly subjective, but which free IDE is the best one around? For
the Python language, I've always been using IDLE. I like the syntax
highlighting and the syntax sugges
.
~~
--- On Wed, 12/16/09, Søren Højsgaard wrote:
From: Søren Højsgaard
Subject: SV: [R] R & very large files
To: "Albert-Jan Roskam" , "r-help@r-project.org"
Date: Wednesday, December 16, 2009, 12:13 PM
The sqldf package may be of he
Hi,
I very recently started using R (as in: last week) and I was wondering if
anyone could point me to website(s) with sample code to deal with large
datasets (length- and/or breadthwise). I understood that R was never designed
to work with datasets larger than, say, a couple of hundred Mb. On
79 matches
Mail list logo