Hi,
I am using split function and wonder how to add the factor to the splitted
results.
#Example
n <- 3; nn <- 10
g <- factor(round(n * stats::runif(n * nn))) #factor
x <- rnorm(n * nn) + sqrt(as.numeric(g))#value
xg <- split(x, g)
xg
$`0`
[1] 0.82513702 -0.03911584 2.32955347 0.36745335
zes of different levels, displayed above. That is, 7 for level 0, 9 for
level 1, et al.
Thanks.
2010/2/26 Henrique Dallazuanna
> Try this:
>
> split(data.frame(x, g), g)
>
> On Fri, Feb 26, 2010 at 3:55 PM, rusers.sh wrote:
> > Hi,
> > I am using split function and wonder h
Thanks.
I think i mistake the sampling() with split().
2010/2/26 David Winsemius
>
> On Feb 26, 2010, at 2:40 PM, rusers.sh wrote:
>
> Your method seems to only re-express the data "data.frame(x, g)" using
>> another format.
>>
>
> In all fairness to the
Hi,
I wrote my own function to finish my work. One strange thing happened. If
i set the number of simulations to be "10", it goes correctly. But if i set
the number of simulations into "100", then errors appeared.
Error information: The instruction at "0x6abf12cf" referenced memory at
"0x0286fff
Hi all,
My problem may be related with the list manipulations. See below.
#example data
a<-list()
a[[1]]<-data.frame(matrix(c(1:4),ncol=2));
a[[2]]<-data.frame(matrix(c(5:8),ncol=2))
I can use a[[1]]$X1,a[[1]]$X2,a[[2]]$X1,a[[2]]$X2 to use the corresponding
variables. But what i need to do is
Cool.
Using [[var]] instead of $var to extract the expected variable is really
what i want.
Thanks. Guys.
2010/4/7 Steve Lianoglou
> Hi,
>
> On Wed, Apr 7, 2010 at 6:27 PM, rusers.sh wrote:
> > Hi all,
> > My problem may be related with the list manipulations. See bel
Hi,
My problem maybe a little bit complicated, so forgive me if the following
words are too much.
#date set
a0<-matrix(c(1.1,1.3,1.1,1.3,1.3, 2.0,1.8,2.0,1.8,1.8,
"12/01/2008","05/20/2007","12/06/2008","05/10/2007","05/06/2007",
"N","N","A","C","A", 1,2,3,4,5),ncol=5,byrow=FALSE)
a0<-data.frame(
Hi all,
Today, i just installed the newest R version 2.10.1 and other necessary
tools for building R package under windows,e.g. Rtools, perl. All are the
newest version.
After the correct configuration under windows, i use it to re-check my old
package. I found the following prolem when check
); flush(stdout())
### Name: stKDE.simcomp
### Here, just copied my example codes, so i ignored here to save space.
### *
###
cat("Time elapsed: ", proc.time() - get("ptime", pos = 'CheckExEnv'),"\n")
grDevices::dev.off()
###
### Local variables: ***
### m
Hi there,
data1<-matrix(data=c(1,1.2,1.3,"3/23/2004",1,1.5,2.3,"3/22/2004",2,0.2,3.3,"4/23/2004",3,1.5,1.3,"5/22/2004"),nrow=4,ncol=4,byrow=TRUE)
data1<-data.frame(data1)
names(data1)<-c("areaid","x","y","date")
data1
areaid x y date
1 1 1.2 1.3 3/23/2004
2 1 1.5 2.3 3/22/200
Hi Rusers,
I hope to divide the original dataset into several subsets and output
these multilple datasets. But errors appeared in my loops. See example.
##
a<-c(1:10)
b<-c(rep(1,3),rep(2,3),rep(3,4))
c<-data.frame(a,b) #c is the example data
num<-c(unique(b))
# I hope to get the subsets c_1.
c.1
Error: object 'c.1' not found
> c.2
Error: object 'c.2' not found
> c.3
Error: object 'c.3' not found
Thanks a lot.
-
Jane Chang
Queen's
2009/11/9 Johann Hibschman
> On Nov 8, 2009, at 7:23 PM, rusers.sh wrote:
>
> for (i in n
Thanks for your ideas. They are really helpful for me to think about my
question.
Cheers,
2009/11/9 David Winsemius
>
> On Nov 9, 2009, at 8:45 AM, rusers.sh wrote:
>
> Hi Johann,
>> Excellent. That is what i really want. A little problem is why the "c.n"
>> d
Hi,
When i tried to merge two datasets (multiple to multiple merge), i met a
problem on how to stop a possible loop in the sampling arguments.
###My codes are as follows.###
data1<-matrix(data=c(1,1.2,1.3,"3/23/2004",1,1.5,2.3,"3/22/2004",2,0.2,3.3,"4/23/2004",3,1.5,1.3,"5/22/2004"),nrow=4,ncol=4
Hi Rusers,
I found sometimes that the same values cannot be judged to be the same in
R. Anybody knows the probelm? I think i ignored some minor detail. Thanks.
Here is the example.
data1<-matrix(data=c(1,1.2,1.3,"3/23/2004",1,1.5,2.3,"3/22/2004",2,0.2,3.3,"4/23/2004",3,1.5,1.3,"5/22/
lso take a look at
> the 'recycling' of arguments and then you may understand what is
> happening:
>
> > data2[(data2$x1 %in% data_1$x1) & (data2$y1 %in% data_1$y1) & (data2$tag
> == 0),]
> areaid x1 y1 tag
> 2 1 1.53 2.34 0
> 4 1 1.52
Hi,
In the following function, i hope to save my simulated data into the
"result" dataset, but why the final "result" dataset seems not to be
generated.
#Function
simdata<-function (nsim) {
result<-matrix(NA,nrow=nsim,ncol=2)
colnames(result)<-c("x","y")
for (i in 1:nsim) {
set.seed(i)
resul
Thanks very very much. It is really not easy to change from one language to
another. :)
2009/12/9 Gavin Simpson
> On Tue, 2009-12-08 at 23:22 -0500, David Winsemius wrote:
> > On Dec 8, 2009, at 11:07 PM, rusers.sh wrote:
> >
> > > Hi,
> > > In the foll
Hi all,
I want to use the npudens() function in the np package (multivariate
kernel density estimation), but was confused by the several functions in the
following codes,expand.grid(),array(),image() and npudensbw().
This confusion will only be generated in >=3 dimensions. I marked the four
pla
Hi,
I have installed the necessary tools for making a R package under windows
and am sure these tool have been correctly configured. I am very new to try
writing a package, so the error may be very obvious for you. Forgive me if
it is too easy.
My package name is *stam*, and i put it under the
Dear Duncan,
I just followed an example to try making a package. The problem is really
on the useDynLib. It works after i delete it.
Thanks a lot.
2009/12/17 Duncan Murdoch
> rusers.sh wrote:
>
>> Hi,
>> I have installed the necessary tools for making a R package under
Hi,
Anybody can give me some hints on the following problem?
s<-c(110,112321)
I want to insert a dot "." after the third number and get the following
results.
110.
112.321
Thanks a lot.
--
-
Jane Chang
Queen's
[[alternative HTML version deleted]]
_
Thanks a lot.
2009/12/20 Henrique Dallazuanna
> Try this also:
>
> sapply(s, function(x)format(x, big.interval = nchar(x) - 3, big.mark =
> "."))
>
> On Sun, Dec 20, 2009 at 7:50 PM, rusers.sh wrote:
> > Hi,
> > Anybody can give me some hints on the fo
Hi,
I got two errors after i checking my package. The errors are as follows,
Error1:
* checking for unstated dependencies in R code ... WARNING
'library' or 'require' calls not declared from:
boot np
Error2:
* checking R code for possible problems ... NOTE
myfunction: no visible global functio
is a warning and the second is a note. You did not get
> any errors.
>
> On Thu, Dec 24, 2009 at 9:40 PM, rusers.sh wrote:
> > Hi,
> > I got two errors after i checking my package. The errors are as follows,
> > Error1:
> > * checking for unstated dependencies i
Hi,
Say i have three functions in a new package, a,b and c. I only want the one
function "a" to be exported for use. "b" and "c" are not very stable.
If i specify to export all the three functions in the NAMESPACE file
(export(a,b,c)), no errors appeared after checking the package. But if i
onl
Hi,
Say i have three functions in a new package, a,b and c. I only want the one
function "a" to be exported for use. "b" and "c" are not very stable.
If i specify to export all the three functions in the NAMESPACE file
(export(a,b,c)), no errors appeared after checking the package. And i am
sur
Hi all,
I found the date format (e.g."%d/%m/%Y") in the .rd file cannot be
displayed after building the package. See below,
###.rd file
\examples{
a<-"10/20/1999"
DateConversion(a,DateIn="%m/%d/%Y",DateOut="%d/%m/%Y")
}
The result is
Examples:
a<-"10-20-1999"
DateConversion
Solved. Thanks a lot.
2010/1/7 Duncan Murdoch
> On 07/01/2010 2:09 PM, rusers.sh wrote:
>
>> Hi all,
>> I found the date format (e.g."%d/%m/%Y") in the .rd file cannot be
>> displayed after building the package. See below,
>> ###.rd file
>> \ex
Hello,
'rank' function seems to be only for vectors, but i need to get the ranks
for 3-dimensional arrays. See problems below.
#Example Data
a1<-array(1:12,c(2,3,2)); a2<-array(2,c(2,3,2)); a3<-array(0,c(2,3,2))
> a1
, , 1
[,1] [,2] [,3]
[1,]135
[2,]246
, ,
Hello,
See my problem below.
a<-data.frame(c("s","c","c","n","n","n"),c(rep(1,3),rep(2,3)),c(rep(2,3),rep(1,3)),c("01/01/1999","10/02/2000","13/02/2000","11/02/2000","15/02/2000","23/02/2000"))
colnames(a)<-c("var1","var2","var3","var4")
> a
var1 var2 var3 var4
1s1201/01/1
Thank you so much. I got it.
2010/1/18 William Dunlap
> > -Original Message-
> > From: Bert Gunter [mailto:gunter.ber...@gene.com]
> > Sent: Monday, January 18, 2010 12:32 PM
> > To: William Dunlap; 'rusers.sh'; r-help@r-project.org
> > Subje
> > -Original Message-
> > From: Bert Gunter [mailto:gunter.ber...@gene.com]
> > Sent: Monday, January 18, 2010 12:32 PM
> > To: William Dunlap; 'rusers.sh'; r-help@r-project.org
> > Subject: RE: [R] problem of data manipulation
> >
> > Absolutely... so
Hi,
See example.
for (i in 1:2) {
for (j in 1:3) {
b_1[i,j]<-rank(c(a1[i,j],a2[i,j],a3[i,j]))[1]
b_2[i,j]<-rank(c(a1[i,j],a2[i,j],a3[i,j]))[2]
b_3[i,j]<-rank(c(a1[i,j],a2[i,j],a3[i,j]))[3]
}
}
The inner codes is really repeated, so i want to change the inner codes
into loop
Winsemius
>
> On Jan 18, 2010, at 7:19 PM, rusers.sh wrote:
>
> Hi,
>> See example.
>> for (i in 1:2) {
>> for (j in 1:3) {
>>b_1[i,j]<-rank(c(a1[i,j],a2[i,j],a3[i,j]))[1]
>> b_2[i,j]<-rank(c(a1[i,j],a2[i,j],a3[i,j]))[2]
&g
Hi,
I just cannot remember the R function to divide a dataset into equal
parts. And i searched the "divide dataset into equal parts" in R site, but
cannot find it.
Anybody can tell me that function. I am just blocked by it.
Thanks a lot.
--
-
Jane Chang
Queen's
[[al
Yes. I am looking for them. Thanks.
2010/1/19 jim holtman
> ?cut
> ?split
>
> On Tue, Jan 19, 2010 at 3:18 PM, rusers.sh wrote:
> > Hi,
> > I just cannot remember the R function to divide a dataset into equal
> > parts. And i searched the "divide dataset
Hi,
I know we can use 1:10 to represent the 1,2,3,...,10 numbers, but the
following conditions are except.
Anybody knows how to represent the following two cases with similar usage
of ":" or others? Usually, i will get several hundred names for them, such
as a1,a2,... or f[[1]],f[[2]],...
#Exa
Hi,
See my example below.
a<-array(1:12,c(2,3,2))
> a
, , 1
[,1] [,2] [,3]
[1,]135
[2,]246
, , 2
[,1] [,2] [,3]
[1,]79 11
[2,]8 10 12
I want to get a result something like
dim1 dim2 dim3 elements
111
121
1
Hi all,
I want to put several figures in a one figure for easy comparison, so i
need to use the same methods to plot these figures. The following is an
example. I also list my method, but it does not work.
#Example data
x<- 1:10; y<- 1:10; z<- outer( x,y,"+");z2<- outer( x,y,"-")
#Quick view them
Thanks guys. I forgot to use the argument "zlim". It's solved.
2010/9/16 Jim Lemon
> On 09/16/2010 12:05 PM, rusers.sh wrote:
>
>> Hi all,
>> I want to put several figures in a one figure for easy comparison, so i
>> need to use the same methods to
Hi all,
rmvnorm()can be used to generate the random numbers from a multivariate
normal distribution with specified means and covariance matrix, but i want
to specify the correlation matrix instead of covariance matrix for the
multivariate
normal distribution.
Does anybody know how to generate the
similar
as that.
It will be better to only need us to specify the correlation matrix, mean
values and possible variances. One of my aim is to simulate random fields.
Thanks.
2010/8/23 Ben Bolker
> rusers.sh gmail.com> writes:
>
> > rmvnorm()can be used to generate the rand
Great. It is more clearer for me. Thanks all.
2010/8/24 Michael Dewey
> At 02:40 24/08/2010, rusers.sh wrote:
>
>> Hi all,
>> rmvnorm()can be used to generate the random numbers from a multivariate
>> normal distribution with specified means and covariance matrix, but
BTW, can you recommend a book on statistical simulations? I want to know
more on how to generate random numbers from distributions, how to generate
the theoretical models,...
Thanks a lot.
2010/8/24 Michael Dewey
> At 02:40 24/08/2010, rusers.sh wrote:
>
>> Hi all,
>> rmvno
Hi,
I read some posts from the mailing list on the same problem, but it seems
that i still cannot solve this problem.
I only want to generate some simulated data.
#Generate 2500 observations-it works without errors
> coords<-as.matrix(expand.grid(seq(0,100,length.out=50),
seq(0,100,length.out=50)
Hi all,
Anybody has ever used R to automatically search the coordinates in GE? I
searched the website, but cannot find some useful information.
My addresses are not very regular, so the methods that require the strict
address formats may be not good.
Say my address is "kingston ontario canad
Hi All,
I met a problem using readLines function to return the data from Google
maps.
readLines(url("
http://ditu.google.cn/maps/geo?q=+qianshuichong,+guichi+anhui,+CN&output=csv&key=ABQIq8Fnd_oUka-7RdS6BrD7GBTqeABoQuNTXS36G_rkiwQnKRW6GBTkns8JpKz6y6dScgB8827dlddUlg";),
n=1, warn=FALSE)
[1
se Google
Chrome as a default explorer? Or how can i find the possible solution for
IE to return the same result as Google Chrome .
Confusing.
2011/12/24 David Winsemius
>
> On Dec 24, 2011, at 4:12 AM, rusers.sh wrote:
>
> Hi All,
>> I met a problem using readLines f
suggestions or help?
ÔÚ 2011Äê12ÔÂ24ÈÕ ÏÂÎç5:12£¬rusers.sh дµÀ£º
> Hi All,
> I met a problem using readLines function to return the data from Google
> maps.
>
> readLines(url("
> http://ditu.google.cn/maps/geo?q=+qianshuichong,+guichi+anhui,+CN&output
50 matches
Mail list logo