Displaying 20 results from an estimated 6000 matches similar to: "Regression using mapply?"
2010 Dec 07
2
longer object length is not a multiple of shorter object length
In datamatrix[, "y"] == datamatrix[, "y"][-1] :
longer object length is not a multiple of shorter object length
out = c(FALSE,datamatrix[,'y'] == datamatrix[,'y'][-1])
and I do not know why I get that error, the resulting out matrix is somehow
one row larger than datamatrix...
all I try to do is filter matrix by dropping rows where [,'y'][-1] ==
2011 Feb 10
3
Permuting rows of a matrix
Hi,
I need to permute the rows of a matrix, where each row is independently rearranged. A simple solution is this:
shuffled <- datamatrix <- matrix(1:24, ncol = 4)
for (i in 1:nrow(datamatrix)) { shuffled[i, ] <- sample(datamatrix[i, ]) }
> datamatrix
[,1] [,2] [,3] [,4]
[1,] 1 7 13 19
[2,] 2 8 14 20
[3,] 3 9 15 21
[4,] 4 10 16 22
[5,]
2007 Feb 13
1
Questions about results from PCAproj for robust principal component analysis
Hi.
I have been looking at the PCAproj function in package pcaPP (R 2.4.1) for
robust principal components, and I'm trying to interpret the results. I
started with a data matrix of dimensions RxC (R is the number of rows /
observations, C the number of columns / variables). PCAproj returns a list
of class princomp, similar to the output of the function princomp. In a
case where I can
2008 Mar 03
2
handling big data set in R
Hello R users,
I'm wondering whether it is possible to manage big data set in R? I
have a data set with 3 million rows and 3 columns (X,Y,Z), where X is
the group id. For each X, I need to run 2 regression on the submatrix.
I used the function "split":
datamatrix<-read.csv("datas.csv", header=F, sep=",")
dim(datamatrix)
# [1] 2980523 3
2009 May 14
3
memory usage grows too fast
Hi All,
I have a 1000x1000000 matrix.
The calculation I would like to do is actually very simple: for each row, calculate the frequency of a given pattern. For example, a toy dataset is as follows.
Col1 Col2 Col3 Col4
01 02 02 00 => Freq of ?02? is 0.5
02 02 02 01 => Freq of ?02? is 0.75
00 02 01 01 ?
My code is quite simple as the following to find the pattern ?02?.
2004 Jul 13
5
Help with factanal and missing values
Hi list,
I'm performing a series of confirmatory factor analysis on different
groupings of items from data collected with questionnaires. There are some
missing values.
For those sets with no missing values I call
factanal(datamatrix,factors=n)
where datamatrix is a table of all observations for the items under
investigation.
This call fails when there are missing values.
help(factanal)
2004 Apr 27
1
beginners k means clustering question
Hi all,
I am wandering.. is it possible to cluster data which is in a single
column ?
for example.. I have some data as follows:
4013
7362
7585
9304
11879
14785
21795
30500
30669
30924
33988
36975
40422
42911
50501
51593
53729
54338
55497
57337
61993
62601
66229
69815
69933
70760
71340
75921
83972
90134
91061
.
.
.
is it possible to cluster this data since it is in a single column ?
I have
2009 Jan 20
1
heatmap.2 color issue
Dear All:
I tried to use heatmap.2 to generate hierarchical clustering using the following command:
heatmap.2(datamatrix, scale="row", trace="none", col=greenred(256), labRow=genelist[,1], margins=c(10,10), Rowv=TRUE, Colv=TRUE)
datamatrix is subset of a RMA normalized data subset by a genelist.
The problem is a lot of times, the z-score in key are from, like -5 to 15 or
2012 Jul 24
4
ERROR : cannot allocate vector of size (in MB & GB)
Hi,
Here in R, I need to load a huge file(.csv) , its size is 200MB. [may come
more than 1GB sometimes].
When i tried to load into a variable it taking too much of time and after
that when i do cbind by groups,
getting an error like this
" Error: cannot allocate vector of size 82.4 Mb "
My requirement is, spilt data from Huge-size-file(.csv) to no. of small csv
files.
Here i will give
2012 Aug 10
1
Split CSV as per file size
Hi here i have a code to split a csv file as per group of line.
The code given below,
------------------------------------
SplitCSVByLine <- function(DataMatrix,Destination,NoOfLineToGroup)
{
input <- file(DataMatrix, "r")
fileNo <- 1
repeat
{
myLines <- readLines(input, n=NoOfLineToGroup)
if (length(myLines) == 0) break
2009 Jul 03
1
fix() and edit() not working with Rcmdr and german LANG-variable
Dear Mailinglist,
I just set up an R 2.9.1 environment with Rcmdr 1.4-6 on Ubuntu Jaunty
9.04. As I'm from Germany my $LANG variable is set to "de_DE.UTF-8".
Now, when I open up Rcmdr and try to edit a new datamatrix there is no
edit window appearing:
Datenmatrix <- edit(as.data.frame(NULL))
ERROR: invalid device
In addition, there are plenty of warning messages in the
2003 Oct 14
3
mapply() gives seg fault
Hello everybody.
I've been experimenting with mapply(). Does anyone else have problems with:
R> mapply(rep,times=1:4, MoreArgs=42)
(I get a seg fault).
robin
R> R.version
_
platform powerpc-apple-darwin6.6
arch powerpc
os darwin6.6
system powerpc, darwin6.6
status beta
major 1
minor 8.0
year 2003
month 10
day 02
language R
>
2008 Mar 23
1
mapply
In an earlier post, a person wanted to divide each of the rows of
rawdata by the row vector sens so he did below but didn't like it and
asked if there was a better solution.
rawdata <- data.frame(rbind(c(1,2,2), c(4,5,6))) sens <- c(2,4,6)
temp <- t(rawdata)/sens
temp <- t(temp)
print(temp)
Gabor sent three other solutions and I understood 2 of them but not the
2012 Mar 12
2
mapply & assign to generate functions
Hi,
I have a problem that I'm finding a bit tricky. I'm trying to use
mapply and assign to generate curried functions. For example, if I
have the function divide
divide <- function(x, y) {
x / y
}
And I want the end result to be functionally equivalent to:
half <- function(x) divide(x, 2)
third <- function(x) divide(x, 3)
quarter <- function(x) divide(x, 4)
But I want
2012 Nov 15
1
bug with mapply() on an S4 object
Hi,
Starting with ordinary vectors, so we know what to expect:
> mapply(function(x, y) {x * y}, 101:106, rep(1:3, 2))
[1] 101 204 309 104 210 318
> mapply(function(x, y) {x * y}, 101:106, 1:3)
[1] 101 204 309 104 210 318
Now with an S4 object:
setClass("A", representation(aa="integer"))
a <- new("A", aa=101:106)
> length(a)
2011 Jul 31
1
Trouble Using mapply
Dear all,
I am having a problem with mapply. I guess the reason is that mapply is not "vectorized". But could you please take a look at my code below and help me to find a solution (either a better way to use mapply or a different function to call). Thanks a lot!
##beginning of my code
myfun <- function(threshold, all.data) {
##Just a demostration of a function that takes a
2006 Aug 31
2
Wish: keep names in mapply() result
Hello!
I have noticed that mapply() drops names in R 2.3.1 as well as in
r-devel. Here is a simple example:
l <- list(a=1, b=2)
k <- list(1)
mapply(FUN="+", l, k)
[1] 2 3
mapply(FUN="+", l, k, SIMPLIFY=FALSE)
[[1]]
[1] 2
[[2]]
[1] 3
Help page does not indicate that this should happen. Argument USE.NAMES
does not have any effect here as it used only in a bit special
2013 Feb 14
1
mapply error with Math (S4 group generic)
I get an error when using self-defined (not standard) functions with mapply
with S4 objects from the raster package that I develop: "Error in
as.character(sys.call(sys.parent())[[1]]) : cannot coerce type 'closure'
to vector of type 'character'". Does anyone understand why? The problem is
illustrated below. Thanks, Robert
> # First a general example that works
2013 Dec 06
2
Using assign with mapply
I have a data frame whose first colum contains the names of the variables
and whose second colum contains the values to assign to them:
: kkk <- data.frame(vars=c("var1", "var2", "var3"),
vals=c(10, 20, 30), stringsAsFactors=F)
If I do
: assign(kkk$vars[1], kkk$vals[1])
it works
: var1
[1] 10
However, if I try with mapply
2011 Feb 23
2
list multiplied by a factor / mapply
Dear list,
this works fine:
x <- split(iris, iris$Species)
x1 <- lapply(x, function(L) transform(L, g = L[,1:4] * 3))
but I would like to multiply each Species with another factor:
setosa by 2, versicolor by 3 and virginica by 4. I've tried mapply but
without success.
Any thoughts? Thanks for any idea!
Patrick