similar to: Utility function to apply a scale object on another data frame

Displaying 20 results from an estimated 10000 matches similar to: "Utility function to apply a scale object on another data frame"

2001 Dec 27
1
scale in stars() is not as documented (PR#1230)
R 1.4.0 ?stars has scale: logical flag: if `TRUE', the columns of the data matrix are scaled independently so that the maximum value in each column is 1 and the minimum is 0. If `FALSE', the presumption is that the data have been scaled by some other algorithm to the range [0,1]. but the code has if (scale) { x <- sweep(x, 2,
2011 Jul 15
2
scaling advice
Hi, I have a consultants nightmare -- I was given a project that another consultant did and I was told to do the same calculations, but there's no documentation on what he did. Basically, I have yes/no answers to survey questions about the effectiveness of product attributes by brands. There are 44 attributes and 13 brands. The other guy scaled the proportion of respondents who said
2005 Mar 01
3
Reconstructing Datasets
Hi, Is it possible to recreate "smoothed" data sets in R, by performing a PCA and then reconstructing a data set from say the first 2/3 EOFs? I've had a look in the help pages and don't seem to find anything relevant. Thanks in advance, Laura Laura Quinn Institute of Atmospheric Science School of Earth and Environment University of Leeds Leeds LS2 9JT tel: +44 113 343 1596
2014 Jun 11
2
Alleged bug in Silk codec
Hi, Apologies if this is a known issues, but I have found what I believe is a bug in the fixed point implementation of the Silk codec and could not find any mention on this in the archives. The bug can be easily reproduced with the fixed point demo program (./configure ?enable-fixed-point ?disable-float-api && make) using the following command: ./opus_demo voip 16000 1 23000
2000 Oct 21
1
scale() and NA values
Hello, I've a question concerning the behaviour of the "scale" function in the base package. I'm using R 1.1.1 on Windows 95. If I take a matrix with NA values, such as > tm <- matrix(c(2,1,0,1,0,NA,NA,NA,0), nrow=3) > tm [,1] [,2] [,3] [1,] 2 1 NA [2,] 1 0 NA [3,] 0 NA 0 and scale it, the columns containing NAs come out all NA: >
2010 Aug 11
2
Sweeping a zoo series
Given a long zoo matrix, the goal is to "sweep" out a statistic from the entire length of the sequences. longzoomatrix<-zoo(matrix(rnorm(720),ncol=6),as.yearmon(outer(1900,seq(0,length=120)/12,"+"))) cnames<-c(12345,23456,34567,45678,56789,67890) colnames(longzoomatrix)<-cnames longzoomatrix[1:24,] 12345 23456 34567 45678
2014 Jun 13
3
Alleged bug in Silk codec
Hi Jean Marc, please find attached the audio file (mono 16khz). I shortened it to about 10 seconds. I also add 2 patches that worked for me. Further info that might help: - The problem seems to be related to silk_burg_modified not reaching the maximum gain, so the actual filter order is 16 rather than 2 (which is what would be expected with a sine wave). - The problem seems to happen when
2009 Dec 16
1
difference between the meaning of MARGIN in sweep() and apply()
For example, subtracting 1:2 from the rows of a two-column matrix: > t(apply(matrix(1:6,ncol=2),MARGIN=1,function(y) y - 1:2)) [,1] [,2] [1,] 0 2 [2,] 1 3 [3,] 2 4 > sweep(matrix(1:6,ncol=2),MARGIN=2,1:2,FUN="-") [,1] [,2] [1,] 0 2 [2,] 1 3 [3,] 2 4 Is there a logic to this difference, or is it just a quirk of the history of these
2007 Sep 18
2
How to Standardise the x/y coordinates to the unit square?
Dear Rusers, I want to standardise the values of x/y coordinates to the unit square, i.e. make the x-values all lie within [0,1] and all the y-values lie within [0,1] in the bottom example. I had thought to use scale() function to do it, but it seems that it's used to standardise a variable and the scaled value was not within [0,1]. OR, i can divide x/y-values by their maximum value to get
2011 Apr 27
1
lattice wireframe with logarithmically scaled axis?
Hi, I have some questions for the wireframe function of the lattice package. My dataset's "x-data" are sampled logarithmically and as such I would like to have a semilogarithmic 3D plot when plotting a time series. Does anyone know how to change the example in http://addictedtor.free.fr/graphiques/sources/source_40.R such that x or y would be logarithmically scaled? Also, I would
2009 Sep 11
2
Alternative to Scale Function?
Hi, Is there an alternative to the scale function where I can specify my own mean and standard deviation? I've come across an interesting issue where this would help. I'm training and testing on completely different sets of data. The testing set is smaller than the training set. Using the standard scale function of R seems to introduce some error. Since it scales data WITHIN the
2006 Sep 06
7
Matrix multiplication using apply() or lappy() ?
I am trying to divide the columns of a matrix by the first row in the matrix. I have tried to get this using apply and I seem to be missing a concept regarding the apply w/o calling a function but rather command args %*% / etc. Would using apply be more efficient than this approach? I have observed examples in the archives using this type of approach. Does anybody have a snippet of a call
2010 Sep 01
3
standardize columns selectively within a dataframe
Dear all, I have a dataframe: df<-dataframe(a=c(1,2,3),b=c(4,5,6),c=c(7,8,9),d=c(10,11,12)) I want to obtain a new dataframe with columns a and b being standardized ((x-mean(x))/sd(x)); the other two columns (c,d) I want to leave unchanged. What is the best way to achieve this? I have been trying to use subscripts but did not succeed so far. Any tips? Many thanks, Olga
2005 Jun 20
6
sweep() and recycling
Hi I had a hard-to-find bug in some of my code the other day, which I eventually traced to my misusing of sweep(). I would expect sweep() to give me a warning if the elements don't recycle nicely, but X <- matrix(1:36,6,6) sweep(X,1,1:5,"+") [,1] [,2] [,3] [,4] [,5] [,6] [1,] 2 9 16 23 30 32 [2,] 4 11 18 25 27 34 [3,] 6 13 20 22
2012 Sep 26
2
specifying arguments in functions and calling functions, within functions
Esteemed R UseRs, Regarding specifying arguments in functions and calling functions within functions: ## beginning ## ## some data ex <- rnorm(10) ex[5] <- NA ## example function Scale <- function(x, method=c("mean", "median")) { scl <- method scl(x) } ## both return NA Scale(ex, method=median) median(ex, na.rm=FALSE) ## both return the median Scale(ex,
2003 Apr 03
1
SVM module: scaling data applied to new test set without using SVM again
Hello! We are new in using R. We use the SVM module from the library ''e1071'' for training. Problem formulation: a classification has been performed using SVM module (linear kernel). Later, a new data set (test set) comparable to the training data shall be scaled in the same way as the training set (using the same scaling parameter set, but without using the SVM again
2009 Aug 19
5
scale or not to scale that is the question - prcomp
Dear all here is my data called "rglp" structure(list(vzorek = structure(1:17, .Label = c("179/1/1", "179/2/1", "180/1", "181/1", "182/1", "183/1", "184/1", "185/1", "186/1", "187/1", "188/1", "189/1", "190/1", "191/1", "192/1",
2008 Jan 04
2
question about scale() function
Hi, The documentation for scale() states:"If center is TRUE then centering is done by subtracting the column means (omitting NAs) of x from their corresponding columns". But it seems that R is subtracting something else instead of the column mean: > x=c(2,4,3,4,5) > mean(x) [1] 3.6 > x-mean(x) [1] -1.6 0.4 -0.6 0.4 1.4 > scale(x) [,1] [1,] -1.4032928 [2,]
2010 Apr 22
1
Why does 'apply(.., 1, .., ..)' transpose result
I am sorry if this is documented in apply's dcumentation or completely obvious, I could not find or work it out. Given an matricies Q: 2x3, R:1x3 and S:1x2 apply(Q, 1, '-', R) is 3x2 and apply(Q, 2, '-', S) is 2x3 Why? cheers Worik > Q [,1] [,2] [,3] [1,] 1 2 3 [2,] 10 11 12 > R [1] 1 4 7 > S [1] 1 4 > apply(Q, 1, '-', R) [,1]
2008 Aug 04
1
simulate data based on partial correlation matrix
Given four known and fixed vectors, x1,x2,x3,x4, I am trying to generate a fifth vector,z, with specified known and fixed partial correlations. How can I do this? In the past I have used the following (thanks to Greg Snow) to generate a fifth vector based on zero order correlations---however I'd like to modify it so that it can generate a fifth vector with specific partial