Displaying 20 results from an estimated 500 matches similar to: "Data frame reordering to time series"
2013 Mar 25
2
Faster way of summing values up based on expand.grid
Hello!
# I have 3 vectors of values:
values1<-rnorm(10)
values2<-rnorm(10)
values3<-rnorm(10)
# In real life, all 3 vectors have a length of 25
# I create all possible combinations of 4 based on 10 elements:
mycombos<-expand.grid(1:10,1:10,1:10,1:10)
dim(mycombos)
# Removing rows that contain pairs of identical values in any 2 of
these columns:
mycombos<-mycombos[!(mycombos$Var1
2006 Oct 01
3
aggregate function with 'NA'
Dear r-help reader,
I have some problems with the aggregate function.
My datframe looks like
>frame
Day Time V1 V2
1 M 0 3 NA
2 M 0 4 NA
3 M 0 5 2
4 M 1 NA 4
5 M 1 10 6
6 T 0 4 45
7 T 1 4 3
8 T 1 3 2
9 T 1 6 1
I used the aggegate function to obtain the mean in V1 and V2 over the
grouping variable
Time and Day
2010 Dec 18
3
dotchart for matrix data
Readers,
I am trying to use the function dotchart. The data is:
> testdot
category values1 values2 values3 values4
1 a 10 27 56 709
2 b 4 46 47 208
3 c 5 17 18 109
4 d 6 50 49 308
The following error occurs
> dotchart(testdot,groups=testdot[,2])
Error in dotchart(testdot, labels =
2024 Aug 16
1
allequal diff
? Fri, 16 Aug 2024 10:35:35 +0200
<sibylle.stoeckli at gmx.ch> ?????:
> what do you mean by use is.na() in getValues(). So I need to call
> getValues a second time?
Not necessarily, but it's one of the options. I was thinking along the
lines of:
values1 <- getValues(r1)
mask1 <- is.na(values1)
# Do the same for r2
# Combine the masks
all.equal(values1[!combined_mask],
2013 Jul 17
0
usar partial=TRUE en rake
Estimados usuarios de R:
Estoy usando un programa en que utilizo la funciĆ³n rake:
*rake(ps,list(~A,~B,~C),list(pop.A, pop.B, pop.C),control =
list(maxit=1000, epsilon = 1, verbose=TRUE))*
**
*Obtengo como resultado:*
**
, , C = 1
B
A 1 2 3 4 5
A1 0.000000 0.000000 0.000000 0.000000 0.000000
A2 3.000000 3.000000 0.000000
2009 Jun 16
4
confusion on levels() function, and how to assign a wanted order to factor levels, intentionally?
Dear R-helpers,
I want to make a series of boxplots on several numeric univariates with two
group variables (species and population, population nested in species, and
with population as the X-axis). In order to get a proper order of the
individual populations in X-axis, I need to assign a wanted order to the
factor (population). I used the levels() function to do this assignment, but
it seemed
2007 Nov 16
0
Odp: R: ave and quantile
Hi
Patrick Hausmann <c18g at uni-bremen.de> napsal dne 15.11.2007 18:59:06:
> Hello Petr,
>
> one question solved, the next is standing in front of me... If you
> have a minute to look .... great!
>
> > x
> V1 V2 F1
> 1 A 2 0.1552277
> 2 A 3 0.1552277
> 3 A 4 0.1552277
> 4 B 3 0.8447723
> 5 B 2 0.8447723
> 6 C 6 0.2500000
2013 Jan 05
5
Need help on dataframe
Dear R users, I came up to a problem by taking means (or other summary
statistics) of a big dataframe.
Suppose we do have a dataframe:
ID V1 V2 V3 V4 ........................ V71
1 6 5 3 2 ........................ 3
2 3 2 2 1 ........................ 1
3 6 5 3 2 ........................ 3
4 12 15 3 2 ........................ 100
2011 Jan 27
3
how to divide each element of a matrix by a specific value per column
Hi,
I'd like to divide each element of a matrix by a specific value per column. These specific values are stored in a list. For example:
> x <- c(1,2,3,4,5)
> y <- matrix(c(1:30), nrow = 6)
Now I want to divide each element in y[,1] by x[1], y[,2] by x[2] etc. I have tried this
> my_function <- function(data, ind) data/ind
> apply(y, 2, my_function, x)
[,1] [,2]
2008 Oct 31
4
[ifelse] how to maintain a value from original matrix without probs?
Dear all,
I have a matrix with positive and negative values.
>From this I would like to produce 2 matrices:
1st - retaining positives and putting NA in other positions
2nd - retaining negatives and putting NA in other positions
and then apply rowMeans for both.
I am trying to use the function ifelse in the exemplified form:
ifelse(A>0,A,NA)
but by putting A as a 2nd parameter it
2024 Aug 16
1
allequal diff
Cool thanks
# values and mask r1
r1 <- getValues(r1)
mask1 <- is.na(r1)
# Do the same for r2
r2 <- getValues(r2_resampled)
mask2 <- is.na(r2)
# Combine the masks
all.equal(r1[!(mask1 & mask2)], r2[!(mask1 & mask2)])
output
> all.equal(r1[!(mask1 & mask2)], r2[!(mask1 & mask2)])
[1] "'is.NA' value mismatch: 389 in current 56989152 in target"
2004 Apr 07
4
Problems with rlm
Dear all,
When calling rlm with the following data, I get an error. (R v.1.8.1,
WinXP Pro 2002 with service pack 1.)
> d <- na.omit(data.frame(CPRATIO, HEIGHTZ, FAMILYID))
> c <- tapply(d$CPRATIO, d$FAMILYID, mean)
> h <- tapply(d$HEIGHTZ, d$FAMILYID, mean)
> c
1 2 3 6 7 9 10
11
6.000000 2.500000 3.250000
2007 Jun 05
1
Gruff Stacked Bar order of data
I am making a stacked bar graph in Gruff. Could anyone help me by
telling me how I can change the order in which the data is stacked. No
matter what order I put the data in, I get the same result on the png
picure. Any help would be much appreciated.
Thanks.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because
2011 Oct 11
2
matrix multiplication
Dear all,
Sorry to bother you with such a stupid question, but I just cannot find the
solution to my problem.
I'd like to use matrix multiplication for meanA and factorial 3.
I use the command meanA%*%factorial 3.
But everything I get is: Error in factorial3 %*% A : non-conformable
arguments
I know that the number of the columns of the first vector has to be the same
number of rows of the
2018 Mar 14
3
the same function returning different values when called differently..
dear members,
I have a function ygrpc which acts on the daily price increments of a stock. It returns the following values:
ygrpc(PFC.NS,"h")
[1] 2.149997 1.875000 0.750000 0.349991 2.100006 0.199997 4.000000 2.574996 0.500000 0.349999 1.500000 0.700001
[13] 0.500000 1.300003 0.449997 2.800003 2.724998 66.150002 0.550003 0.050003 1.224991 4.899994 1.375000
2013 Mar 18
2
Confirmatory factor analysis using the sem package. TLI CFI and RMSEA absent from model summary.
Hi R-help,
I am using the sem package to run confirmatory factor analysis (cfa) on some questionnaire data collected from 307 participants. I have been running R-2.15.3 in Windows in conjunction with R studio. The model I am using was developed from exploratory factor analysis of a separate dataset (n=439); it includes 18 items that load onto 3 factors. I have used the sem package documentation
2024 Aug 16
2
allequal diff
Many thanks Ivan
Use is.na() on getValues() outputs, combine the two masks using the | operator to get a mask of values that are missing in either raster, then negate the mask to choose the non-missing values:
all.equal(getValues(r1)[!mask], getValues(r2)[!mask])
--> what do you mean by use is.na() in getValues(). So I need to call getValues a second time? I suppose you mean to first
2007 May 04
1
Bug in qr.R ? (PR#9655)
Ladies and Gentlemen,
using
> A <- structure(c(1, 0, 0, 3, 2, 1, 4, 5, -3, -2, 1, 0), .Dim =
as.integer(c(3,4)))
I get
> dim(A)
[1] 3 4
> qr.R(qr(A),complete=TRUE)
[,1] [,2] [,3] [,4]
[1,] -1 -3.000000 -4.000000 2.0000000
[2,] 0 -2.236068 -3.130495 -0.8944272
[3,] 0 0.000000 -4.919350 -0.4472136
> qr.R(qr(A),complete=FALSE)
[,1]
2019 Oct 23
2
Unexpected behavior when using macro to loop over vector
Hi all,
I found an unexpected behavior when I was trying to use the macro defined
in "R_ext/Itermacros.h" to loop over an atomic vector. Here is a minimum
example:
C++ code
```
#include "R_ext/Itermacros.h"
#define GET_REGION_BUFSIZE 2
//Redefine the macro since C++ is not happy with the implicit type
conversion
#define ITERATE_BY_REGION_PARTIAL(sx, px, idx, nb, etype,
2018 Mar 14
0
Fwd: the same function returning different values when called differently..
Hi Akshay,
(Please include r-help when replying)
You have learned that PFC.NS and snl[[159]] are not identical. Now you have
to figure out why they differ. This could also point to a bug or a logic
error in your program.
Figuring out how two objects differ can be a bit tricky, but with
experience it becomes easier. (Some others may even have some suggestions
for good ways to do it.)
Basically