HI,
Assuming a matrix:
set.seed(15)
mat1<-matrix(sample(-10:10,40,replace=TRUE),ncol=5)
apply(mat1,2,function(x) ifelse(x<0,x+24, x))
# [,1] [,2] [,3] [,4] [,5]
#[1,] 2 4 23 1 0
#[2,] 18 7 10 3 16
#[3,] 10 16 16 16 0
#[4,] 3 3 6 17 3
#[5,] 21
Hi AK
I got the gg plots , thanks. All of a sudden I just got it. I didn't even
update packages. Not sure what worked.
Just a basic confusion, to find out if in the association between HiBP and
Obese/Overweight status, to quantify if obese males and obese females run a
different risk of becoming
Thanks Arun,Petr,Greg and Christophe,
I have some possibilities to consider now :-)
Cheers / Frank
On 01/18/2013 08:37 AM, arun wrote:
Hi,
Sorry, there was a mistake. I didn't notice comma in key3
.Lines1<-readLines(textConnection('key1=23, key2=67, key3="hello there"
key1=7, key2=22, key3="
Hi m p,
You can use either
apply(fhours, 2, function(x) ifelse(x < 0, x + 24, x)
or
shours <- fhours
shours[shours < 0 ] <- shours[shours < 0 ] + 24
shours
HTH,
Jorge.-
On Sat, Jan 19, 2013 at 4:17 PM, m p <> wrote:
> Hello,
> It should be easu but I cannot figure out how to use apply func
Hello,
It should be easu but I cannot figure out how to use apply function. I am
trying to replace negative values in an array with these values + 24.
Would appreciate help. Thanks,
Mark
shours <- apply(fhours, function(x){if (x < 0) x <- x+24})
Error in match.fun(FUN) : argument "FUN" is missing,
Dear r-users,
Actually, this is not a big problem, however it is a bit annoying. Everytime I
want to use Tinn-R and R. I have to do this step first before I can excute a
set of R codes:
R--> configure --> temporarily (current session)
if not it will give this message:
> .trPaths <- paste
On Jan 18, 2013, at 3:13 PM, Jeff Newmiller wrote:
> If you have a lot of names to change, or you need to do it regularly, you can
> use something like:
>
> renames <- read.table(text=
> "oldname newname
> constant c
> numbers b
> ", header=TRUE, as.is=TRUE )
> names(seba)[match(renames$oldname
Hello,
Right, thanks for the explanation, it saved me time.
Rui Barradas
Em 18-01-2013 22:50, David Alston escreveu:
Greetings!
I hope you don't mind, Rui Barradas, but I'd like to explain the
regex. Parsing it was a fun exercise!
Here's the regex broken into two parts..
[[:alp
Hi Sarah, that works perfectly, thank you!
Mark Na
On Fri, Jan 18, 2013 at 5:23 PM, Sarah Goslee wrote:
> Hi,
>
> You need to assign the result of the function to an object:
>
> dd1 <- dredgeit(lm1)
>
> On Fri, Jan 18, 2013 at 6:17 PM, wrote:
> > Dear R-helpers,
> >
> > I have run the code be
Dear R-helpers,
I have run the code below which I expected to make an object called dd1,
but that object does not exist.
So, in summary, my problem is that my function is meant to make an object
(dd1), and it does indeed make that object (I know that the last line of
the function prints it out) b
If you have a lot of names to change, or you need to do it regularly, you can
use something like:
renames <- read.table(text=
"oldname newname
constant c
numbers b
", header=TRUE, as.is=TRUE )
names(seba)[match(renames$oldname, names(seba))] <- renames$newnames
--
Hi,
Not sure what format you wanted the dates:
gsub("^\\w+ ","",gsub("[_]"," ",Text))
#[1] "May 09 2009" "01-01-2001"
#Another way is:
gsub("^\\w+ |\\w+_","",Text)
#[1] "May 09 2009" "01-01-2001"
res<- gsub("^\\w+ |\\w+_","",Text)
res1<-c(as.Date(res[grep(" ",res)],format="%b %d %Y"), as.D
Greetings!
I hope you don't mind, Rui Barradas, but I'd like to explain the
regex. Parsing it was a fun exercise!
Here's the regex broken into two parts..
[[:alpha:]_]* = match zero or more alphabet or underscore characters
(.*)= match zero or more characters and add
Dear All,
I have conducted an experiment in order to examine predation pressure in the
surroundings of potential wildlife road-crossing structures. I have
documented predation occurrence (binary…) in these structures and calculated
several possible explanatory variables describing the spatial hete
apply(f,1,function(x) all(duplicated(x)|duplicated(x,fromLast=TRUE)&!is.na(x)))
#[1] TRUE FALSE FALSE FALSE
A.K.
- Original Message -
From: Sam Steingold
To: r-help@r-project.org
Cc:
Sent: Friday, January 18, 2013 3:53 PM
Subject: [R] select rows with identical columns from a data
The important thing to understand is that $ is a shortcut for [[ and you
are moving into the realm where a shortcut is the longest distance between
2 points (see fortune(312)).
So your code can be something like:
state <- 'oldstate'
balance <- 'oldbalance'
dataa[[balance]][ dataa[[state]]=='AR' ]
Here are two related approaches to your problem. The first uses
a logical vector, "keep", to say which rows to keep. The second
uses an integer vector, it can be considerably faster when the columns
are not well correlated with one another (so the number of desired
rows is small proportion of the
On Jan 18, 2013, at 1:02 PM, Rui Barradas wrote:
> Hello,
>
> Try the following.
>
> complete.cases(f) & apply(f, 1, function(x) all(x == x[1]))
>
>
> Hope this helps,
>
> Rui Barradas
>
> Em 18-01-2013 20:53, Sam Steingold escreveu:
>> I have a data frame with several columns.
>> I want to
You could use the strapply function from the gsubfn package to extract the
data from strings. This will return a list that you could use with
do.call(rbind(
The stringr package may have something similar or an alternative (but I am
less familiar with that package).
On Thu, Jan 17, 2013 at 9:21
Thanks Rui for your help.
Could you also explain the underlying logic please?
Thanks and regards,
On Sat, Jan 19, 2013 at 2:43 AM, Rui Barradas wrote:
> gsub("[[:alpha:]_]*(.*)", "\\1", Text)
__
R-help@r-project.org mailing list
https://stat.ethz.ch
Hello,
Try the following.
complete.cases(f) & apply(f, 1, function(x) all(x == x[1]))
Hope this helps,
Rui Barradas
Em 18-01-2013 20:53, Sam Steingold escreveu:
I have a data frame with several columns.
I want to select the rows with no NAs (as with complete.cases)
and all columns identical
Hello,
This one seems to work.
gsub("[[:alpha:]_]*(.*)", "\\1", Text)
Hope this helps,
Rui Barradas
Em 18-01-2013 20:11, Christofer Bogaso escreveu:
Hello again,
I was trying to extract the date element from a character vector using
Regular expression. Below is a sample what I was trying t
I can do
Reduce("==",f[complete.cases(f),])
but that creates an intermediate data frame which I would love to avoid
(to save memory).
> * Sam Steingold [2013-01-18 15:53:21 -0500]:
>
> I have a data frame with several columns.
> I want to select the rows with no NAs (as with complete.cases)
> a
Hello,
I'm trying to read a file rows at a time, so as to not read the entire file
into memory. When reading the connections and readLines help, and R help
archive, it seems this should be possible with read.csv and a file connection,
making use of the "nrows" argument.
>From certain posts,
I have a data frame with several columns.
I want to select the rows with no NAs (as with complete.cases)
and all columns identical.
E.g., for
--8<---cut here---start->8---
> f <- data.frame(a=c(1,NA,NA,4),b=c(1,NA,3,40),c=c(1,NA,5,40))
> f
a b c
1 1 1 1
On Jan 18, 2013, at 10:26 AM, Henrik Bengtsson wrote:
> Christof,
>
> I've added support for this to the R.filesets package. In your case,
> then all you need to do is:
>
> library("R.filesets")
> dlf <- readDataFrame(filename, skip="^year")
>
> No need to specify any other arguments - they'r
Simply
> colnames(seba)[1] <- "c"
> colnames(seba)[2] <- "b"
Regards,
Jose
From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of
Sebastian Kruk [residuo.so...@gmail.com]
Sent: 18 January 2013 18:14
To: R-help
Subject: [R] column
Dear expeRts,
Here is a minimal example with the latest version of 'tables' (questions below):
require(tables)
saveopts <- table_options(toprule="\\toprule", midrule="\\midrule",
bottomrule="\\bottomrule",
titlerule="\\cmidrule(lr)",
rowlabeljustification="r")#, justi
On 18/01/2013 2:40 PM, Yuan, Rebecca wrote:
Hello all,
I have a data frame dataa:
newdate newstate newid newbalance newaccounts
1 31DEC2001AR 1 1170 61
2 31DEC2001VA 2 4565 54
3 31DEC2001WA 3
Hello,
Try the following.
names(seba)[grep("numbers", names(seba))] <- "b"
names(seba)[grep("constant", names(seba))] <- "c"
names(seba)
Hope this helps,
Rui Barradas
Em 18-01-2013 18:14, Sebastian Kruk escreveu:
I have a data. frame to which you want to change the names to some of their
Hello all,
I have a data frame dataa:
newdate newstate newid newbalance newaccounts
1 31DEC2001AR 1 1170 61
2 31DEC2001VA 2 4565 54
3 31DEC2001WA 3 2726 35
4 31DEC2001
On Jan 18, 2013, at 9:49 AM, Dominic Roye wrote:
> Hello,
>
> I would like to generate isolines of temperature for the 24 hours by the 12
> month. Something like hier:
> http://www.diercke.de/bilder/omeda/800/12351E.jpg.
>
> On the x-axis are the month and on the y-axis the 24 hours, than as co
Hi,
I'm doing hierarchical clustering, and want to export my dendrogram to a
tree-viewing/editing software. I can do this by converting the data to
Newick format (hc2Newick in ctc package), but I can't get branch lengths to
show in the resulting phylogram. I figured it might help to convert my
hcl
HI,
May be this helps:
dat1<-read.table(text="
id status week
1 no 1
1 no 2
1 no 3
1 no 4
1 no 5
1 no 6
1 no 7
2 no 1
2 no 2
2 no 3
2 no 4
2 yes 5
2 yes 6
2 na 7
2 na 8
2 na 9
3 no 1
3 no 2
3 no 3
3 Unknown 4
3 unknown 5
3 na 6
3 na 7
3 na 8
",sep="",header=TRUE,stringsAsFactors=FALSE,na.strings=
Hello,
I would like to generate isolines of temperature for the 24 hours by the 12
month. Something like hier:
http://www.diercke.de/bilder/omeda/800/12351E.jpg.
On the x-axis are the month and on the y-axis the 24 hours, than as contour
lines the temperature.
My data are:
'data.frame': 288 o
Hi,
May be this helps:
frames<-list(data.frame(c1=1:3,day1=17,hour1=c(10,11,6)),data.frame(c1=6:7,day1=19,hour1=8),data.frame(c1=8:10,day1=21,hour1=c(11,15,18)),data.frame(c1=12:13,day1=23,hour1=7))
par(mfrow=c(2,2))
lapply(seq_along(frames),function(i) plot(frames[[i]][,3]))
A.K.
- Origina
Hi Bert,
Thanks for your answer - I've done a good bit of research in to panel functions
this afternoon, and they're starting to seem a *little* less intimidating. I
didn't know there was a panel.lines, so that's very helpful!
Turns out that panel.loess has an argument 'horizontal', which when
Christof,
I've added support for this to the R.filesets package. In your case,
then all you need to do is:
library("R.filesets")
dlf <- readDataFrame(filename, skip="^year")
No need to specify any other arguments - they're all automagically
inferred - and the default is stringsAsFactors=FALSE.
I have a data. frame to which you want to change the names to some of their
columns.
For example:
> seba <- data.frame ('constant' = 3, 'numbers' = 1: 10, 'letters' = LETTERS
[1:10], otros = 2:11)
List their names:
> names (Seba)
[1] "constant" "numbers" "letters"
I want to rename c the column
Many thanks to everyone who chimed in on this one. I really appreciate the
time you took to help me. Especially Dave W. who made me question what
exactly I was after.
Dan N.'s solution does exactly what I want, and it helped me learn about
the eval() and parse() functions too.
Thanks again, and a
On Fri, 18 Jan 2013, bibek sharma wrote:
I have a data set from a longitudinal study ( sample below) where subjects
are followed over time. Second column (status) contains info about if
subject is dead or still in the study and third column is time measured in
the week. Here is what I need: if s
Hello R user,
I have a data set from a longitudinal study ( sample below) where
subjects are followed over time. Second column (status) contains info
about if subject is dead or still in the study and third column is
time measured in the week. Here is what I need: if status is not dead
or unknown
I have nc files for global soil moisture,here is one file
https://echange-fichiers.inra.fr/get?k=f9DDllPKdUKs5ZNQwfq
from the metadata ,the projection is cylindrical and the resolution is 25
km(it is based on authalic sphere based on International 1924 ellipsoid).As
I want to compare with other
Yes ... that's much better. RTFM, Bert.
-- Bert
On Fri, Jan 18, 2013 at 7:57 AM, Raeanne Miller
wrote:
> Hi Bert,
>
> Thanks for your answer - I've done a good bit of research in to panel
> functions this afternoon, and they're starting to seem a *little* less
> intimidating. I didn't know the
Hi,
I'm using the sem package under conditions where I know beforehand that
several models will be problematic. Because of that, I want to suppress
warnings. I've used the following code
sem(mod, S = as.matrix(dataset), N = 1000, maxiter = 1,
warn = FALSE)
But I still get warning
You need to (re-) read the Introduction to R document that comes with R,
particularly about indexing lists.
Briefly, there are three ways: integer, string, and approximate string
indexing. You seem to be stuck now using approximate string indexing with the $
operator. Integer indexing is more a
thx, works perfectly :-)
Mat
--
View this message in context:
http://r.789695.n4.nabble.com/eliminate-double-entries-in-data-frame-tp4655956p4655963.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org mailing list
h
Hello,
Both Gabor's and my way work and produce the same results:
#-- Gabor
library(zoo)
library(chron)
data1 <- "
01:23:40 5
01:23:45 10
01:23:50 12
01:23:55 7"
data2 <- "
01:23:42
01:23:47
01:23:51
01:23:54
01:23:58
01:23:59"
data1zoo <- read.zoo(text=data1, FUN=times)
data2zoo <- read.z
Hi,
Sorry, there was a mistake. I didn't notice comma in key3
.Lines1<-readLines(textConnection('key1=23, key2=67, key3="hello there"
key1=7, key2=22, key3="how are you"
key1=2, key2=77, key3="nice day, thanks"'))
res1<-read.table(text=gsub("key{0,1}\\d","",gsub("[\"]","",Lines1)),sep="=",header=
HI,
May be this helps:
Lines1<-readLines(textConnection('key1=23, key2=67, key3="hello there"
key1=7, key2=22, key3="how are you"
key1=2, key2=77, key3="nice day, thanks"'))
res<-read.table(text=gsub("key{0,1}\\d","",gsub("[\",]","",Lines1)),sep="=",header=FALSE,stringsAsFactors=F)[-1]
names(re
Hi,
We got a actuarial question which cannot be solved in Excel, so we are
wondering if R can help us on it.
As the sample table below, variable X has 50 different values and the
weighted Y has a lognormal distribution.
We want to make X into four or five classes, based on the standard
deviation
hello together,
i want to eliminate double entries in a data.frame.
I have a data.frame, like this one:
1 2
A Albert1800
B Albert1800
C Jack2000
D Mike 2200
As you can see, "Albert" is two times available.
I want a solution like this one:
1
Dear R Helpers
I am having difficulty understanding how to use the penalty matrix for the
nomROC function in package 'nonbinROC'.
The documentation says that the values of the penalty matrix code the
penalty function L[i,j] in which 0 <= L[i,j] <= 1 for
j > i. It gives an example that if we hav
Hello,
Maybe instead of a loop, you could try
lapply(frames, function(y) plot(y$hour1))
Hope this helps,
Rui Barradas
Em 18-01-2013 09:16, condor escreveu:
So by hand the command would be
par(mfrow=c(1,2))
plot(frames$'1'hour1)
plot(frames$'2'hour1)
But in my case there are far more than 2
Reanne:
UNTESTED:
I would reverse the xyplot call as xyplot(x~y,...) to get all axes set
up properly and then just write an explicit panel function using
loess() and predict.loess the "correct" way, e.g. as loess(y~x) to get
the (x,y) curve pairs to be plotted via panel.lines(y,x). You
will
Martina Ozan hotmail.com> writes:
> Hi, can anyone tell me how to nest two fixed factors using glmer in
> lme4? I have a split-plot design with two fixed factors - A (whole
> plot factor) and B (subplot factor), both with two levels. I want to
> do GLMM as I also want to include different plots a
On 18/01/2013, Gabor Grothendieck wrote:
> On Fri, Jan 18, 2013 at 7:31 AM, e-letter wrote:
>> On 16/01/2013, Rui Barradas wrote:
>>> Hello,
>>>
>>> Like this?
>>>
>>>
>>> data1 <- read.table(text = "
>>> 01:23:40 5
>>> 01:23:45 10
>>> 01:23:50 12
>>> 01:23:55 7
>>> ")
>>>
>>> data2 <- read.tabl
On 18/01/2013, Gabor Grothendieck wrote:
> On Fri, Jan 18, 2013 at 7:31 AM, e-letter wrote:
>> On 16/01/2013, Rui Barradas wrote:
>>> Hello,
>>>
>>> Like this?
>>>
>>>
>>> data1 <- read.table(text = "
>>> 01:23:40 5
>>> 01:23:45 10
>>> 01:23:50 12
>>> 01:23:55 7
>>> ")
>>>
>>> data2 <- read.tabl
dear all,
apologizes for this off topic.
I would like to inform you that registration and paper submission for
the 28th International Workshop on Statistical Modelling (IWSM)
to be held in Palermo (Italy) 8-12 July 2013 is now open at
http://iwsm2013.unipa.it
Register at http://iwsm2013.unipa.i
Respected Sir,
With reference to my mail to you and the reply mail
by you dated 9th and 16th January, 2013, I am sending the reproducible code
in the attached document named " MODIFIED ANS ". I am also attaching the
txt file named "hazModel", which is required to save in my d
Hi, can anyone tell me how to nest two fixed factors using glmer in lme4? I
have a split-plot design with two fixed factors - A (whole plot factor) and B
(subplot factor), both with two levels. I want to do GLMM as I also want to
include different plots as a random factor. But I am interested o
Hi there,
I'm using the lattice package to create an xy plot of abundance vs. depth for 5
stages of barnacle larvae from 5 species. Each panel of the plot represents a
different stage, while different loess smoothers within each panel should
represent different species.
However, I would like d
On Fri, Jan 18, 2013 at 7:31 AM, e-letter wrote:
> On 16/01/2013, Rui Barradas wrote:
>> Hello,
>>
>> Like this?
>>
>>
>> data1 <- read.table(text = "
>> 01:23:40 5
>> 01:23:45 10
>> 01:23:50 12
>> 01:23:55 7
>> ")
>>
>> data2 <- read.table(text = "
>> 01:23:42
>> 01:23:47
>> 01:23:51
>> 01:23:54
> -Original Message-
> x<-dat.col
>
> Now, is there a function (or combination of functions) that
> will let me assign the character string "dat.col" to a new
> object (called y) without actually typing the characters
> "dat$col", i.e. just by referring to x?
Yes.
dat <- data.frame
survreg does work. Hard to tell what went wrong without any code from you.
As for smoothing a Cox survival function, see example below. However, just
because you can, doesn't mean you should.
Chris
library(survival)
nn <- 10
zz <- rep(0:1, nn)
xx <- rexp(2*nn)
cc <- rexp(2*nn)
tt <- pmin(xx,
On 16/01/2013, Rui Barradas wrote:
> Hello,
>
> Like this?
>
>
> data1 <- read.table(text = "
> 01:23:40 5
> 01:23:45 10
> 01:23:50 12
> 01:23:55 7
> ")
>
> data2 <- read.table(text = "
> 01:23:42
> 01:23:47
> 01:23:51
> 01:23:54
> ")
>
> approx(as.POSIXct(data1$V1, format = "%H:%M:%S"), y = data1
On 13-01-17 6:33 PM, michele caseposta wrote:
Hi,
I just updated R and patchDVI (from CRAN).
Now I can reverse search from the pdf to the included.Rnw.
However, I cannot forward search from the included to the pdf. Is this how it
is expected to work?
I think it works if you use first line
% !
On 13-01-17 10:00 PM, John Sorkin wrote:
Rolf
Perhaps the philosophy of the help system needs to change . . .
And perhaps it doesn't. Who knows?
Maybe we just need a manual on how to use the existing help system. But
I suspect people who won't read the existing manuals won't read that
one,
Works for me.
If you want a more helpful response, provide a reproducible example of what
didn't work. It may also be necessary to explain what 'works' means to you.
Also note that ggplot2 has a dedicated forum under Google Groups that may be a
better option for this question.
-
Hi,
I am running an ANCOVA model like:
aov(Y ~ Var1 + Var2 + Var3 + Var4 + CoVar1 + CoVar2)
where Y is the response (metric, 1.0-1000.0), VarX are all
metric predictors, and CoVarX are two Covariates each a
factor of 4-5 levels.
So far as I can remember results of an ANCOVA for a Covariate
of i
Hi
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of condor
> Sent: Friday, January 18, 2013 10:17 AM
> To: r-help@r-project.org
> Subject: Re: [R] plotting from dataframes
>
> So by hand the command would be
>
> par(mfrow=c(1
Hi
One option are regular expressions but you can also read data with "=" as
separator.
test<-read.table("input_kvpairs.csv", sep=c("="), header=F, stringsAsFactors=F)
#use this function to split and extract numeric parts
extract<-function(x) as.numeric(sapply(strsplit(x,","),"[",1))
# and app
Thanks,I am using windows
--
View this message in context:
http://r.789695.n4.nabble.com/How-to-calculate-monthly-average-from-daily-files-in-R-tp4655869p4655933.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org m
So by hand the command would be
par(mfrow=c(1,2))
plot(frames$'1'hour1)
plot(frames$'2'hour1)
But in my case there are far more than 2 days, so I want to use a loop.
Suppose I have 10 plots
par(mfrow=c(2,5))
for(i in 1:10){
plot( /what should be put here??/)
}
--
View this message in context:
Hi,
I'm trying to write a code (see below) to randomly resample measurements of
one variable (say here the variable "counts" in the data frame "dat") with
different resampled subsample sizes.
The code works fine for a single resampled subsample size (in the code below
= 10).
I then tried to genera
Dear All,
I am plotting a graph in ggplot, I would like to magnify the values between 0-1
without losing data in the higher range. How can I do that? neither
scale_y_continous nor coord_cartesian works.
Thank you
Özgül
Université Libre de Bruxelles
_
Hello,
I guess that you are working on Windows. So, I don't know whether the
following is pertinent or not.
On Linux, the first file is 'ET100.bin', not 'ET1.bin'. Thus, the first
'monthly' mean is calculated between April, 10 and May, 10.
You can try the following script. When I read your
Thank you very much Andrew! I will follow your suggestion.
Spyros
--
View this message in context:
http://r.789695.n4.nabble.com/Explore-patterns-with-GAM-tp4655838p4655928.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-pro
78 matches
Mail list logo