Displaying 20 results from an estimated 10000 matches similar to: "syntax to restrict coefficient in lm()"
2008 Aug 19
4
converting coordinates from utm to longitude / latitude
Hi,
is there a function in R to convert data read with read.shape and which is originally in UTM coordinates into longitude / latitude coordinates?
I found the convUL() function from the PBSmapping package but I have no idea how I could apply that to the read.shape object.
Many thanks,
Werner
__________________________________________________
Do
sragenden Schutz gegen Massenmails.
2006 Apr 05
5
List to Array
Hi,
this is probably the easiest thing to do but I manage
not finding the answer:
I have a list with matrices of exact same format and
headers. Now I would like to transform the list into
an normal array. What is the proper way to do this?
as.array changes the entire format and right now I
only found the method of creating a new array, going
through the entire list and copy the matrix in each
2010 Jul 01
3
Double Integration
Dear R helpers
I am working on the Bi-variate Normal distribution probabilities. I need to double integrate the following function (actually simplified form of bivariate normal distribution)
f(x, y) = exp [ - 0.549451 * (x^2 + y^2 - 0.6 * x * y) ]
where 2.696 < x < 3.54 and -1.51 < y < 1.98
I need to solve something like
INTEGRATE (2.696 to 3.54) dx INTEGRATE [(-1.51 to 1.98)]
2006 May 12
3
optimal way to compute matrix subtotals?
Hi!
I have large matrices, one column per variable and I have a vector of factors / grouping symbols. Then I am computing subtotals for the groups but it takes pretty long and thus I wanted to ask if there is a better way to do it or if this is already the best way:
subTotals <- function(x, groupvec) do.call("rbind",lapply(split(x,groupvec),colSums,na.rm=T))
Thanks reading my
2006 Jan 10
5
matching country name tables from different sources
Hi,
Before I reinvent the wheel I wanted to kindly ask you for your opinion if there is a simple way to do it.
I want to merge a larger number of tables from different data sources in R and the matching criterium are country names. The tables are of different size and sometimes the country names do differ slightly.
Has anyone done this or any recommendation on what commands I
2008 Apr 11
2
How to fill out some columns?
Dear R users,
I'm working with 2 data sets which look like (for example) dx and dy in the
next code:
# Seed
set.seed(4)
# First data frame
dx=matrix(rnorm(6*5),ncol=6)
colnames(dx)=LETTERS[1:6]
# Second data frame
dy=matrix(rnorm(3*5),ncol=3)
colnames(dy)=c('A','C','E')
As you will notice, some columns in both data sets have the same names. At
the end, what I need
2011 Aug 11
1
Splitting data
I want to implement the following algorithm in R:
I want to split my data, use a t test to compare both means of the groups to see if they significantly differ from each other. If this is a yes (p < alpha) I want to split again (into 4 groups) and do the same procedure twice, and stop otherwise (here the problem arises). As a final result I would have different groups of data.
I made some
2008 Jul 27
4
Object-oriented programming in R for Java programmers?
Hi,
I was wondering if anybody might have a reference for
me: My R code is growing and getting more and more
confusing. Thus, I figure it's time to switch to
object-oriented again. I have done oo programming in
C++ and Java before but the first few tutorial on R oo
were a bit confusing for me.
Is there any brief tutorial on oo programming in R
especially for people who have done oo in Java
2002 Mar 21
1
legend - bug with argument angle (PR#1404)
When legend() is used with the angle argument as follows, not only the
boxes beside the legend text, but also the whole legend box is filled
with shading lines.
I think this is not intended:
plot(1:10)
legend(8, 4, c("A", "B"), angle=c(10, 80), fill=NULL, density=20)
I'd suggest as a fix (legend.R of R-1.5.0):
25c25
< rect2 <- function(left, top, dx, dy,
2012 Oct 10
3
Generating random geographical coordinates
Dear all,
I have two coordinates vectors, say X and Y of length n.
I want to generate for each couple of coordinates X1,Y1 X2,Y2
X3,Y3....Xn,Yn a random coordinate which is located in a square define
as X +/- dx and Y +/- dy.
I saw the runif function which can generate for just one value at a time
what I want : runif(1, X - dx, X + dx) for X and runif(1, Y - dy, Y +
dy) for Y.
I would like
2005 Dec 08
1
kronecker(... , make.dimnames=TRUE)
Hi
I'm using kronecker() with a matrix and a vector. I'm interested in
the column names that kronecker() returns:
> a <- matrix(1:9,3,3)
> rownames(a) <- letters[1:3]
> colnames(a) <- LETTERS[1:3]
> b <- c(x=1,y=2)
> kronecker(a,b,make.dimnames=TRUE)
A: B: C:
a:x 1 4 7
a:y 2 8 14
b:x 2 5 8
b:y 4 10 16
c:x 3 6 9
c:y 6 12 18
>
The
2010 Jan 19
4
Remove term from formula for predict.lm
Hi,
probably just a quick question: can I somehow change the formula used with predict? E.g., the regression was run on "y ~ u + v + w" but for the prediction the term v should be removed from the formula contained in the regression object and only "y ~ u + w" be used.
I could use model.matrix etc. to do the predictions but it would be very helpful to know a simpler way.
2008 Feb 21
2
column name handling and long labels
Hi,
I have two loosely related questions which could make
my live again a bit easier:
1) Is there a simple way to select a range of columns
in a data frame using column names?
I am thinking of something like mydf[1,"col4":"col8"]
2) I have a data frame with many columns and they all
have short variable names which is good in most cases
but sometimes it would be nice to have
2009 Mar 02
4
portable R editor
Hi,
I have been dreaming about a complete R environment on my USB stick for a long time. Now I finally want to realize it but what I am missing is a good, portable editor for R which has tabs and syntax highlighting, can execute code, has bookmarks and a little project file management facility pretty much like Tinn-R has those. I like Tinn-R but it seems like there is only a very old version of
2006 Apr 21
4
Considering port of SAS application to R
Hi there!
I am considering to port a SAS application to R and I would like to hear your opinion if you think this is possible and worthwhile. SAS is mainly used to do data management and then to do some aggregations and simple computations on the data and to output a modified data set. The main problem I see is the size of the data file. As I have no access to SAS yet I cannot give real details
2012 Nov 27
2
in par(mfrow=c(1, 2)), how to keep one half plot static and the other half changing
Hi,
I'm trying to plot something in the following way and would like if
you could help:
I'd like in a same plot window, two plots are shown, the left one is a
bird-view plot of the whole data, the right half keep changing, i.e.,
different plots will be shown up on request, so that when I
select/click on some where in the left plot, the right plot will be
the corresponding plot.
What I
2008 Feb 28
3
Collapse an array
Suppose I have a 4-D array X with dimensions (dx, dy, dz, dp). I want
to collapse the first 3 dimensions of X to make a 2-D array Y with
dimensions (dx*dy*dz, dp). Instead of awkward looping, what is a good
way to do this? Is there a similar function like reshape in Matlab?
Thanks,
Gang
2008 Feb 26
2
Custom LaTeX tables
Hello,
I am very happy that I have Sweave and R to write my
papers. But I still have to do some tables by hand
since I have not found out how I can customize the
latex tables produced by R further (I mainly use
xtable()). Like for instance, I have a table which
needs an extra row every few rows as a group header
and sometimes I want some extra horizontal lines in
the table and also a multicolumn
2012 Jul 29
1
Return od functions
Hi!
I have some questions about R function. I try to write a function for
multi-returns. The function code is as attachment.
dgp.par<-function(ai, bi, t, n)
{
t0<-t+20
y0<-matrix(0, nr=t0, nc=n)
y0[1,]<-ai/(1-bi)
for(tt in 2:t0)
{ y0[tt,]<-ai+bi*y0[tt-1,]+rnorm(n, 0, 1) }
y<-y0[21:t0,]
x<-y0[20:t0-1,]
z<-y0[19:t0-2,]
z<-z[2:t,]
dy<-y[2:t,]-y[1:t-1,]
2010 Jul 19
5
par("uin") ?
I inherited a function written either for an older version of R or SPlus
to draw a brace, "{", in a graph. It uses par("uin") to determine the
scaling of the
quarter circles that make up segments of the brace, but that setting
doesn't
exist in current R.
I'm guessing that, in the function below, ux, uy can be defined from
par("usr") and