Convenient ways of computing both simple
and log returns are at the very end of:
http://www.portfolioprobe.com/2012/11/05/an-easy-mistake-with-returns/
Those work whether you have a vector or
a matrix.
Pat
On 17/12/2012 17:16, kevj1980 wrote:
Hi, I have an n x m matrix of numerical
Hi,
help is very much appreciated. Thanks in advance!!!
rgamma(...)
As far as I know with this function (code) one can randomly sample 100
numbers simultanously.
Question is: is it possible to sample 100 random numbers e.g. from 100
different gamma distributions using only one command line (or:
Hi,
I have a dataframe containing 3 columns:
data.frame(X=c(100,102,104,102,103),Y=c(12,14,14,13,16),Time=c(1,2,3,4,5))
where X and Y are coordinates and Time refers to an index of a timestep.
Now I would like to get the distance between the consecutive timesteps.
This should actually provide
On 18/12/2012 10:56 p.m., Johannes Radinger wrote:
Hi,
I have a dataframe containing 3 columns:
data.frame(X=c(100,102,104,102,103),Y=c(12,14,14,13,16),Time=c(1,2,3,4,5))
where X and Y are coordinates and Time refers to an index of a timestep.
Now I would like to get the distance between the
Hello,
Here is a possibility:
library(maptools)
XY - cbind(X=c(100,102,104,102,103),Y=c(12,14,14,13,16))
dst - spDists(XY[1:4,],XY[2:5,],longlat=TRUE)
?spDists
HTH,
Pascal
Le 18/12/2012 18:56, Johannes Radinger a écrit :
Hi,
I have a dataframe containing 3 columns:
Thanks to all for help. The filter function appears most straightforward way
for this problem.
Kevin
--
View this message in context:
http://r.789695.n4.nabble.com/R-beginner-matrix-algebra-tp4653335p4653414.html
Sent from the R help mailing list archive at Nabble.com.
On Dec 18, 2012, at 9:07 AM, Kairos2012 lucie.salwic...@zooplus.de wrote:
Hi,
help is very much appreciated. Thanks in advance!!!
rgamma(...)
As far as I know with this function (code) one can randomly sample 100
numbers simultanously.
Question is: is it possible to sample 100
Readers,
Two variables 'M', 'T', each contain a column of numbers.
Have tried to create a derivative function to see how 'M' varies with
respect to 'T':
dm-D(m)(dm/dt)~dt
dm(m=M,t=T)
but R returns an error:
Error: could not find function dm
What is my mistake please?
--
R2151
Hi Ray,
thank you very much. That one-line approach is what I was looking for.
A very simple but very efficient way without loading any other packages.
/j
On Tue, Dec 18, 2012 at 11:17 AM, Ray Brownrigg
ray.brownr...@ecs.vuw.ac.nz wrote:
On 18/12/2012 10:56 p.m., Johannes Radinger wrote:
Hi,
Tilottama Ghosh waggymaggy at yahoo.com writes:
Hi,
Following Anthony's reply I am attaching two of the POI shapefiles and the
code for creating the spatial
grid. I am not being able to read the list of these shapefiles and then
perform the points in spatial grid
function. If someone can
Right you are, A.K.
Thanks for catching that.
It should be ...
data2 - data.frame(
id = rep(data1$ID, 3),
visit = rep(1:3, rep(dim(data1)[1], 3)),
date = as.Date(c(data1$V1Date, data1$V2date, data1$V3date), %m/%d/%y),
dva = c(data1$V1a, data1$V2a, data1$V3a),
dvb = c(data1$V1b, data1$V2b,
Hi Christofer,
Check ?tapply, ?aggregate and ?ave. Here is a way of doing in using the
first function:
tapply(Dat1[, 3], list(Dat1[,1], Dat1[,2]), sum, na.rm = TRUE)
HTH,
Jorge.-
On Wed, Dec 19, 2012 at 1:36 AM, Christofer Bogaso wrote:
Dat1 -
Hi David,
I'm always working on a second edition :-) Making more progress now and
hope to submit to publisher in April.
Frank
David Winsemius wrote
On Dec 17, 2012, at 7:30 PM, Frank Harrell wrote:
In http://biostat.mc.vanderbilt.edu/RmS see the section marked R Code.
The
zip file
You are wrong about my code. The entire excel spreadsheet table should be
loaded into R. Save As to a Tab delimited text file and use read.table() to
bring the data into R.
--
David L Carlson
Associate Professor of Anthropology
Texas AM University
Hello,
I'd like to convert the below time-series data with fft or wavelet related
function and plot it.
Could you let me know
1. How to convert xts data frame format to list format ?
2. How to plot fft or wavelet diagram ?
Here is the data :
gt; class(zc)
[1] xts zoo
gt; str(zc)
An
Hello
My optmatch package is loaded and otherwise running fine.
I get an error after lcds successfully completes logistic regression and
I'm trying to obtain a propensity score:
pdist - pscore.dist(lcds)
Error: could not find function pscore.dist
I searched the help files, other online
Dear all,
Does someone know an R function implementing the method of Sison and
Glaz (1995) (see full ref below) for computing Simultaneous confidence
intervals for multinomial proportions?
As alternative method, I think to boostrap the mean of each proportion
and get in that way confidence
HI Elaine,
Regarding the second part of your question, use ?cut()
dta$Lat-floor(dta$Latitude)
res-aggregate(Range~cut(dta$Lat,breaks=c(6,10,15,20),label=c(6-10,11-15,16-20)),dta,mean)
colnames(res)-c(Rangesize,Mean)
res
# Rangesize Mean
#1 6-10 675.1920
#2 11-15 851.5500
#3
Hi,
You could also use ?xtabs()
dat1-structure(list(Col1 = structure(c(1L, 3L, 2L, 1L, 3L, 3L, 1L), .Label =
c(A,
B, C), class = factor), Col2 = structure(c(2L, 2L, 1L,
1L, 2L, 1L, 2L), .Label = c(a, b), class = factor), Col3 = c(1,
2, 3, 4, 5, 6, 2)), .Names = c(Col1, Col2, Col3),
Dear R Helpers,
I'm struggling with a data preparation problem. I feel that it is a quite
easy task but I don't get it done. I hope you can help me with that.
I have a data frame looking like this:
ID - c(1,1,1,2,2,3,3,3,3)
T - c(1,2,3,1,4,3,5,6,8)
x - rep(1,9)
df - data.frame(ID,T,x)
df
ID T
Hello:
I s there a way to use xtable with objects from the psych package, particularly
principal()?
Is there a difference between princomp and principal? xtable seems to play
better with princomp.
Thank you.
Yours, Simon Kiss
*
Simon J. Kiss, PhD
Assistant
There may be more efficient ways, but here's one:
x_new - rep(0,nrow(df))
x_new - ifelse(df$T==min(T),0,1)
Regards,
José
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Carlos Nasher
Sent: 18 December 2012 14:10
To:
Dear Rui,
thankyou very much. it really worked. extremly sorry for telling you a bit late
as i was on the move.
eliza
Date: Tue, 18 Dec 2012 00:44:44 +
From: ruipbarra...@sapo.pt
To: eliza_bo...@hotmail.com
CC: r-help@r-project.org
Subject: Re: [R] subset handling
Hello,
You could
On Dec 18, 2012, at 9:24 AM, Simon Kiss sjk...@gmail.com wrote:
Hello:
I s there a way to use xtable with objects from the psych package,
particularly principal()?
Is there a difference between princomp and principal? xtable seems to play
better with princomp.
Thank you.
Yours, Simon
And yet another way.
library(reshape2)
names(Dat1) - c(big,small,nums)
dcast(Dat1 , big ~ small, sum)
John Kane
Kingston ON Canada
-Original Message-
From: bogaso.christo...@gmail.com
Sent: Tue, 18 Dec 2012 20:06:42 +0530
To: r-help@r-project.org
Subject: [R] Summarizing
You should show what you tried with aggregate and tapply.
You could use ave():
wm - as.logical(ave(df$T, df$ID, FUN=function(x)x==min(x)))
df$x_new - df$x
df$x_new[wm] - 0
df
ID T x x_new
1 1 1 1 0
2 1 2 1 1
3 1 3 1 1
4 2 1 1 0
5 2 4 1 1
6 3 3
Cross-posted on Stackoverflow:
http://stackoverflow.com/q/13935782/271616
--
Joshua Ulrich | about.me/joshuaulrich
FOSS Trading | www.fosstrading.com
On Tue, Dec 18, 2012 at 7:59 AM, 박상규 birdfir...@naver.com wrote:
Hello,
I'd like to convert the below time-series data with fft or wavelet
Dear my R friends,
I want to get a number from a list using paste function.
In my example,
lambda.rule - lambda.1se
cvtest is a list (result from cv.glmnet)
and
cvtest$lambda.1se
[1] 1.308973
I want to call the value using paste function.
I used get function but there was an error.
test -
Hey all,
I'm currently working through the problems at Project Euler -- this
question came up while working on Problem 9
(http://projecteuler.net/problem=9):
A Pythagorean triplet is a set of three natural numbers, a b c,
for which, a^2 + b^2 = c^2. For example, 3^2 + 4^2 = 9 + 16 = 25 =
5^2.
Hello:
What is the most efficient way to change the plotted variable names in mosaic
plots in the vcd package? Should one do a separate contingency table first,
change the dimension names there and then pass that to mosaic?
Or is there a way to do it simply within mosaic.
I was thinking
Simon:
What is the most efficient way to change the plotted variable names in
mosaic plots in the vcd package? Should one do a separate contingency
table first, change the dimension names there and then pass that to
mosaic? Or is there a way to do it simply within mosaic.
I was thinking
I am attempting to use optim to solve a neural network problem. I would like
to optimize coefficients that are currently stored in a matrix
Y=270 x 1
X= 27- x 14
b1= 10x14
b2= 11x1
V= 10 x 14 set of prior variances.
I have the following function:
posterior.mode1=function(y,X,b_0,b2,V) {
Hi,
You could also use:
df$x_new-unlist(lapply(split(df,df$ID),function(x)
as.numeric(min(x[,2])!=x[,2])))
df
# ID T x x_new
#1 1 1 1 0
#2 1 2 1 1
#3 1 3 1 1
#4 2 1 1 0
#5 2 4 1 1
#6 3 3 1 0
#7 3 5 1 1
#8 3 6 1 1
#9 3 8 1 1
A.K.
- Original
HI,
It guess ?get() does not work with $ elements.
x1 - list(a=c(1,2), b = c(2,4), c=c(4,5,6))
#this works
get(paste(x,1,sep=))[a]
#$a
#[1] 1 2
#or
get(paste(x,1,sep=))[[2]]
#[1] 2 4
A.K.
- Original Message -
From: Soyeon Kim yunni0...@gmail.com
To: r-help r-help@r-project.org
Cc:
Hi,
I get the results from your method:
x_new
#[1] 0 1 1 0 1 1 1 1 1
I guess there should be three zeros, as there are three IDs.
A.K.
- Original Message -
From: Jose Iparraguirre jose.iparragui...@ageuk.org.uk
To: Carlos Nasher carlos.nas...@googlemail.com; r-help@r-project.org
# use the mtcars data frame as your starting list. save it to x
x - as.list( mtcars )
# just print one column, by hand.
x$wt
# ..dynamically choose the column you want
colname - 'wt'
# this breaks
get( paste( 'x$' , colname , sep = ) )
# this works, but doesn't do what you want, since it's
Soyeon-
A possible solution:
get(lambda.rule,envir=list2env(cvtest))
On Tue, Dec 18, 2012 at 12:34 PM, Soyeon Kim yunni0...@gmail.com wrote:
Dear my R friends,
I want to get a number from a list using paste function.
In my example,
lambda.rule - lambda.1se
cvtest is a list (result from
David:
More specifically:
library(forecast)Loading required package: parallelLoading required package:
tseries
tseries version: 0.10-30
tseries is a package for time series analysis and computational finance.
See library(help=tseries) for details.
Attaching package:
Uwe:
More specifically:
library(forecast)Loading required package: parallelLoading required package:
tseries
tseries version: 0.10-30
tseries is a package for time series analysis and computational finance.
See library(help=tseries) for details.
Attaching package:
Uwe:
Well, a simple re-install did the trick apparently:
install.packages(forecast)Installing package(s) into C:/Program
Files/R/R-2.15.2/library
(as lib is unspecified)also installing the dependency caret
trying URL
Thanks for letting me know,
Uwe
On 18.12.2012 21:00, John Kerpel wrote:
Uwe:
Well, a simple re-install did the trick apparently:
install.packages(forecast)Installing package(s) into ‘C:/Program
Files/R/R-2.15.2/library’
(as ‘lib’ is unspecified)also installing the dependency ‘caret’
Hi! I am doing a course about the R software and I have a couple of doubts.
In one of the tasks we were asigned, we have to perform a function that
simulates a bus' trip with 25 stops. In each of those stops, between 0 and
6 people can go on board. And when the total of passengers reaches 44, no
Hello,
I have done a scatterplot and now would like to add its regression line but it
does not show.
Below, the code I have used.
lm3 - lm(data$S_pH_KCl2.5_BCx~data$B_OleicoPF_BCx_per)
plot(data$S_pH_KCl2.5_BCx, data$B_OleicoPF_BCx_per)
abline(lm3)
I have been able to do the complete
You swapped the x and y variables in the plot command.
lm(y~ x)
but
plot(x, y)
On Tue, Dec 18, 2012 at 3:09 PM, Beatriz González Domínguez
harimagua...@gmail.com wrote:
Hello,
I have done a scatterplot and now would like to add its regression line but
it does not show.
Below, the code I
On 18-Dec-2012 20:09:36 Beatriz González Domínguez wrote:
Hello,
I have done a scatterplot and now would like to add its regression
line but it does not show.
Below, the code I have used.
lm3 - lm(data$S_pH_KCl2.5_BCx~data$B_OleicoPF_BCx_per)
plot(data$S_pH_KCl2.5_BCx,
Hi again!
I am doing a course about the R software and I have a couple of doubts.
In one of the tasks we were asigned, we have to perform a function that
simulates a bus' trip with 25 stops. In each of those stops, between 0 and
6 people can go on board. And when the total of passengers reaches
Forgot to cc the help list.
On 18-12-2012, at 19:40, Lu, James T wrote:
I am attempting to use optim to solve a neural network problem. I would like
to optimize coefficients that are currently stored in a matrix
Y=270 x 1
X= 27- x 14
b1= 10x14
b2= 11x1
V= 10 x 14 set of prior
Sorry, I made a mistake in re-writing your code below. See at [***]
On 18-Dec-2012 21:00:28 Ted Harding wrote:
On 18-Dec-2012 20:09:36 Beatriz González Domínguez wrote:
Hello,
I have done a scatterplot and now would like to add its regression
line but it does not show.
Below, the code I
Your English is fine, but your intentions are not. This list has a no
homework policy.
-- Bert
On Tue, Dec 18, 2012 at 1:09 PM, Wanda Iriarte wanda.iria...@gmail.comwrote:
Hi again!
I am doing a course about the R software and I have a couple of doubts.
In one of the tasks we were asigned,
Hello,
There's a no home work policy but since you've obviously tried, here it
goes.
The main problem with your function is that you are testing outside the
loop. Another problem is that your function doesn't return a value. Both
problems are corrected. I also include a function that does the
On 12-12-18 1:02 PM, McCloskey, Bryan wrote:
Hey all,
I'm currently working through the problems at Project Euler -- this
question came up while working on Problem 9
(http://projecteuler.net/problem=9):
A Pythagorean triplet is a set of three natural numbers, a b c,
for which, a^2 + b^2 =
This is a bit simpler:
df$x_new - ave(df$T, df$ID, FUN=function(x)x!=min(x))
df
ID T x x_new
1 1 1 0 0
2 1 2 1 1
3 1 3 1 1
4 2 1 0 0
5 2 4 1 1
6 3 3 0 0
7 3 5 1 1
8 3 6 1 1
9 3 8 1 1
Are you sure there are no ties for the minimum value?
Hello,
Please advice on encoding data for the following clustering problem.
I have a dataset with car usage info. Dataset has the following fields:
1. Car model (Toyoya Celica, BMW, Nissan X-Trail, Mazda Cosmo, etc.)
2. Year built
3. Country where the car runs
4. Distance run by car before
I used the more complicated version because I didn't know if
df$x could contain values other than 0 and 1.
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
-Original Message-
From: David L Carlson [mailto:dcarl...@tamu.edu]
Sent: Tuesday, December 18, 2012 2:30 PM
To: William
Just noticed that I used a modified copy of df. It should be
df
ID T x x_new
1 1 1 1 0
2 1 2 1 1
3 1 3 1 1
4 2 1 1 0
5 2 4 1 1
6 3 3 1 0
7 3 5 1 1
8 3 6 1 1
9 3 8 1 1
---
David
-Original Message-
From: r-help-boun...@r-project.org
Hello-
I am using the vegan package PCMN() because I need to use option of row
weights (I am using CCA following the selection of the significant/positive
PCNM variables). In the library PCNM (PCNM function), the Moran's I is
calculated for you as part of the function. I see that I need to
Hello,
Im trying to use the package ade4 to build a taxonomy, though my data
isnt biological. Heres the data (a small subset of the real data):
dat = matrix(c(070201,0201,01,100201,0201,01,070201,0201,
01,110201,0201,01,020501,0501,01,040102,0102,02,040102
Hello,
I generally use 'moran.test' and 'moran.mc' from the 'spdep' package.
Regards,
Pascal
Le 19/12/2012 09:02, Chase, Jennifer a écrit :
Hello-
I am using the vegan package PCMN() because I need to use option of row
weights (I am using CCA following the selection of the
Hi,
I'm trying convert plink files to gds (SNPRelate).
I have the files: baep.fam, baep.bed and baep.bim
and the program to convert data is:
setwd('C:/Silvano/Incor/Baependi/Dados Baependi/')
library(gdsfmt)# versão 0.9.10
library(SNPRelate) # versão 0.9.8
# Arquivos PLINK BED
Hello
I have a one question about random sampling matrix
I want to regeneration value of matrix
For example,
Matrix A :
1 2 3
11 12 13
21 22 23 .
sample= data.frame(a[sample(1:dim(a)[1]),sample(1:dim(a)[2])])
Then,
Matrix sample :
21 23 22
11 13 12
1 3 2
But, I want
Hello,
How can I convert Close colume of the below xts time series data into a list of
Close values ?
I'd like to plot Close values as a list.
gt; head(zc)
Close
(10/15/12 09:00:00) 252.40
(10/15/12 09:01:00) 253.10
(10/15/12 09:02:00) 253.15
(10/15/12 09:03:00) 253.30
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of ???
Sent: Tuesday, December 18, 2012 9:08 PM
To: r-help@r-project.org
Subject: [R] random sampling matrix
Hello
I have a one question about random sampling matrix
62 matches
Mail list logo