Displaying 20 results from an estimated 10000 matches similar to: "converting column to factor *within* a data frame"
2003 Nov 20
5
Find value in vector (or matrix)
Hi all,
Is there a function to check if a particular value is contained in a
vector? I've looked at grep in the hope that I could use a Perl-like
syntax, but obviously it's different...
I'd like to do something like:
y <- c("a","b","c")
if("a" in y)
{
# "a" is not in y
}
Also, is there a way to
2003 Nov 21
3
plot map of areas
Hi all,
Given a number of points (x,y) in a plane, I'd like to plot a map of
polygons, so that
1) each polygon contains exactly one point
2) the polygon defines the area for which this specific point is
closer than any other point.
It's a bit like a map of areas "influenced" by that point, and it's
obviously a matter of intersecting the perpendicular bisectors
2008 Sep 23
5
xyplot problem
Hi all,
I am trying to produce some panels with dots in an X/Y plane where the
diameter of the dots indicates a Z value (like e.g. earthquake maps where dot
sizes indicate magnitudes and X/Y the location).
This works fine with xyplot, e.g.:
xyplot(1:3~1:3,cex=1:3,pch=16)
However, when I do this with a panel variable, e.g.:
x<-rep(1:3,5)
y <- rep(1:3,5)
sz <- rep(1:5,each=3)
grp
2003 Nov 25
2
R recursion depth and stack size
Hi all,
I am playing around with latin squares, and wrote a recursive function
that searches for valid combinations.
Apart from the fact that there are very many, I run into troubles
beginning with size 10x10 because the recursion depth becomes too large
(max of 10x9-1=89 in this case).
Why is this a problem? Isn't there enough space allocated to the stack?
Can this be increased? The
2003 Oct 22
2
plotmath question: y'
Hi all,
I wonder how to correctly write the following expression (it's the axis
label in a plot command):
ylab=expression(y' == y - bar(y) )
Somehow the single quote in y' is causing the problems, I guess because
it is interpreted as a quote...
Does it have to be escaped? But how?
Thanks for your help
Pascal
2003 Dec 17
1
Session log file...
Hi all,
I tried to save a complete log of a R session we had in a seminar
today... but I didn't succeed.
1) R | tee session.log
This saves both input and output, but I do get the cursor key escape
sequences from editing (cursor-up to get last command etc) instead of
the actual command line executed.
2) savehistory
Gets commands only, not the output
3) sink
Gets output, without the
2011 Dec 19
2
nlrob problem
Dear all,
I am not sure if this mail is for R-help or should be sent to R-devel
instead, and therefore post to both.
While using nlrob from package 'robustbase', I ran into the following
problem:
For psi-functions that can become zero (e.g. psi.bisquare), weights in
the internal call to nls can become zero. Example:
d <- data.frame(x=1:5,y=c(2,3,5,10,9))
d.nlrob <-
2009 Jan 07
2
NA and NaN question
Hi all,
I ran into a problem in some of my code that could be traced back to 'mean'
sometimes returning NA and sometimes NaN, depending on the value of na.rm:
> mean(c())
[1] NA
> mean(c(NA),na.rm=T)
[1] NaN
However, I don't understand the reasoning behind this and would appreciate and
explanation.
I understand that the mean of an empty vector is not definied, but I
2003 Dec 08
1
Add row to data frame
Hi all,
is there an easy way to build up a data frame by sequentially adding
individual rows? The data frame consists of numeric and character
columns. I thought of rbind, but I ended up with numeric values for the
character columns.
Pascal
2003 Oct 30
7
Weird problem with median on a factor
Hi all,
I hope this isn't a naive newbie question again. Here you can see column 264 of
a data frame containing data of the same interview in May and September. Column
264 contains the answers of 49 persons to a question in May.
> fbhint.spss1[,264]
[1] teils/teils sehr wichtig <NA> <NA> sehr wichtig
[6] sehr wichtig sehr wichtig sehr wichtig <NA>
2006 Dec 18
2
Error compiling on HP-UX
Dear all,
I hope this is the right mailing list for my question -- I felt that this was
too technical for R-help.
I am trying to compile R-2.4.0 on a HP-UX system:
./configure
MAKE=gmake --prefix=$HOME --without-x --without-tcltk --disable-R-profiling --without-readline --disable-multibyte
R is now configured for ia64-hp-hpux11.23
Source directory: .
Installation directory:
2003 Nov 20
2
Increment element of vector and efficiency
Hi all,
Thanks for the incredibly quick help with the "%in%"...
There's a second question, though: I'd like to increment an element of a
vector if a certain event occurs, e.g.
count[event] <- count[event] + 1; # works, but...
Is this efficient? I wonder whether R needs to subset the count vector
on both sides of the assignment operator (i.e., twice), or
2005 Dec 06
2
figure with inset
I am trying to plot a figure within a figure (an inset that shows a closeup of
part of the data set). I have searched R-help and other sources but not found a
solution.
What I would like to do is
(1) produce a plot
(2) specify a window that will be used for the next plot (in inches or using the
coordinate system of the plot produced in (1)
(3) overlay a new plot in the window specified under (2)
2003 Aug 12
8
capturing output from Win 98 shell
How can I best achieve the following (works in Splus):
filenames <- dos("dir *.sasb7dat /b")
What I am asking, more generically, is: how can I capture the output of
a
DOS command in R?
I have tried using
system("COMMAND.COM /c dir /b", intern=T, show.output.on.console=T)
where
intern: a logical, indicates whether to make the output of the
command an R
2003 Jul 31
6
Problem with data.frames
Hi,
I just encountered a problem in R that may easily be fixed: If one uses
attach for a data.frame e.g. 10000 times and forgets detach, then R gets
incredibly slow (less then 10% of the original speed).
My system:
platform powerpc-apple-darwin6.0
arch powerpc
os darwin6.0
system powerpc, darwin6.0
status
major 1
minor 6.1
year 2002
2012 Jan 06
1
lme model specification problem (Error in MEEM...)
Dear all,
In lme, models in which a factor is fully "contained" in another lead to
an error. This is not the case when using lm/aov.
I understand that these factors are aliased, but believe that such
models make sense when the factors are fitted sequentially. For example,
I sometimes fit a factor first as linear term (continuous variable with
discrete levels, e.g. 1,2,4,6), and
2011 Oct 07
1
modify "..." (optional args)
Hi all,
Is there a way to modify the optional arguments (...) passed to a
function, so that these can be passed in modified form to a subsequent
function call? I checked "Programming with Data" but could not find a
solution there.
What I'd like is something along these lines:
test <- function(x,y,...) {
if(!hasArg(xlab)) { ___add xlab to ...___ }
if(hasArg(xlab)) {
2003 Nov 18
3
plot, plot, methods, crash (PR#5173)
(If this only happens in Win 98, I'm sure I could live with it. Just
may be helpful to report it, I hope.)
Start up R GUI, then
> plot(1:4,1:4) # then close manually by clicking X
> plot(1:4,1:4) # ditto
> methods(plot)
sometimes produces normal output and even the following prompt,
but then crashes immediately, or more often, crashes immediately with
no output.
I can do any
2003 Nov 18
4
address for bug reports? (PR#5171)
bug.report() tells me to email to r-bugs@r-project.org, whereas
the Web site http://www.r-project.org/ points me to
r-bugs@biostat.ku.dk.
Which should I believe?
Simon Fear
Senior Statistician
Syne qua non Ltd
Tel: +44 (0) 1379 644449
Fax: +44 (0) 1379 644445
email: Simon.Fear@synequanon.com
web: http://www.synequanon.com
Number of attachments included with this message: 0
This
2003 Nov 19
5
ISOdate returns incorrect date?
Dear all,
I have found the following (for me) incomprehensible behaviour of
ISOdate (POSIXct):
> ISOdate(1900,6,16)
[1] "1900-06-15 14:00:00 Westeurop?ische Sommerzeit"
> ISOdate(1950,6,16)
[1] "1950-06-16 14:00:00 Westeurop?ische Sommerzeit"
Note that in the first case I get the 15th of June back, not the 16th as
I would have expected!
This happened under R-1.7.1 on