Displaying 20 results from an estimated 10000 matches similar to: "Creating lists from matrices"
2004 Nov 25
2
Turning strings into expressions
Hello,
I am running R 1.9.1 om Windows 2000 SP4. My problem is as follows:
Say I have a dataframe my.frame with column names A and B. I have a string,
>my.string
[1] "A==1 & B==2"
And I would like to retrieve the subset corresponding to my.string, that is,
from my.frame and my.string I would like to get the result of
subset(my.frame,A==1 & B==2)
So I need to find a way
2004 Nov 04
5
Conversion of strings to expressions
Hello,
I'm not sure how to state my question in a technically accurate manner, so
I'll use a short example to clarify my problem:
Say I have a vector,
vec<-c(1,2,3,2)
I would like to be able to "reference" the vector by using the string
containing the name of the vector - that is, I would like to know of some
function which is able to convert the string "vec"
2004 Nov 11
11
Logical "and"
Hello,
I have the following very simple problem:
Say I have two vectors,
a<-c(1,7,4,5,9,11)
b<-c(7,4,9)
I would like to create a vector containing the elements in a which are not in
b.
Obviously, this is possible by writing
a[a!=b[1] & a!=b[2] & a!=b[3]]
But I would like a solution which is applicable to the situation where the
number of elements in b is unknown.
I have
2004 Nov 18
5
Lexical Scoping: eval(expr,envir=)
Hi R-listers,
I am trying to better undertand what we would call "functional paradigm"
use of S/R to better map my programming activities in other languages.
This little function is aimed to create an object (at the end end, it would
have it's own class):
--
myObject =function(){
list(
a=1,
foo=function(b)
{
cat("b:",b)
2004 Nov 09
2
do.call invoking a function with multiple arguments
Hi users,
I am not sure to understand the help page about do.call.
--
do.call(what, args)
args: a _list_ of arguments to the function call. The 'names'
attribute of 'args' gives the argument names.
--
If we take the following sample data:
> (tab=as.data.frame(table(factor(1:10))))
Var1 Freq
1 1 1
2 2 1
3 3 1
4 4 1
5 5
2002 Oct 02
4
Introduction of NA:s
Hello,
I wonder if someone could help me with the following: I have generated 10 000 values from rnorm and now I want to randomly replace 500 of those with NA. The problem is that values indexed between 6-10,16-20,26-30.... only should be considered for replacement. Any suggestions?
Patrik Waldmann
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing
2005 Feb 15
2
special symobol / character
Hi all,
Is it possible to add a permil (or per mille) symbol to
an R plot (I couldn't find this symbol under demo(Hershey) or
the plotmath information).
In some ascii tables it is symbol no. 137.
cheers,
Matt.
[[alternative HTML version deleted]]
2003 Dec 18
3
Summaries
Hello UseRs:
Excuses for my english.
I have a dataset with 65000 records and I'd like to make a summary where I
can view all the values (with the number of times that it repeats) that
there are each column of my dataset.
I tried with summary( ), str( ), but nothing gives me the result that I am
loking for.
Thank you very much.
2004 Nov 04
3
keep dimension of a sub matrix
Hi,
is there any way to keep a sub matrix dimension?
exemple :
i1<-1; i2<-1
j1<-2; j2<-3;
ret <-matrix(1,4,4)[i1:i2,j1:j2] ;
dim(ret) is NULL because the submatrix single col or single row is coerce to a vector automaticaly.
How can i bypass this cast : submatrix->vector ???????
Thank you.
---------------------------------
[[alternative HTML version
2005 Jan 11
4
Matrix to "indexed" vector
I have a matrix that I want to turn into a transformed matrix that
includes the indices from the original matrix and the value. The
matrix is simply real-valued and is square (and large (8k x 8k)). I
want something that looks like (for the 3x3 case):
i j value
1 1 1.0
1 2 0.783432
1 3 -0.123482
2 1 0.783432
2 2 1.0
2 3 0.928374
and so on....
I can do this with for loops, but there is
2005 Mar 22
3
Newbie: Matrix indexing
Hi all,
I need to compute some "occurence matrix": given a zero matrix and a set
of paired indexes, I want to store the number of occurences of each paired
index in a matrix. The paired indexes are stores as an index matrix. I
prefere not to use loops for performances purpose.
Here follows a dummy example:
> occurence <- matrix(0, 2, 2); data
[,1] [,2]
[1,] 0 0
2003 Feb 07
2
My remark on libraries
Hi R community,
These days, I am writing some functions to work with 2-ways frequency
tables ; you know all this tuff about measures of association: Chisq and
derived (phi, cramer's v), tau b, tau c, somer's d and so on.
So I consider all those functions could be gathered in a single R file, as
they are coherent and dealing with the same problem / objective (analysis
of crosstables).
2004 Nov 29
3
Differences between "$" and "[["
Hi,
If I define the following list:
> (l<-list("text-align"="right"))
$"text-align"
[1] "right"
I know that I can't use l$text-align, as the parser will find a '-' operation.
If I want (need) to use special names, as "text-align", I have to enclose
it between "". So I can use:
l$"text-align" or
2004 Apr 27
5
parsing a data file
Hi,
I need to parse a data file (output of a measuring device) of the
following format:
BEGIN RECORD [first record data] RECORD [second
record data] RECORD
[third record data]
END
Line breaks can (and do ;-() occur anywhere. White space behaves very
much like TeX, eg it is not important whether there are one or more
spaces or linebreaks as long as there is one of them. It is a text
file, not
2002 Jun 20
1
Argument visible of addTaskCallback
Hello,
I have a question about addTaskCallback
It is said that the argument visible allows to know wether the result of
the top-level evaluation was printed or not.
Nevertheless, in the following example, I encountered a problem, as it
seems not all printed objects are visible...
Could someone tell me where is the tip?
TIA
2004 May 27
4
extract columns using their names
Hello,
Is there a way to extract multiple columns from a dataframe using their
names instead of their numbers?
Currently I use:
data2 <- data1[, c(1,3,9)]
And I am looking for something like
data2 <- data1[, c("XX","YY","ZZ")]
I use the same dataframe for many purposes, and I run codes that change
the order of the columns every time.
Many thanks,
Adrian
2005 Feb 18
3
Hosting a R Graph Gallery?
Dear R users,
Following some of the recent questions and discussions about the R
plotting abilities, it occurred to me again that it would be very
valuable to have an R graph gallery.
Eric Lecoutre made a very nice example in:
http://www.stat.ucl.ac.be/ISpersonnel/lecoutre/stats/fichiers/_gallery.pdf
It would be very useful to many beginners, but probably also advanced
users of R, to have an
2004 Jun 04
1
[Wish]: Add "..." argument to library function
Hello,
I would find it very usefull to have the ability to load packages with options.
Consider for example the SciViews package Philippe and me are working on.
When loading on Windows, it automatically loads the associated GUI
executable. It should be convenient to have an option not to load the exe
but still have an access to the R functions of the package.
For that, I think a simple change
2005 Jan 14
1
S3/S4 classes performance comparison
Hi R-devel,
If you did read my survey on Rhelp about reporting, you may have seen that
I am implementing a way to handle outputs for R (mainly target output
destinations: xHTML and TeX).
In fact: I does have something that works for basic objects, entirely done
with S4 classes, with the results visible at:
http://www.stat.ucl.ac.be/ROMA/sample.htm
http://www.stat.ucl.ac.be/ROMA/sample.pdf
To
2005 Feb 08
2
Data manipulation
Content-Type: text/plain; charset="iso-8859-1"
Received-SPF: none (hypatia: domain of hellik at web.de does not designate permitted sender hosts)
X-Virus-Scanned: by amavisd-new at stat.math.ethz.ch
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from quoted-printable to 8bit by hypatia.math.ethz.ch id j186djX0017423
X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on