Displaying 20 results from an estimated 20000 matches similar to: "filling values in a vector using smaller vector"
2008 Jul 11
1
Subsetting an array by a vector of dimensions
Hi
Is it possible to subset an n-dimensional array by a vector of n dimensions? E.g. assume I have
> x <- array(1:24, dim=2:4)
> x[1,1,2]
[1] 7
> dims <- c(1,1,2)
I would like a function that I can supply x and dims as parameters to, and have it return 7. Also, I would like to do something like:
> x[1,1,]
[1] 1 7 13 19
> dims2<- c(1,1,NA)
And have a function of x and
2005 Jul 07
3
xmat[1, 2:3] <- NULL
I have a situation where I'm filling out a dataframe
from a database. Sometimes the database query doesn't
get anything, so I end up trying to place NULL in the
dataframe like below.
> temp <- NULL
> xmat <- as.data.frame(matrix(NA, 2, 3))
> xmat[1, 2:3] <- temp
Error in if (m < n * p && (n * p)%%m)
stop(gettextf("replacement has %d items, need %d",
2006 Feb 03
2
all.equal() and which()
Please excuse the lack of a complete dataset here, if its needed I'll be
happy to provide it.
Can anyone show me how to rewrite this?
Browse[1]> time(data)[24210:24220]
[1] 24.209 24.210 24.211 24.212 24.213 24.214 24.215 24.216 24.217
[10] 24.218 24.219
Browse[1]> which(time(data)==24.211)
numeric(0)
I'm assuming its an eps fault but
which(all.equal(time(data),24.211))
dosnt
2005 Jan 03
3
spreadsheet addiction
There's a new page on the Burns Statistics website
http://www.burns-stat.com/pages/Tutor/spreadsheet_addiction.html
that looks at spreadsheets from a quality assurance perspective. It
presents R as a suitable alternative to spreadsheets. Also there are
several specific problems with Excel that are highlighted, including
the status of statistical functionality in Excel.
Patrick Burns
Burns
2008 Jul 13
2
multiple names to assign
'assign' does not give a warning if 'x' has length
greater than 1 -- it just uses the first element:
assign(c('a1', 'a2'), 1:2)
One way of thinking about this is that people using
'assign' get what they deserve. The other is that it is
used seldom enough that adding a warning isn't going
to slow things down appreciably.
Patrick Burns
patrick at
2005 Sep 21
2
MGARCH estimation
Hi R-users
Can the users let me know how to do MGARCH estimate (Bivariate GARCH)
and volatility forecast for 2 variables in R.
thanks and regards
snvk
2006 Jan 27
3
draft of Comment on UCLA tech report
You may recall that there was a discussion of a technical
report from the statistical consulting group at UCLA.
I have a draft of a comment on that report, which you
can get from
http://www.burns-stat.com/pages/Flotsam/uclaRcomment_draft1.pdf
I'm interested in comments: corrections, additions, deletions.
Patrick Burns
patrick at burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
2005 Aug 29
5
Testing if all elements are equal in a vector/matrix
Is there a canonical way to check if all elements of a vector or matrix are
the same? Solutions below work, but look hackish to me.
> x <- rep(1, 10)
> all(x == x[1]) # == operator does not provide for small differences
[1] TRUE
> isTRUE(all.equal(x, rep(x[1], length(x)))) # ugly
[1] TRUE
Best,
Vincent
--
Vincent Goulet, Associate Professor
??cole d'actuariat
2006 Feb 23
2
Problem with List() Inside Function
I have a function declared thus.
FirstEigenvectorBoundary.Training <-
function(InputFileName='C:/Samples2/PT_Amp.txt',
Header=TRUE, Colour="red")
Inside the function, I have the following call
out<-list(x=Eigenvectors[2:(NumMetricsSelected+1),1],
y=-0.8, z=NumMetricsSelected);
NumMetricsSelected has the value 2 and Eigenvectors
has the following form
[,1]
2005 Oct 07
2
Assign references
Folks,
I've run into trouble while writing functions that I hope will create
and modify a dataframe or two. To that end I've written a toy function
that simply sets a couple of variables (well, tries but fails).
Searching the archives, Thomas Lumley recently explained the <<-
operator, showing that it was necessary for x and y to exist prior to
the function call, but I haven't
2006 Nov 24
2
vector problem
Hello out there,
i am not yet that experienced and trying to my best on a real survey.
but i am stuck with a little matrix / vector problem.
my vector of answers could have a length of 3 or only one. i want to
rbind all the answers into one matrix. (one vector for each participant)
answers vectors for one participant could look like:
p1: 100
p2: 20 80
p3: 40 10 50
i have the following
2007 Jun 15
5
removing values from a vector, where both the value and its name are the same?
I have an array such as:
x=c(sum=77, min=4,max=9, count=5, min=4,max=9, count=8 , test=77)
I wish to remove values where both the name and the value are identical.
eg. i wish to end up with:
x2=c(sum=77, min=4,max=9, count=5, count=8, test=77)
What is the "best" way to do this?
---------------------------------
Park yourself in front of a world of choices in alternative
2005 Oct 31
2
How can I test temporal autocorrelation of binary data?
Hi,
I have a binary (o/1 - coded) data set and want to test it's autocorrelation
structure. Is that function implemented in R?
Can I use the ACF - funtion with binary data?
Thanks for your help,
Daniel
2008 Jul 15
2
Regression problem
Hello all,
I am new to r programmeand need help. I want to do
multiple linear regression analysis. say, I have two matrix 'x' and 'y'. I
want, 'x' as my response variable and 'y' as predictor.
Each time one column of 'x' will be the response, say x[,1], then next x[,2]
and so on. And also I need to store the coefficients in a matrix form.
2006 Jul 26
2
R vs. Stata
I have read some very good reviews comparing R (or Splus) to SAS. Does
anyone know if there are any reviews comparing R (or Splus) to Stata? I
am trying to get others to try R in my department, and I have never used
Stata.
Regards, -Cody
Cody Hamilton, Ph.D
Institute for Health Care Research and Improvement
Baylor Health Care System
(214) 265-3618
This e-mail, facsimile, or letter
2004 Mar 26
3
regression problem
i need to know how to estimate a linear regression whose coefficients sum
to zero
2006 Nov 07
1
S-poetry as book
Hi,
Is there a printed version of S-poetry which can purchased or would I have
to print out and bind it myself?
Regards,
Benjamin
--
Benjamin Otto
Universitaetsklinikum Eppendorf Hamburg
Institut fuer Klinische Chemie
Martinistrasse 52
20246 Hamburg
[[alternative HTML version deleted]]
2006 May 16
1
variable row names
Hy all,
I wish to use a variable as rownames for a set of datas.
By example :
> nom<-"toto"
> prenom<-"tutu"
> res<-c(1,2)
> res<-t(res)
> res
[,1] [,2]
[1,] 1 2
> colnames(res)<-c(nom,prenom)
> res
toto tutu
[1,] 1 2
> nom
[1] "toto"
>
I wish to call the rowname by the
2007 Mar 15
2
Cannot allocate vector size of... ?
Hello all,
I've been working with R & Fridolin Wild's lsa package a bit over the
past few months, but I'm still pretty much a novice. I have a lot of
files that I want to use to create a semantic space. When I begin to run
the initial textmatrix( ), it runs for about 3-4 hours and eventually
gives me an error. It's always "ERROR: cannot allocate vector size of
xxx
2006 May 29
2
Analog to matlab repmat function
Hello,
I'm trying to switch from Matlab to R-project, and having some difficulties.
I make a use of multidimensional matrices. For example, I need to extract
mean from one of the dimensions:
% we have matrix data of size: 130 x 11 x 350 x 2
data = data - repmat(mean(data,3),[130 1 1 1]);
In R project I managed to do that in a very pervarsive way:
# mean(data,3) in R
base <-