Displaying 20 results from an estimated 500 matches similar to: "calculations on columns with partially matching names"
2009 Aug 10
4
problem selecting rows meeting a criterion
When I try to select only those rows from the following data frame, called
"data", in which X > Y
X Y V3
2 2 1 8.062258
3 3 1 2.236068
4 4 1 6.324555
5 5 1 5.000000
6 1 2 8.062258
8 3 2 9.486833
9 4 2 2.236068
10 5 2 5.656854
11 1 3 2.236068
12 2 3 9.486833
14 4 3 8.062258
15 5 3 5.099020
16 1 4 6.324555
17 2 4 2.236068
18 3 4 8.062258
20 5 4 5.385165
21 1 5 5.000000
2010 May 06
2
splitting character strings and converting to numeric vectors
This seemingly should be quite simple but I can't solve it:
I have a long character vector of geographic data (data frame column named
"XY") whose elements vary in length (from 11 to 14 chars). Each element is
structured as a set of digits, then an underscore, then more digits, e.g:
> data.frame(head(as.character(XY)))
head.as.character.XY..
1 -448623_854854
2
2010 Mar 11
3
NAs and row/column calculations
I continue to have great frustrations with NA values--in particular making
summary calculations on rows or cols of a matrix containing them. For
example, why does:
> a = matrix(1:30,nrow=5)
> is.na(a[c(1:2),c(3:4)]);a
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] 1 6 NA NA 21 26
[2,] 2 7 NA NA 22 27
[3,] 3 8 13 18 23 28
[4,] 4 9 14 19 24 29
2003 May 30
2
Rsyncing Problem with - character!
Dear Rsync Users,
Please can I have a bit of rsync advice?
I am trying to rsync a file called.
'Draft text - with Holley comments.doc' from machine a to machine b.
Unfortunately this isn't working because I think rsync recognises the -
character and thinks it's an option.
I have tried escaping this out as well as putting it all in " " but
neither seems to work
2010 May 12
1
removing duplicate rows
I'm trying to identify and remove rows in a data frame that are duplicated
only on particular columns within it (i.e. not on all columns). The
"unique" function looks for uniqueness across all columns of a data frame.
Identifying unique rows based only on specific columns of interest returns
only those columns, not all of the columns in the original frame. I tried
this, and then
2011 Feb 09
1
Adding labels into lattice's barchart
*** APOLOGIZES FOR THOSE READING THE LIST THROUGH NABBLE THIS WAS ALREADY POSTED THERE BUT NOT FORWARDED TO THE LIST FOR SOME UNKNOWN REASON ***
I have a dataset that looks like:
$ V1: factor with 4 levels
$ V2: factor with 4 levels
$ V3: factor with 2 levels
$ V4: num (summing up to 100 within V3 levels)
$ V5: num (nr of cases for each unique combination of V1*V2*V3 levels)
Quite new to
2006 Oct 06
1
sparklines in lattice
Dear R-help,
Has anyone implemented sparklines in the strips of a lattice plot? What I have in mind is, say, highlighting that part of a time series that one is examining in more detail in a set of lattice plots.
Regads,.
Mark Difford.
PS: (Andreas Loffler has implemented a simple but functional version for
TeX/LaTeX:
http://www.tug.org/tex-archive/help/Catalogue/entries/sparklines.html)
2009 Jul 23
5
error message: .Random.seed is not an integer vector but of type 'list'
I'm trying to run this simple random sample procedure and keep getting the
error message shown. I don't understand this; I've designated x as a
numeric vector, so what is going on here? Thanks.
> x = as.vector(c(1:12));x
[1] 1 2 3 4 5 6 7 8 9 10 11 12
> mode(x)
[1] "numeric"
> sample(x, 3)
Error in sample(x, 3) :
.Random.seed is not an integer vector
2011 Nov 22
1
glht for lme object with significant interaction term
Dear all,
I'm working on some data from an experiment on the breeding behavior of
birds. In short, I have been measuring how the time spent on performing a
certain task (variable 'mean_on_active') differs over time (variable 'day',
2 levels) across three experimental categories (variable 'treat'; levels
'C', 'R', 'E'). The model shows a
2006 Jan 23
3
ordering a data frame to same order as a chr vector
Hi all,
I've got a data frame that has an identical column to a chr vector. I would
like to use the chr vector to order the rows of the data frame to be
identical to the order in the chr vector (the contents of the chr vector are
completely identical to one col of the data frame), but this is proving
trickier than it sounds..
Any help would be much obliged,
-Ken
2009 Aug 28
1
names<- in data.frame (PR#13916)
Full_Name: Spinu Vitalie
Version: 2.9.0
OS: Windows
Submission from: (NULL) (130.115.113.15)
In assignment of "zero length" names to data.frame:
> tdf <- data.frame(rbind(c(1, 2), c(1, 2)))
> names(tdf) <- c("", "")
> tdf
structure(c("1", "1"), class = "AsIs") structure(c("2", "2"), class =
2010 Jul 07
3
quantiles on rows of a matrix
I'm trying to obtain the mean of the middle 95% of the values from each row
of a matrix (that is, the highest and lowest 2.5% of values in each row
are removed before calculating the mean). I am having all sorts of
problems with this; for example the command:
apply(matrix1,1,function(x) quantile(c(.05,.90),na.rm=T))
returns the exact same quantile values for each row, which is clearly
2009 Jul 23
5
Random # generator accuracy
Dan Nordlund wrote:
"It would be necessary to see the code for your 'brief test' before anyone
could meaningfully comment on your results. But your results for a single
test could have been a valid "random" result."
I've re-created what I did below. The problem appears to be with the
weighting process: the unweighted sample came out much closer to the actual
2011 Oct 24
3
extract the p value
OK, what is the trick to extracting the overall p value from an lm object?
It shows up in the summary(lm(model)) output but I can't seem to extract it:
> test2 = apply(aa, 1, function(x) summary(lm(x[,1] ~ 0 + x[,3] + x[,6])))
> test2[[1]]
Call:
lm(formula = x[, 1] ~ 0 + x[, 3] + x[, 6])
[omitted summary output]
F-statistic: 40.94 on 2 and 7 DF, p-value: 0.0001371
It does not seem
2008 Jul 10
1
Ellipsis arguments for plot.formula
Hi:
I have a function as follows:
my.plot <- function( x, y = NULL, ... )
{
plot( x, y, cex.axis=0.5, ...)
}
Set up the variables:
x <- 1:10; y <- x; tdf <- data.frame( x, y ); main.str <- "test"
I will exercise the function in two ways:
> my.plot( y ~ x, tdf, main = "test" )
This works fine
> my.plot( y ~ x, tdf, main = main.str )
Error in
2011 Sep 23
2
converting object elements to variable names and making subsequent assignments thereto
This has got to be incredibly simple but I nevertheless can't figure it out
as I am apparently brain dead.
I just want to convert the elements of a character vector to variable names,
so as to then assign formulas to them, e.g:
z = c("model1","model2"); I want to assign formulas, such as lm(y~x[,1]) and
lm(y~x[,2]), to the variables "model1" and
2009 Nov 21
7
consecutive numbering of elements in a matrix
Within a very large matrix composed of a mix of values and NAs, e.g, matrix A:
[,1] [,2] [,3]
[1,] 1 NA NA
[2,] 3 NA NA
[3,] 3 10 17
[4,] 4 12 18
[5,] 6 16 19
[6,] 6 22 20
[7,] 5 11 NA
I need to be able to consecutively number, in new columns, the non-NA
values within each column (i.e. A[1,1] A[3,2] and A[3,3] would all be set
to one, and
2010 Dec 26
2
object names from character strings
I realize this is probably pretty basic but I can't figure it out.
I'm looping through an array, doing various calculations and producing a
resulting data frame in each loop iteration. I need to give each data
frame a different name. Although I can easily create a new character
string for writing each frame to an output file, I cannot figure out how
to convert such strings to
2008 Jun 26
1
Undefined method: camelize
Hi,
I am fairly new at Rails, and attempting to deploy an application
that''s running fine using InstantRails on my PC. On the deployment
server (I use railsplayground.net), I get the following error:
Processing ApplicationController#index (for 220.224.229.156 at
2008-06-25 18:49:34) [GET]
Session ID: 5921e7d789ee3aaa214f2d59aa40986a
Parameters: {"action"=>:index,
2009 Nov 24
2
linear regression on groups of consecutive rows of a matrix
I want to perform linear regression on groups of consecutive rows--say 5 to
10 such--of two matrices. There are many such potential groups because the
matrices have thousands of rows. The matrices are both of the form:
> shp[1:5,16:20]
SL495B SL004C SL005C SL005A SL017A
-2649 1.06 0.56 NA NA NA
-2648 0.97 0.57 NA NA NA
-2647 0.46 0.30 NA NA