Hi all,
I am sure this is simple, but being a beginner in R,I am finding it
difficult to manage myself.
I am running the following code to get a multiple line plot for two time
series variables, x and y:
plot(as.ts(cbind(x,y)), plot.type = single, col = 1:2)
I want to change the scales of both
WIth x, y are vectors, the grid is plotted by surface3d. Thanks for your
answer.
My code is here;
#SurfacePlot is plotted by above surface data
Surface - read.csv(D:/R/Surface.csv, header=F)
Surface - as.matrix(Surface)
x - Surface[2:17,1]
x - as.numeric(x) # x is vector 1x16
y -
I have the same problem you mention here. As there is no answer, did you
find the way to obtain the optimal number of groups? Thank you!
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
Hello R Experts,
I need a bit of help in using loop.
I have a matrix onto which I need to use several functions.
In a simplified form suppose my matrix is
mdat
[,1] [,2] [,3] [,4] [,5]
[1,]12345
[2,] 11 12 13 10 10
[3,]23456
[4,] 109
Hi,
?sweep
mdat -
matrix(c(1,11,2,10,5,2,12,3,9,6,3,13,4,8,7,4,10,5,9,8,5,10,6,10,4),5,5)
x - c(14,15,10,11,18)
sweep(mdat*100, 2, x, FUN='/')
[,1] [,2] [,3] [,4] [,5]
[1,] 7.142857 13.3 30 36.36364 27.8
[2,] 78.571429 80.0 130 90.90909 55.6
[3,]
On 21-05-2013, at 09:16, Suparna Mitra suparna.mitra...@gmail.com wrote:
Hello R Experts,
I need a bit of help in using loop.
I have a matrix onto which I need to use several functions.
In a simplified form suppose my matrix is
mdat
[,1] [,2] [,3] [,4] [,5]
[1,]1234
Hi All,
I am looking for a package that performs Repeated k-fold cross-validation
with Stepwise Regression.
I would greatly appreciate if someone could share with us a package(s) that
include this type of analysis.
Thank you very much in advance.
Chris
[[alternative HTML version
Hello,
If you *really* need a loop:
Data - array(NA, dim(mdat))
for(i in 1:ncol(mdat)){
Data[,i] - mdat[,i]*100/x[i]
}
But I would consider first the thread cited by Berend.
Regards,
Pascal
On 05/21/2013 06:19 PM, Suparna Mitra wrote:
Thanks for your reply Pascal.
I am presently using
Hi
maybe someone could help
Program:
NS=10
ONS=100
. some declarations
## f. START
. functions definitions
## f. STOP
for (osym in
Thanks for your reply Pascal.
I am presently using it with sweep. But here in the question I just gave
one simple example. In reality I need several functions to run. Thus I
was wondering, if without sweep, I can use loop. Also want to learn how to
do this using loop.
Any help will be really
Hi there,
I've got this matrix D with, say 10 rows and 20 columns. For each row I want
to sum the first 3 non zero elements and put them in a vector z.
So if the first row D[1,] is
0 3 5 0 8 9 3 2 4 0
then I want z
z-D[1,2]+D[1,3]+D[1,5]
But if there are less than 3 non zero elements, those
Hi Riu,
Very helpful. Thanks a million!
Andrew
-Original Message-
From: Rui Barradas [mailto:ruipbarra...@sapo.pt]
Sent: 20 May 2013 23:49
To: Lorentz, Andrew
Cc: r-help@r-project.org
Subject: Re: [R] Gamma curve fit to data with specific bins
Hello,
You are fitting a vector other
Does this work? Probably not the fastest, but I think it does the job.
foo-function(x){
temp=x[x0]
if(length(temp)=3) sum(temp[1:3])
else sum(temp)
set.seed(2)
mat-matrix(sample(0:4, 25, replace=T, prob=c(1/2,rep(1/8,4)), ncol=5)
mat
# [,1] [,2] [,3] [,4] [,5]
#[1,]012
Oops, a couple of missing brackets in the previous reply:
foo-function(x){
temp=x[x0]
if(length(temp)=3) sum(temp[1:3])
else sum(temp)
} #This was missing in the previous post
set.seed(2)
mat-matrix(sample(0:4, 25, replace=T, prob=c(1/2,rep(1/8,4))), ncol=5)
#add a right
Hi!
When inserting R plots into a document using odfWeave, I fought for a
while to get Lattice plots use the same text size as base plots. I
eventually discovered that specifying a point size via e.g.
svg(pointsize=10) has no effect on Lattice plots. One needs to adjust
the size manually via:
Dear R-Users,
While reading a GDX file from GAMS-software, the R-program does not read the
string (text) observations. Instead, it assigns some numerical values to each
text. Do you have some idea on how to read string observations?
Example in GDX file:
fid out year value
1_2_3
Dear R users,
I ran into the strange situation where a number does not seem to equal
its value. Try this:
a - seq(0.05,0.7,0.05)[3]
b - 0.15
a == b
Should this not be TRUE? a-b yields a very small number (and not 0) so
this most probably is a numerical error, but why does seq create
Hi! I'm sorry for bothering you. I'm a new R-user and I'm having some problems
while doing a microarray analysis. I'm comparing the whole genome array of a
Salmonella serovar to another 25, and my goal is to determine which genes are
differentially expressed. I'm using limma package and running
Dear R users
I have the matrix of the centres of some clusters, e.g. 20 clusters each
with 100 dimentions, so this matrix contains 20 rows * 100 columns numeric
values.
I have collected new data (each with 100 numeric values) and would like to
keep the above 20 centres fixed/'unmoved' whilst
Hello,
I am using the package arules to generate association rules. I would like
to restrict the rules so that in the left-hand side there's only one
particular element, let's call it potatoe.
If I do this:
rules - apriori(dtm.mat, parameter = list(sup = 0.4, conf =
0.9,target=rules),
Hi. Check R FAQ, section 7.31 Why doesn't R think these numbers are equal?
http://cran.r-project.org/doc/FAQ/R-FAQ.html
all.equal(a,b)
Andrija
On Mon, May 20, 2013 at 2:36 PM, Jannis bt_jan...@yahoo.de wrote:
Dear R users,
I ran into the strange situation where a number does not seem to
Hello,
That's FAQ 7.31.
Note that the increment, 0.05, is not a power of 2 so the third value of
the sequence is not exactly equal to 0.15.
Hope this helps,
Rui Barradas
Em 20-05-2013 13:36, Jannis escreveu:
Dear R users,
I ran into the strange situation where a number does not seem to
On May 20, 2013, at 10:35 PM, meng wrote:
Hi all:
If the explainary variables are ordinal,the result of regression is different
from
unordered variables.But I can't understand the result of regression from
ordered
variable.
The data is warpbreaks,which belongs to R.
If I use the
You are absolutely right.
I am storing POSIXct objects into a hash (from the hash package). However, if I
try to get them out as a vector using the values() function, they are
unclassed. And that breaks my (highly vectorized) code. Take a look at this:
h = hash()
h[[a]] = Sys.time()
You could also use:
sapply(seq_len(ncol(mdat)),function(i) mdat[,i]*100/x[i])
# [,1] [,2] [,3] [,4] [,5]
#[1,] 7.142857 13.3 30 36.36364 27.8
#[2,] 78.571429 80.0 130 90.90909 55.6
#[3,] 14.285714 20.0 40 45.45455 33.3
#[4,] 71.428571 60.0
On 21-05-2013, at 13:16, shyam basnet shyamabc2...@yahoo.com wrote:
Dear R-Users,
While reading a GDX file from GAMS-software, the R-program does not read the
string (text) observations. Instead, it assigns some numerical values to each
text. Do you have some idea on how to read string
Hi
See par.settings in xyplot
Things are also controlled by
trellis.par.get()
to see values
trellis.par.set()
eg
xyplot(~Freq|Year, data = sheep2,
groups = farm,
par.settings = list(strip.background = list(col = transparent),
axis.text =
Hi Oihane
lmFit is from the limma package, and the limma package is part of the
Bioconductor project; the Bioconductor mailing list
http://bioconductor.org/help/mailing-list/
(follow the 'Post' link) may be a more appropriate place to post this question
(after searching the archive) if
Hi,
You could try:
set.seed(24)
mat1- matrix(sample(0:5,10*20,replace=TRUE),ncol=20)
mat2- mat1
mat2[2,1:19]-0
sapply(split(mat2,row(mat2)),function(x) sum(x[x!=0][1:3],na.rm=TRUE))
# 1 2 3 4 5 6 7 8 9 10
# 5 2 12 8 5 14 6 10 10 8
mat3- mat2
mat3[2,]- 0
That's a good one, Using cumsum + rowsum would definitely be faster,
On Tue, May 21, 2013 at 6:40 AM, José Verhoeven j...@memo2.nl wrote:
Thank you, that really worked. Actually received an even shorter version:
rowSums((t(apply(D 0, 1, cumsum)) = 3) * D)
2013/5/21 Xiao He
Le mardi 21 mai 2013 à 23:30 +1000, Duncan Mackay a écrit :
Hi
See par.settings in xyplot
Things are also controlled by
trellis.par.get()
to see values
trellis.par.set()
eg
xyplot(~Freq|Year, data = sheep2,
groups = farm,
par.settings =
Please see my answers below.
Best,
Wolfgang
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Moon Qiang
Sent: Thursday, May 16, 2013 19:12
To: r-help
Subject: [R] using metafor for meta-analysis of before-after studies
Thank you, that really worked. Actually received an even shorter version:
rowSums((t(apply(D 0, 1, cumsum)) = 3) * D)
2013/5/21 Xiao He praguewaterme...@gmail.com
Oops, a couple of missing brackets in the previous reply:
foo-function(x){
temp=x[x0]
if(length(temp)=3) sum(temp[1:3])
On 05/18/2013 05:00 AM, r-help-requ...@r-project.org wrote:
hi all
this command used tt function for all variables.
How can i define a different function for each variable?
exCox.all-coxph(Surv(SURVT,STATUS) ~
RX+LOGWBC+SEX+tt(RX)+tt(LOGWBC)+tt(SEX),
data=rem.data,tt=function(x,t,...)
Hello!
I am using package VAR.
I've fitted my model:
mymodel-VAR(mydata,myp,type=const)
I can extract the Log Liklihood for THE WHOLE MODEL:
logLik(mymodel)
How could I calculate (other than manually) the corresponding Akaike
Information Criterion (AIC)?
I tried AIC - but it does not take
On 21/05/2013 16:00, Dimitri Liakhovitski wrote:
Hello!
I am using package VAR.
What is that? There is no such package on CRAN nor BioC.
I've fitted my model:
mymodel-VAR(mydata,myp,type=const)
I can extract the Log Liklihood for THE WHOLE MODEL:
logLik(mymodel)
How could I calculate
Sorry, I am using package vars
On Tue, May 21, 2013 at 11:09 AM, Prof Brian Ripley
rip...@stats.ox.ac.ukwrote:
On 21/05/2013 16:00, Dimitri Liakhovitski wrote:
Hello!
I am using package VAR.
What is that? There is no such package on CRAN nor BioC.
I've fitted my model:
That is like complaining that your hammer does not fit these newfangled Philips
screws.
These are different tools. Do not expect them to interoperate.
---
Jeff NewmillerThe . . Go
On 21/05/2013 16:11, Dimitri Liakhovitski wrote:
Sorry, I am using package vars
So you need to report the bug in that package to its maintainer.
?logLik says
Value:
Returns an object of class ‘logLik’. This is a number with at
least one attribute, ‘df’ (*d*egrees of *f*reedom),
Jannis,
Not strange. Try with numbers that can be exactly represented in binary
(that's what computers use), e.g.,
a-seq(5,70,by=5)
b-15
a==b
or fractions,
a-seq(1/32,14/32,by=1/32)
b-3/32
a==b
Most decimal fractions cannot be represented exactly although a bit of
magic will display them
Here is a reproducible example:
library(vars)
data(Canada)
mymodel - VAR(Canada, p = 2, type = const)
myLL-logLik(mymodel)
AIC(myLL)
Why does logLik(mymodel) say that df=NULL?
Might this be the reason for AIC(myLL) being numeric(0)?
Dimitri
On Tue, May 21, 2013 at 11:17 AM, Prof Brian Ripley
Thanks a million Uwe.
I used the following from a forum to do it and it worked out:
mylevels -c(-150,-100,-50,-20,-10,-5,-2,-1,1,2,5,10,20,50,100,150)
cols - jet.colors(length(mylevels) - 1)
customAxis - function() {
n - length(mylevels)
y - seq(min(mylevels), max(mylevels), length.out=n)
Greetings,
I cannot find solution for this problem (I was searching on web, but without
success):
I want to plot dose-response models for one concentration and many responses
(lets say 200) and I don´t want to do it manually.
So I use loop for this:
for (i in mydata[,2:201]){
Dear All
I have the following code for list a:
a -list(structure(c(0, 4, 8, 12, 0, 19.5581076131386, 10.7499105081144,
5.91923975728553, 0, 4.08916328337685, 2.26872955281708, 1.24929641535359
), .Dim = c(4L, 3L), .Dimnames = list(NULL, c(time, y, b
)), istate = c(2L, 107L, 250L, NA, 5L, 5L,
So if I understand you correctly, and I may not, you want to extract
the columns from a dataframe that start with y?
Using your reproducible example (thanks!):
b[, grepl(^y, colnames(b))]
y y.1 y.2
1 0.0 0.00 0.00
2 19.55811 17.023812 15.354880
3 10.74991
I don't think the problem is with the plotting, I think the problem is
with your loop. R isn't selecting random numbers, it's doing exactly
what you told, but what you told it doesn't make sense. Hint: use the
same loop but simply print out i at each iteration.
Here's a better way to do it,
that is exactly what I wanted! Thank you Sarah!
Andras
--- On Tue, 5/21/13, Sarah Goslee sarah.gos...@gmail.com wrote:
From: Sarah Goslee sarah.gos...@gmail.com
Subject: Re: [R] help with data.frame
To: Andras Farkas motyoc...@yahoo.com
Cc: r-help@r-project.org
Date: Tuesday, May 21, 2013,
Hi,
Try:
set.seed(28)
dat1-
as.data.frame(matrix(c(rep(c(5,10,15,20,25),each=3),sample(1:20,15,replace=TRUE),sample(15:35,15,replace=TRUE),sample(20:40,15,replace=TRUE)),ncol=4))
names(dat1)[1]- concentration
lapply(seq_len(ncol(dat1[,-1]))+1,function(i) {x1-
Hi,
library(stringr)
b[str_detect(colnames(b),^y)]
# y y.1 y.2
#1 0.0 0.00 0.00
#2 19.55811 17.023812 15.354880
#3 10.74991 9.024250 8.177128
#4 5.91924 4.789331 4.367188
#or
b[,!is.na(match(gsub(\\..*,,names(b)),y))]
# y y.1 y.2
#1
Le mardi 21 mai 2013 à 08:17 -0700, Jeff Newmiller a écrit :
That is like complaining that your hammer does not fit these
newfangled Philips screws.
These are different tools. Do not expect them to interoperate.
I understand that Lattice and ggplot2 do not use settings from par().
I'm fine
I want to add identifier column (Date) to a time series data frame. I want
to name the Date column be from 1 to 30 every 1440 rows.
Say I have a data like this (I simply my actual data here):
$dat
ID Var
1 1
2 4
3 6
4 7
5 7
6 8
How can
You can use rep() to create the Date column, and data.frame() to combine it.
For your simple example,
newdata - data.frame(dat, Date=rep(1:3, each=2))
On Tue, May 21, 2013 at 4:16 PM, Ye Lin ye...@lbl.gov wrote:
I want to add identifier column (Date) to a time series data frame. I want
to
At the risk of misunderstanding... (inline)
On Tue, May 21, 2013 at 12:17 PM, Milan Bouchet-Valat nalimi...@club.fr wrote:
Le mardi 21 mai 2013 à 08:17 -0700, Jeff Newmiller a écrit :
That is like complaining that your hammer does not fit these
newfangled Philips screws.
These are different
Do you want each number in Date to be repeated once (as in your
example) or appear 48 times (so that you start over every 1440 rows,
as in your request).
For the former,
rep(c(1:30),each=48)
fills the first 1440 rows.
On 21-May-13, at 1:16 PM, Ye Lin wrote:
I want to add identifier
Duh -- I mean for the latter
On 21-May-13, at 1:25 PM, Don McKenzie wrote:
Do you want each number in Date to be repeated once (as in your
example) or appear 48 times (so that you start over every 1440
rows, as in your request).
For the former,
rep(c(1:30),each=48)
fills the first 1440
May be this helps:
dat- read.table(text=
ID Var
1 1
2 4
3 6
4 7
5 7
6 8
7 9
,sep=,header=TRUE)
dat$Date-cumsum(seq_len(nrow(dat))%%2)
dat
# ID Var Date
#1 1 1 1
#2 2 4 1
#3 3 6 2
#4 4 7 2
#5 5 7 3
Am Dienstag, den 21.05.2013, 16:17 +0100 schrieb Prof Brian Ripley:
On 21/05/2013 16:11, Dimitri Liakhovitski wrote:
Sorry, I am using package vars
So you need to report the bug in that package to its maintainer.
?logLik says
Value:
Returns an object of class ‘logLik’. This
On 21/05/2013 21:24, Bert Gunter wrote:
At the risk of misunderstanding... (inline)
On Tue, May 21, 2013 at 12:17 PM, Milan Bouchet-Valat nalimi...@club.fr wrote:
Le mardi 21 mai 2013 à 08:17 -0700, Jeff Newmiller a écrit :
That is like complaining that your hammer does not fit these
Dear Rxperts,
Using the same example above, is there a way to remove the borders of
multi-panel strips and control the display of the borders of each panel..
for example, I would like to keep only side 1 2 of a panel...
Thanks,
Santosh
On Wed, May 1, 2013 at 11:11 PM, Santosh
I am new to mapping with R, and I would like to use the point.in.polygon
function from the sp package, but I am unsure of how to get my data in the
correct format for the function. The generic form of the function is as
follows:
point.in.polygon(point.x, point.y, pol.x, pol.y, mode.checked=FALSE)
Hello, I'm having a problem using the transform and get functions. I'm
probably making a dumb mistake, and I need help!
I start by making a small simulated dataset. I save the names of the
variables in var.names. Without getting into the details of it, I have to
create a custom function to
hi
I've been using this code to set a reference level for uni and
multivariate analysis
rmix$interviewmethodcode-relevel(mix$interviewmethodcode,ref=SAQ)
summary(rma.1-rma(yi,vi,mods=~interviewmethodcode,data=rmix,method=SJ,knha=F,weighted=F,intercept=T))
giving this
Hey I have a dataset like this:
Date Var day 1/1/2013 1 Tue 1/2/2013 2 Wed 1/3/2013 3 Thu 1/4/2013 4
Fri 1/5/2013 5 Sat 1/6/2013 6 Sun 1/7/2013 7 Mon 1/8/2013 8 Tue
1/9/2013 9 Wed 1/10/2013 10 Thu
And I want to plot Var~day
Here is the code I use:
rep(c(1:30),each=1440) works!
On Tue, May 21, 2013 at 1:25 PM, Don McKenzie d...@u.washington.edu wrote:
Do you want each number in Date to be repeated once (as in your example)
or appear 48 times (so that you start over every 1440 rows, as in your
request).
For the former,
it works! Thanks!
On Tue, May 21, 2013 at 1:24 PM, Sarah Goslee sarah.gos...@gmail.comwrote:
You can use rep() to create the Date column, and data.frame() to combine
it.
For your simple example,
newdata - data.frame(dat, Date=rep(1:3, each=2))
On Tue, May 21, 2013 at 4:16 PM, Ye Lin
On May 21, 2013, at 12:40 PM, Roni Kobrosly wrote:
Hello, I'm having a problem using the transform and get functions. I'm
probably making a dumb mistake, and I need help!
I start by making a small simulated dataset. I save the names of the
variables in var.names. Without getting into the
Dear Rxperts,
Ok The curly braces as we talked before,...
They appear if the group argument of xyplot function is entered as a
numeric value; and don't when the values are letters.
I just figured how to hide the strip borders...and also control the ticks
in different axes...
Any suggestions
Hi,
May be this helps:
dat1-read.table(text=
Date Var day
1/1/2013 1 Tue
1/2/2013 2 Wed
1/3/2013 3 Thu
1/4/2013 4 Fri
1/5/2013 5 Sat
1/6/2013 6 Sun
1/7/2013 7 Mon
1/8/2013 8 Tue
1/9/2013 9 Wed
1/10/2013 10 Thu
,sep=,header=TRUE,stringsAsFactors=FALSE)
I recommend that you not plan on waiting for the hash package to be redesigned
to meet your expectations. Also, your response to discovering this feature of
the hash package seems illogical.
From a computer science perspective, the hash mechanism is an implementation
trick that is intended to
Hi,
Try this:
lst1-lapply(1:5,function(i) {pdf(paste0(i,.pdf));
hist(rnorm(100),main=paste0(Histogram_,i));dev.off()}) #you can change the
numbers
A.K.
I'm trying to generate a pdf called 1.pdf, 2.pdf, 3.pdf etc and it isn't
working. My code is:
x - 0
for(i in 1:1000){
x - x + 1
HI,
I am not sure about what you expect as output.
dat1- read.table(text=
Offense Play
Y A
N B
Y A
Y C
N B
N C
,sep=,header=TRUE,stringsAsFactors=FALSE)
with(dat1,tapply(Play,list(Offense),table))
#$N
#
#B C
#2 1
#
#$Y
#
#A C
#2 1
#or
I want to make an index using IRT, I use eRm package.
I have a data frame (24 items, 4 categories, 427 cases) that works if I use
PCM (partial credit model), but, when I run RSM (rating scale model) this
appear:
Error in solve.default(parest$hessian) :
Lapack routine dgesv: system is exactly
Thanks a lot for all your help.
best wishes,
Mitra
On 21 May 2013 21:04, arun smartpink...@yahoo.com wrote:
You could also use:
sapply(seq_len(ncol(mdat)),function(i) mdat[,i]*100/x[i])
# [,1] [,2] [,3] [,4] [,5]
#[1,] 7.142857 13.3 30 36.36364 27.8
On Sat, May 18, 2013 at 7:05 AM, Stephen Milborrow mi...@sonic.net wrote:
Paul Johnson pauljoh...@gmail.com wrote:
m1 - lm(log(y) ~ log(x), data = dat)
termplot shows log(y) on the vertical. What if I want y on the vertical?
plotmo in the plotmo package has an inverse.func argument,
so
Dear Rxperts,
Sorry about that..forgot to update the numeric part of the multipanel group
indicator...
Below is the updated code... in addition to getting rid of the curly
braces, is there a better way to control the position of
panel.text flexibly instead of hardcoding.
Thanks,
santosh
q -
75 matches
Mail list logo