Displaying 20 results from an estimated 10000 matches similar to: "Again: Variable names in functions"
2005 Feb 08
5
How to get variable names in a function?
Hello,
applying a function to a list of variables I face the following problem:
Let's say I want to compute tables for several variables. I could write a
command for every single table, like
bravo<-c(1,1,2,3,5,5,5,);charly<-c(7,7,4,4,2,1)
table(bravo); table(charly)
> table(bravo); table(charly)
bravo
1 2 3 5
2 1 1 3
charly
1 2 4 7
1 1 2 2
The results are two tables with the
2004 Nov 30
6
How to know if a bug was recognised
Hello!
A problem with special characters seemed to me to be a bug. I sent a mail
to R-windows at r-project.org concerning the problem (see below).
How can I find out, if this is considered as a bug or an error of myself?
Which part of FAQs or documentation did I miss to find the answer?
thanks in advance
Heinz T??chler
-------------------- copy of abovementioned mail ----------
to: R-windows
2005 Feb 04
5
How to access results of survival analysis
Hello,
it seems that the main results of survival analysis with package survival
are shown only as side effects of the print method.
If I compute e.g. a Kaplan-Meier estimate by
> km.survdur<-survfit(s.survdur)
then I can simply print the results by
> km.survdur
Call: survfit(formula = s.survdur)
n events median 0.95LCL 0.95UCL
100.0 58.0 46.8 41.0 79.3
Is
2005 Apr 02
4
factor to numeric in data.frame
Dear All,
Assume I have a data.frame that contains also factors and I would like to
get another data.frame containing the factors as numeric vectors, to apply
functions like sapply(..., median) on them.
I read the warning concerning as.numeric or unclass, but in my case this
makes sense, because the factor levels are properly ordered.
I can do it, if I write for each single column
2005 Aug 10
5
how to write assignment form of function
Dear All,
where can I find information about how to write an assigment form of a
function?
For curiosity I tried to write a different form of the levels()-function,
since the original method for factor deletes all other attributes of a factor.
Of course, the simple method would be to use instead of levels(x) <-
newlevels, attr(x, 'levels') <- newlevels.
I tried the following:
##
2006 May 24
3
How to make attributes persist after indexing?
Dear All!
For descriptive purposes I would like to add attributes to objects. These
attributes should be kept, even if by indexing only part of the object is
used.
I noted that some attributes like levels and class of a factor exist also
after indexing, while others, like comment or label vanish.
Is there a way to make an arbitrary attribute to be kept after indexing?
This would be especially
2004 Nov 30
1
Attn Heinz Tuechler: Re: problem with special characters (ä,ö,ü)
[I tried to send this message privately, but the return address
bounced.]
I think this has been fixed in R-patched, but I doubt if the fix has
been tested in Win98. Could you please download a copy from
<http://cran.r-project.org/bin/windows/base/rpatched.html> and confirm
that it has been fixed?
Duncan Murdoch
On Sat, 27 Nov 2004 23:31:23 +0100, Heinz Tuechler <tuechler at gmx.at>
2005 Sep 08
3
change in read.spss, package foreing?
Dear All,
it seems to me that the function read.spss of package foreign changed its
behaviour regarding factors. I noted that in version 0.8-8 variables with
value labels in SPSS were transformed in factors with the labels in
alphabetic order.
In version 0.8-10 they seem to be ordered preserving the order
corresponding to their numerical codes in SPSS.
However I could not find a description of
2005 Sep 08
3
change in read.spss, package foreing?
Dear All,
it seems to me that the function read.spss of package foreign changed its
behaviour regarding factors. I noted that in version 0.8-8 variables with
value labels in SPSS were transformed in factors with the labels in
alphabetic order.
In version 0.8-10 they seem to be ordered preserving the order
corresponding to their numerical codes in SPSS.
However I could not find a description of
2006 May 23
4
How to call a value labels attribute?
Dear All,
after searching on CRAN I got the impression that there is no standard way
in R to label values of a numerical variable.
Since this would be useful for me I intend to create such an attribute, at
the moment for my personal use.
Still I would like to choose a name which does not conflict with names of
commonly used attributes.
Would value.labels or vallabs create conflicts?
The
2009 Sep 28
4
How to assess object names within a function in lapply or l_ply?
Dear All,
to produce output of several columns of a data frame, I tried to use
lapply and also l_ply. In both cases, I would like to print a header
line containing also the name of the respective column in the data frame.
For example, I would like the following
lapply(data.frame(a=1:3, b=2:4), function(x) print(deparse(substitute(x))))
to produce:
[1] "a"
[1] "b"
and
2006 Jul 27
2
How to get the name of the first argument in an assignment function?
Dear All!
If I pass an object to an assignment function I cannot get it's name by
deparse(substitute(argument)), but I get *tmp* and I found no way to get
the original name, in the example below it should be "va1".
Is there a way?
Thanks,
Heinz
## example
'fu1<-' <- function(var, value) {
print(c(name.of.var=deparse(substitute(var))))}
fu1(va1) <- 3
name.of.var
2008 Nov 06
3
Umlaut read from csv-file
Dear All!
Reading character strings containing an "umlaut"
from a csv-file I find a (to me) surprising
behaviour in R 2.8.0, that I did not notice in R 2.7.2.
A comparison by "==" results in FALSE, while grep does find the aggreement.
See the example below.
The crucial line is x=="div 1-2 Ver?nderungen",
with the result [1] FALSE in R 2.8.0 but
[1] TRUE in R
2006 Mar 15
5
Surv object in data.frame
Dear All,
a Surv object I put in a data frame behaves somehow unexpected (see example).
If I do a Cox regression on the original Surv object it works. If I put it
in a data.frame and do the regression on the data frame it does not work.
Seemingly it has to do with the class attribute, because if I change the
class attribute to let "Surv" appeare first, again it works.
Is this known?
2005 Aug 28
2
stratified Wilcoxon available?
Dear All,
is there a stratified version of the Wilcoxon test (also known as van
Elteren test) available in R?
I could find it in the survdiff function of the survival package for
censored data. I think, it should be possible to use this function creating
a dummy censoring indicator and setting it to not censored, but may be
there is a better way to perform the test.
Thanks,
Heinz T??chler
2017 Sep 07
0
post_processor in rmarkdown not working
Are you sure that you want to read in the output_file in
text <- readLines(output_file, warn = FALSE)?
best regards,
Heinz
Thierry Onkelinx wrote/hat geschrieben on/am 06.09.2017 11:41:
> Dear all,
>
> I'm trying to write a post_processor() for a custom rmarkdown format. The
> goal of the post_processor() is to modify the latex file before it is
> compiled. For some
2005 Mar 29
3
From FAQ 7.21 to a command like apply(sapply(list(f1,f2,f3),is.na),2,sum)
Dear all,
Last December there was a thread regarding the famous FAQ 7.21 "How can I
turn a string into a variable?" and asking what people want to do with
these strings.
My, certainly trivial application would be as follows:
Assume I have a data.frame containing besides others also the columns f1,
f2, ..., fn and I want to create a command like:
apply(sapply(list(f1,f2,f3),is.na),2,sum)
2006 May 05
2
How to access results of survival analysis
Hi List,
A friend of mine recently asked the same question as Heinz T?chler. Since
I've already written the code I'd like to share with the list.
# x is an object returned by "survfit";
# "smed" returns a matrix of 5 columns of
# n, events, median, 0.95LCL, 0.95UCL.
# The matrix returned has rownames as the
# group labels (eg., treatment arms) if any.
smed <-
2008 Nov 09
1
attr.all.equal() and all.equal(attributes(), attributes())
Dear All!
If I try to compare the attributes of two
objects, I find a surprising behaviour of
attr.all.equal(). With identical attributes I
receive the answert NULL. If the attributes
differ, the answer is as expecxted and differences are shown.
all.equal(attributes(), attributes()) instead
returns TRUE, if attributes are equal.
See example:
v <- 1:5
attr(v, 'testattribute')
2008 Dec 19
1
How to write a Surv object to a csv-file?
Dear All,
trying to write a data.frame, containing Surv objects to a csv-file I get
"Error in dimnames(X) <- list(dn[[1L]], unlist(collabs, use.names = FALSE)) :
length of 'dimnames' [2] not equal to array extent".
See example below.
May be, I overlooked something, but I expected
that also data.frames containing Surv objects may be written to csv files.
Is there a