Displaying 20 results from an estimated 6000 matches similar to: "probably need to se sapply but i can't get it"
2006 Jun 27
1
related to my previous sapply question]
in my previous post in which i asked about creating sequences
from two vectors of numbers, all suggestions worked.
tradevectors<-mapply(seq,from=tempa,to=tempb)
or
tradevectors<-sapply(1:length(tempa),function(x) seq(tempa[x],tempb[x])
>both return a list with 3 components.
the problem is that i want to take these 3 sequences and
use them as the indices of two other vectors, X and
2008 Jun 04
2
converting a table to a dataframe or a matrix
can someone show me how to convert a table to a data.frame or a matrix ?
I tried below and as.data.frame rearranges the columns
similarly to a melt from reshape and as.matrix didn't change it. I
actually would prefer to change it to a dataframe but if someone
can show me how to convert it to a matrix, then as.data.frame will work
on that. I was thinking about just changing the class to
2006 Nov 16
1
getting a title in a plot during an lapply
In my code below tempa and tempb are numeric vectors that I combined
into a dataframe along with the deciles of tempa.
I have an lapply statement that goes through the dataframe and does ten
plots according to the appropriate decile.
The code is below and it works fine. There are no bugs so I figure there
was no need to include structure statements on the data.
Also, I don't want to use coplot
2006 Jun 28
2
hopefully my last question on lapply
Marc and many other people ( whose names escape me ) have been
very helpful in explaining the use of lapply to me.
In his last response, Marc explained that if tradevectors is a list
of vectors of different lengths ( excuse my terminology ) then
lapply(tradevectors,function(x) G[x]*B[x] )
will go through each component of the list as if it was a vector
and apply the element by element
2011 Aug 01
4
Use dump or write? or what?
Greetings all,
I am calculating two t-test values for each of many files then save it
to file calculate another set and append, repeat.
But I can't figure out how to write it to file and then append
subsequent t-tests.
(maybe too tired ;} )
I have tried to use "dump" and "file.append" to no avial.
ttest_results = tempfile()
two_sample_ttest <- t.test (tempA, tempB,
2012 May 30
1
caret() train based on cross validation - split dataset to keep sites together?
Hello all,
I have searched and have not yet identified a solution so now I am sending
this message. In short, I need to split my data into training, validation,
and testing subsets that keep all observations from the same sites together
? preferably as part of a cross validation procedure. Now for the longer
version. And I must confess that although my R skills are improving, they
are not so
2006 Jan 23
1
will vectorization help in this case?
Hi all,
I am doing a array marginalization over one dimension in the following
manner:
===========================================================
for(l in 1:L)
{
flst=list(Pzu, Pzi, array(Puzu[,as.character(r[[l,"u"]])],
dim=dim(Puzu)[1], dimnames=dimnames(Puzu)[1]), array(Pizi[,as.character(r[[l,
"i"]])], dim=dim(Pizi)[1], dimnames=dimnames(Pizi)[1]) );
tempa = 1;
2012 Jul 03
2
EM algorithm to find MLE of coeff in mixed effects model
I have a general question about coefficients estimation of the mixed model.
I simulated a very basic model: Y|b=X*\beta+Z*b +\sigma^2* diag(ni);
b follows
N(0,\psi) #i.e. bivariate normal
where b is the latent variable, Z and X are ni*2 design matrices, sigma is
the error variance,
Y are longitudinal data, i.e. there are ni
2008 Oct 22
4
A matrix automation problem
[I am really sorry if it is double posted, I doubt me previous post could not
reach forum due to some problem with net]
Suppose I have a matrix :
a = matrix(1:9, 3)
>From this matrix, I construct 9 additional matrices :
i = 1:9
bi = a * i
Now combining all those 9 new matrices, I construct a final metrix as :
c =
b1 b4 b7
b2 b5 b8
b3 b6 b8
I want to automate this procedure for any
2006 Jun 20
2
strange use of sapply
I've tried and give up. I have a matrix of say 200 columns and 400 rows.
For each odd ( or even i suppose if i wanted to )column,
I want to know the number of rows in which the value is greater than zero.
So, I did sapply(tempMatrix,2,function(x) sum( x > 0 ))
this almost works but i don't know how to tell
it to only do the odd columns. my guess is , like everything else
in R, this
2010 Aug 05
2
[Bug 29403] New: [nvac] attempting to use displayport freezes machine
https://bugs.freedesktop.org/show_bug.cgi?id=29403
Summary: [nvac] attempting to use displayport freezes machine
Product: xorg
Version: git
Platform: Other
OS/Version: All
Status: NEW
Severity: normal
Priority: medium
Component: Driver/nouveau
AssignedTo: nouveau at lists.freedesktop.org
2012 Jul 03
0
need help EM algorithm to find MLE of coeff in mixed effects model
Dear All,
have a general question about coefficients estimation of the mixed model.
I simulated a very basic model: Y|b=X*\beta+Z*b +\sigma^2* diag(ni);
b follows
N(0,\psi) #i.e. bivariate normal
where b is the latent variable, Z and X are ni*2 design matrices, sigma is
the error variance,
Y are longitudinal data, i.e. there are ni
2008 Aug 20
3
vector operation using regexpr?
Hi,
Here's my problem... I have a data frame with three columns containing
strings. The first columns is a simple character. I want to get the
index of that character in the second column and use it to extract the
item from the third column. I can do this using a scalar method. But
I'm not finding a vector method. An example is below.
col1 col2 col3
'L'
2009 Mar 31
1
error when going through Alan Lenarcic's package Tutorial
Hi Everyone: I've been going through Alan Lenarcic's package tutorial but
when I did
R CMD SHLIB Xdemo.cc Xdemo_main.cc -o Xdemo.dll
I got the following error:
XDemo_res.rc:15:38: warning: missing terminating " character
XDemo_res.rc:23:34: warning: missing terminating ' character
c:\mark\research\Rtools\MinGW\bin\windres.exe: XDemo_res.rc:16: syntax error
2008 Sep 23
4
perl expression question
If I have the string below. does someone know a regular expression to
just get the "BLC.NYSE". I bought the O'Reilley
book and read it when I can and I study the solutions on the list but
I'm still not self sufficient with these things. Thanks.
stock<-"/opt/limsrv/mark/research/equity/projects/testDL/stock_data/fhdb/US/BLC.NYSE"
2009 Aug 05
4
A question regarding R scoping
I have a question related to scoping. Suppose we have 2 functions:
f1 = function(i){i = 1}
f2 = function(n){
i = length(n)
f1(i)
}
In other words, I would like i=1 regardless of n. Is this possible without having f1 in the body of f2? Thanks in advance!
2009 Nov 13
4
processing log file
Dear all, I'm trying to process a log file which logs the date, the username and the computer number accessed. The table looks like this:
>table.users
Date UserName Machine
1 2008-11-25 John 641
2 2008-11-25 Clive 611
3 2008-11-25 Jeremy 641
4 2008-11-25 Walt 722
5 2008-11-25 Tony 645
6 2008-11-26 Tony 645
7 2008-11-26
2010 Dec 15
3
Applying function to a TABLE and also "apply, tapply, sapply etc"
Dear R-help forum members,
Suppose I have a data-frame having two variables and single data for each of them, as described below.
variable_1 variable_2
10 20
I have written a function, say, 'fun' which uses input 10 and 20 and gives me desired result.
fun = function(X, Y)
{
X + Y #( I am just giving an example of
2007 Jun 22
2
extract index during execution of sapply
Hi there
During execution of sapply I want to extract the number of times the
function given to supply has been executed. I came up with:
mylist <- list(a=3,b=6,c=9)
sapply(mylist,function(x)as.numeric(gsub("[^0-9]","",deparse(substitute(x)))))
This works fine, but looks quite ugly. I'm sure that there's a more
elegant way to do this.
Any suggestion?
Christian
2006 Jun 16
2
scatterplot but a little tricky
i have two vectors of numbers x and y and of course i
can do the standard scatterplot plot(x,y)
and it looks fine. But, I was hoping there was a way to
do the scatterplot so that each point plotted is a number
where the number represents the index in the dataset.
so, if it was x[3] and y[3], then the point would be a 3
or if it was x[4] and y[4], then the point would be a 4 etc.
i doubt this is