slice.index() in base
On 4/2/2013 6:36 AM, Enrico Bibbona wrote:
Is there any function that extends to multidimentional arrays the
functionalities of row and col which are just defined for matrices?
Thanks, Enrico Bibbona
[[alternative HTML version deleted]]
slice.index() in base
On 4/2/2013 9:53 AM, Enrico Bibbona wrote:
Great!
Thanks a lot, Enrico
2013/4/2 Duncan Murdoch murdoch.dun...@gmail.com
On 02/04/2013 6:36 AM, Enrico Bibbona wrote:
Is there any function that extends to multidimentional arrays the
functionalities of row and col which
abind() (from package 'abind') can take a list of arrays as its first argument,
so in general, no need for do.call() with abind().
As another poster pointed out, simplify2array() can also be used; while abind()
gives more options regarding which dimension is created and how dimension names
PATH, strsplit(Sys.getenv(PATH),
;)[[1]], value=T, invert=T), collapse=;))
(substitute some pattern that matches the unwanted directory for
UNWANTEDPATH, remembering to use four backslashes to match one).
-- Tony Plate
__
R-help@r-project.org
into mvbutils, but it would probably be a significant amount
of work.
-- Tony Plate
On 05/31/2010 09:56 PM, Day, Roger S wrote:
Hello Colleagues,
I've recently become a fan of Mark Bravington's mvbutils package for organizing
analysis projects in a tree.
Using cd(), Save(), fixr(), mlazy
- paste(fData., i, sep=)
df - get(dataName)
... do something with data frame df ...
}
You can also give additional arguments to get() to tell it where to look
(pos=,envir=), and whether to look in parent environments
(inherits=TRUE/FALSE).
-- Tony Plate
matrix(str, ncol=1)
Francesco Napolitano wrote:
Sorry for the dumb question, but I couldn't figure this out myself.
Consider the following:
str - c(abc,def)
array(str, c(2,1))
[,1]
[1,] abc
[2,] def
How can i obtain the outcome of the second instruction without
specifying the number
) else x))
write.table(d1, quote=which(sapply(d, function(x) !is.numeric(x) !is(x,
Date
ticker date price
1 IBM 12/03/2009 120
2 IBM 12/04/2009 123
-- Tony Plate
William Dunlap wrote:
-Original Message-
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org
Try looking in the NAMESPACE file (in the same directory as the
DESCRIPTION file).
-- Tony Plate
David Scherrer wrote:
Dear all,
I get the error
Error in namespaceExport(ns, exports) :
undefined exports function1 , function2
when compiling or even when I roxygen my package. The two
grep(^[[:alpha:]]+[ \t]*\\([ \t]*[0-9]+[ \t]*\\), x)
[1] 1 2 3 4
-- Tony Plate
Dennis Fisher wrote:
Colleagues,
I am using R (2.9.2, all platforms) to search for a complicated text
string using regular expressions. I would appreciate any help you can
provide.
The string consists
and Erkki Oja *
(http://www.cis.hut.fi/aapo/papers/IJCNN99_tutorialweb/) -- it's an
excellent introduction.
-- Tony Plate
Joel Fürstenberg-Hägg wrote:
Ok, so then the S gives the individual components, good. Thanks Tony!
But what about the principal components from the PCA plot, how
(, x, ))), eval), ncol=ncol(x),
dimnames=dimnames(x))
X Y
row1 Character,2 b
row2 c d
- Tony Plate
esterhazy wrote:
Yes, thanks for this, this is exactly what I want to do.
However, I have a remaining problem which is how to get R to understand that
each entry in my
. And if that's the case, it would make
sense to code it in C.
-- Tony Plate
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
any ideas?
thank you and best regards,
stefan
__
R-help@r-project.org mailing list
https://stat.ethz.ch
(the estimated source matrix) and
A (the estimated mixing matrix). Are these what you want?
-- Tony Plate
Joel Fürstenberg-Hägg wrote:
Hi all,
Does anyone know how to get the independent components and loadings from an
Independent Component Analysis (ICA), as well as principal components
Character,5 g
3 Character,3 Character,3 Character,3
4 Character,5 Character,3 Character,2
5 Character,2 i Character,2
y[1,3]
[[1]]
[1] b
-- Tony Plate
esterhazy wrote:
Hi,
I have a matrix with two columns, and the elements of the matrix are
vectors.
So for example, in line 3
the
values of D in the SVD of a matrix -- you could look for that if you have
demanding computations (e.g., the sqrts of the eigen values of the covariance
matrix of scaled x: sqrt(eigen(var(scale(x, center=T, scale=F)),
only.values=T)$values)).
-- Tony Plate
zubin wrote:
Hello, not understanding
that doesn't confuse things by having non-standard evaluation
rules:
f - function(a=1, b=2) cat(a=, a, b=, b, \n)
b
Error: object 'b' not found
f(b - 33)
a= 33 b= 2
b
[1] 33
f(b=33)
a= 1 b= 33
-- Tony Plate
Feng Li wrote:
Dear R,
Why rm(list-ls()) gives an error but rm(list=ls()) not? I
x - matrix(sample(0:1, 1200, replace=T, prob=c(0.952, 0.048)), ncol=30)
table(x)
x
01
1131 69
x - matrix(sample(0:1, 1200, replace=T, prob=c(0.952, 0.048)), ncol=30)
table(x)
x
01
1151 49
bikemike42 wrote:
Dear All,
I am trying to create an artificial binary matrix
[ii])
row colcor
a 1 2 -0.3767034
b 2 3 0.6040273
-- Tony Plate
Lee William wrote:
Hi! All,
I am working on a correlation matrix of 4217x4217 named 'cor_expN'. I wish
to obtain pairs with highest correlation values. So, I did this
b=matrix(data=NA,nrow=4217,ncol=1)
rownames(b
, data=myDat[1:10,])
predict(fit, myDat[11:16,])
$class
[1] c c c b c a
Levels: a b c
...
-- Tony Plate
BostonR wrote:
When I import a simple dataset, run LDA, and then try to use the model to
forecast out of sample data, I get a forecast for the training set not the
out of sample set. Others
must add a row to all the
slices. When I read to add a row in place to a single table of the 3 dimensional
array it sounds like you might be trying to do something that's not possible with R
arrays. However, if I could see your examples, then I probably give more help.
-- Tony Plate
Another
R doesn't access arrays like C, use [i,j] to access a 2-d array, e.g.:
my_array - array(0,dim=c(2,2))
for(i in seq(1,2,by=1)){
+ for(j in seq(1,2,by=1)){
+ my_array[i,j] = i+j
+ }
+ }
my_array
[,1] [,2]
[1,]23
[2,]34
tdm wrote:
Hi,
Can someone please give
Try playing around with the oma setting in par() -- it sets the outer
margins, which by default are zero.
The following shows the mtext label for me, using the windows device:
par(mfrow=c(2,2))
par(oma)
[1] 0 0 0 0
par(oma=c(0,0,2,0))
for (i in 1:4) plot(0:1,0:1)
mtext(text = my test plots,
test$x doesn't evaluate the function, you want something like test(1,2)$x, e.g.:
test - function(i, j){
x - i:j
y - i*j
z - i/j
return(list(x=x,y=y,z=z))
}
test(1,2)$x
[1] 1 2
test(1,2)$y
[1] 2
test(1,2)$z
[1] 0.5
Or if you want to avoid evaluating your
x - data.frame(d=letters[1:3], e=letters[3:5])
lookuptable - c(a=aa, c=cc, e=ee)
match.or.keep - function(x, lookuptable) {if (is.factor(x)) x - as.character(x);
m - match(x, names(lookuptable)); ifelse(is.na(m), x, lookuptable[m])}
# to return a matrix
apply(x, 2, match.or.keep,
(3,...) will generate samples from 1, 2, and 3.)
-- Tony Plate
Jason Rupert wrote:
Say I have the following data:
house_number-floor(runif(100, 200, 600))
water_evaluation-c(No water damage, Water damage, Water On, Water off, water pipes
damaged, leaking water)
water_evaluation_selection-floor
(*, dimnames)=List of 2
..$ : NULL
..$ : chr [1:6] GBP=X.Open GBP=X.High GBP=X.Low GBP=X.Close ...
Indexed by objects of class: [Date] TZ: GMT
xts Attributes:
List of 2
$ src: chr yahoo
$ updated: POSIXct[1:1], format: 2009-09-24 19:58:01
-- Tony Plate
Bogaso wrote:
Hi,
I wanted to download
also depend on whether intermediate results are kept in
CPU registers, which sometimes have higher precision than 64 bits. Usually,
they're nothing to worry about, which is one of the major reasons that
all.equal() has a non-zero default for the tol= argument.
-- Tony Plate
Tal Galili wrote
You could try setting options(error=function() NULL). This should cause R in
batch mode to continue running after an error (the same way it does in
interactive mode.)
-- Tony Plate
Nir Shachaf wrote:
Hi All,
I am running an Rscript with a bunch of algorithms that are UNSTABLE
under some
2
colSums(abind(along=0, x2))
[,1] [,2]
[1,] 1.768406 -1.534413
[2,] -1.534413 3.890200
-- Tony Plate
megh wrote:
Hi,
I have created a list object like that :
x = vector(list)
for (i in 1:5) x[[i]] = rnorm(2)
x
Now I want to do two things :
1. for each i, I want to do
Did you try putting
library(your-package-name, char=TRUE)
at the start of the examples?
-- Tony Plate
Rebecca Sela wrote:
I am creating an R package. I ran R CMD check on the package, and everything
passed until it tried to run the examples. Then, the result was:
* checking examples
# intersect() returns columns that are the same in each dataframe, not rows
intersect(x, y)
c
1 C
2 D
intersect(x1, y)
a c
1 1 C
2 2 D
-- Tony Plate
jim holtman wrote:
You are missing a comma:
common - intersect(data_frame_x[,c(Latitude, Longitude)],
data_frame_y[,c(Latitude,Longitude
without at least seeing some cut'n'pasted
transcripts. The output of traceback() would also be useful.
-- Tony Plate
Gang Chen wrote:
I've written a function, myFunc, that works fine with myFunc(data,
...), but when I use apply() to run it with an array of data
apply(myArray, 1, myFunc, ...)
I get
R doesn't keep track of when objects were created, so that's not possible.
If this is important to you, you could look at the 'trackObjs' package, which
does this and also stores individual objects in individual files (and writes
them to the file when they are changed in R).
-- Tony Plate
States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] TimeWarp_0.7abind_1.2-0 trackObjs_0.8-0 tap.misc_1.0
[5] bmc.misc_1.0RtTests_0.1-5
-- Tony Plate
Pedro de Barros wrote:
Hi All,
I am
)
If none of this is what you want, you could consider storing the matrices in a
list, as another poster suggested.
-- Tony Plate
Suyan Tian wrote:
I am trying to combine two arrays with different dimensions into one.
For example
The first one is
1 2 3
4 5 6
The second one is
7 8
9 10
If you return the value as named list, you get your answer
using unlist(res, recursive=F):
res - lapply(1:2, function(i) {val - list(i);
names(val) - paste(Hugo, i, sep=_); return(val)})
unlist(res, rec=F)
$Hugo_1
[1] 1
$Hugo_2
[1] 2
Antje wrote:
Oh true, this would solve the problem
.)
-- Tony Plate
--- Edward Wijaya [EMAIL PROTECTED] wrote:
You might try cron job under Windows.
http://drupal.org/node/31506
HTH.
- Edward
On Thu, May 22, 2008 at 8:51 AM, Thomas Pujol
[EMAIL PROTECTED] wrote:
I am using R in a Windows environment.
I store my data in a Microsoft SQL database
The most common objects with the name of RGUI.EXE have
yet to be classified as safe by our research department.
So, I suspect that they don't actually classify it as a
virus, they just haven't classified it as safe... (I
couldn't see any email contact address on their web page.)
-- Tony Plate
Try this:
data1 - list(a = 1, b = 2, c = 3)
data2 - list(a = 4, b = 5, c = 6)
data3 - list(a = 3, b = 6, c = 9)
comb - list(data1 = data1, data2 = data2, data3 = data3)
sapply(comb, [[, a)
data1 data2 data3
1 4 3
# Also, this can be useful:
comb[[c(data2, b)]]
[1] 5
[EMAIL
If the increases or decreases could be any size,
rle(sign(diff(x))) could do it:
x - c(1, 2, 3, 4, 4, 4, 5, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1)
r - rle(sign(diff(x)))
r
Run Length Encoding
lengths: int [1:5] 3 2 2 5 4
values : num [1:5] 1 0 1 -1 0
i1 -
this option to No.
I see 5 identical posts with the subject Several questions
about MCMClogit on R-help recently.
-- Tony Plate
j t wrote:
Sorry to bother your.
I am trying to post my question for more than 10 times, but I still
didn't see it.
It drives my crazy!!!
It is a test for posting some
Another way is using straightforward indexing:
x - cbind(trips=c(1,3,2), y=1:3, z=4:6)
x
trips y z
[1,] 1 1 4
[2,] 3 2 5
[3,] 2 3 6
# generate row indices with the appropriate
# number of repeats
ii - rep(seq(len=nrow(x)), x[,1])
[1] 1 2 2 2 3 3
# use these indices to
If you're using Rgui under Windows, see FAQ 7.1:
7.1 When using Rgui the output to the console seems to be delayed.
This is deliberate: the console output is buffered ...
(the FAQ says how to turn it off -- it's a menu item).
Vidhu Choudhary wrote:
Hi All,
My R code takes very long time to
simpleLoess() with,
and then try calling stats:::simpleLoess() directly. (Of course you have to be
careful with this because this is not using the published API).
-- Tony Plate
Sudipta Sarkar wrote:
Respected R experts,
I am trying to apply a user function that basically calls and
applies the R
new vars to an existing .RData file --
that's why I wrote the above to save them in a .RData file that's different to
the one that contained the old variables.
-- Tony Plate
Ng Stanley wrote:
Read and reread, can't make out. Will try an experiment later
On Wed, Apr 16, 2008 at 7:51 PM
argument name collisions).
-- Tony Plate
Thank you very much.
Best,
Ravi.
---
Ravi Varadhan, Ph.D.
Assistant Professor, The Center on Aging and Health
Division of Geriatric Medicine
, but here are some alternatives:
data.frame(a=numeric(0), b=numeric(0)) # include 9 arguments if you like
[1] a b
0 rows (or 0-length row.names)
as.data.frame(rep(list(a=numeric(0)), 9))
[1] a a.1 a.2 a.3 a.4 a.5 a.6 a.7 a.8
0 rows (or 0-length row.names)
-- Tony Plate
cheers
my.t.test.p.value(c(1,2))
[1] 0.2048328
hope this helps,
Tony Plate
Regards
Petr
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http
.
o Fixed bug that stopped track.stop(all=TRUE) from working
-- Tony Plate
___
R-packages mailing list
[EMAIL PROTECTED]
https://stat.ethz.ch/mailman/listinfo/r-packages
__
R-help@r-project.org mailing
Marie Pierre Sylvestre wrote:
Dear R users,
I am analysing a very large data set and I need to perform several data
manipulations. The dataset is so big that the only way I can play with it
without having memory problems (E.g. cannot allocate vectors of size...)
is to write a batch script
3 4 5 10 12 13 14
-- Tony Plate
Martin
MS HTH,
MS Marc Schwartz
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
large proportion of the situations
where people reach for parse/eval, there's a neater, cleaner more direct
way of doing the job.)
-- Tony Plate
Talbot Katz wrote:
Hi.
I'm looking for an R equivalent to something like function pointers in C/C++.
I have a search procedure that evaluates
'spectrum' is a data.frame before the code fragment you've shown)
hope this helps,
Tony Plate
Johannes Graumann wrote:
Why is class(spectrum[[Ion]]) after this factor?
spectrum - cbind(spectrum,Ion=rep(,
nrow(spectrum)),Deviation.AMU=rep(0.0, nrow(spectrum)))
slowly going crazy ...
Joh
probably storing it in a data frame.
AFAIK, there is no 3d object in R that can store mixed-type data like a
data frame can. An array object in R has to have the same data type for
every column etc.
-- Tony Plate
dave mitchell wrote:
Dear all,
Possibly a rudimentary question, however any help
Try these:
x - matrix(rnorm(100), ncol=10)
persp(x)
contour(x)
Also, look at the R graph gallery: http://addictedtor.free.fr/graphiques/
-- Tony Plate
threshold wrote:
Hi All, simple question:
do you know how to graph the following object/matrix in a 'surface manner':
[,1
settings)
For more info, look in the trackObjs package.
-- Tony Plate
Dong-hyun Oh wrote:
Dear UseRs,
I would like to know the created time and date of specific object.
Is there any function for it?
Thank you in advance.
Sincerely,
__
R-help
Mike Waters wrote:
Tony Plate wrote:
[...]
You don't say if this an R-specific problem, or if it afflicts your
computer system clock as well.
Thanks, I should have noted that my computer system clock is fine, and as
far as I can tell it (correctly) believes we are still in Daylight
Saving
/datetime.c:do_asPOSIXlt, and it looks like this isdst value
comes from a call to localtime() from localtime0() ...
thanks in advance for any help,
Tony Plate
PS. I do not see the same problem in an old version of R (2.2.1)
running under Ubuntu Linux:
Sys.timezone()
[1]
as.POSIXlt((d - Sys.time()), EST5EDT
that they believe some particular advice is poor
practice? Ideally, these annotations would be easily searchable so
that other users could find and fix or respond to them.
-- Tony Plate
Hadley
__
R-help@r-project.org mailing list
https://stat.ethz.ch
a - c(2, 3, 7, 5)
b - c(4, 7, 8, 9)
mapply(seq, a, b)
[[1]]
[1] 2 3 4
[[2]]
[1] 3 4 5 6 7
[[3]]
[1] 7 8
[[4]]
[1] 5 6 7 8 9
mapply(sum, a, b)
[1] 6 10 15 14
hope this helps,
Tony Plate
Anya Okhmatovskaia wrote:
Hi,
I am very new to R, so I apologize if I have missed some
suggest posting more details back to the list, e.g., what OS you
are using, and a directory listing that shows file sizes and permissions
(i.e., as you get with 'ls -l' on Unix systems.)
-- Tony Plate
Hongxiao Zhu wrote:
Hi,
I tried to load a .RData object on unix system using R, it gives error
, but essentially disable use of a particular file. I generally
fix this by resetting ownership and all permissions using Windows
dialogs. It sounds like you need to get your sysadmins to help you sort
this problem out.
-- Tony Plate
Hongxiao Zhu wrote:
Tony,
Thanks for return. Actually, the data object
Here's a function that does what I think you want to do:
attach.firstvar - function(file) {
+ tmpenv - new.env()
+ vars - load(file, envir=tmpenv)
+ x - get(vars[1], envir=tmpenv, inherits=FALSE)
+ if (is.list(x))
+ attach(x, name=vars[1])
+ return(vars)
+ }
x -
64 matches
Mail list logo