Hi,
May be this helps:
set.seed(42)
T <- matrix(sample(1:20,20,replace=TRUE),ncol=5)
TEMP <- T
T1 <- T
for(i in 1: nrow(TEMP)){
for(j in 1: nrow(TEMP)){if (i <= j) T[i, j] <- 0 }}
indx <- expand.grid(rep(list(1:nrow(TEMP)),2))[,2:1]
T1[as.matrix(indx[indx[,1] <= indx[,2],])] <- 0
#or
libra
On 14-12-2013, at 08:01, Arnaud Michel wrote:
> Hello
>
> I would like to replace the for loop this below
>
> T <- as.matrix(T)
> for(i in 1: nrow(TEMP)){
> for(j in 1: nrow(TEMP)){if (i <= j) T[i, j] <- 0 }}
>
Your code is mangled.
We don’t know what T is.
You refer to TEMP in the for loop
Hello
I would like to replace the for loop this below
T <- as.matrix(T)
for(i in 1: nrow(TEMP)){
for(j in 1: nrow(TEMP)){if (i <= j) T[i, j] <- 0 }}
I don't find the function in the doc.
Thanks in advance for your help.
--
Michel ARNAUD
Chargé de mission auprès du DRH
DGDRD-Drh - TA 174/04
Av
On Sat, 14 Dec 2013, wrote:
i have write a function to convert decimal number into binary number in R.
dectobin<-function(x){
as.numeric(intToBits(x))->x1
paste(x1,collapse="")->x2
as.numeric(gsub("0+$","",x2))->x3
return(as.character(x3))}
dectobin can get right result ,it is so
I recommend
?sprintf
(4^(1/3))^3 != 4
(4^(1/3))^3 == 4
(4^(1/3))^3 - 4
format(c((4^(1/3))^3 , 4), digits=17)
sprintf("%+13.13a", c((4^(1/3))^3 , 4))
On Fri, Dec 13, 2013 at 10:11 PM, 水静流深 <1248283...@qq.com> wrote:
> i have write a function to convert decimal number into binary number in R.
>
>
Hello, I met a problem which needs your help. I reinstalled the R and Rstudio
recently. After that, I found there was a problem that the Chinese character
was garbled in Rstudio sometimes.
example 1
"richness.csv" is a file containing three columns and the names of the three
columns are "处理水平",“组
On Fri, 13 Dec 2013, Trevor Davies wrote:
Is there a quick function that can convert minutes (seconds) after midnight
to a time?
i.e 670.93 (minutes after midnight) --> 11:10:56.**
I know it can be done by hand but I thought there must be a function for
this already.
Sort of. There isn't re
i have write a function to convert decimal number into binary number in R.
dectobin<-function(x){
as.numeric(intToBits(x))->x1
paste(x1,collapse="")->x2
as.numeric(gsub("0+$","",x2))->x3
return(as.character(x3))}
dectobin can get right result ,it is so long ,is there a build-in function
Try the following, which have the usual lower.tail and log.p arguments to make
it easier to get accurate results in the tails. logspace_sub() is an R version
of
the R C-API function Rf_logspace_sub(). I haven't tested the [pq]stoppa
functions
much.
logspace_sub <- function (logx, logy)
{
#
On Dec 13, 2013, at 6:23 PM, David Winsemius wrote:
>
> On Dec 13, 2013, at 3:01 PM, Roe, Colleen wrote:
>
>> I have a plot I'd like to do wherein I plot to different y data sets and
>> want to have two different y axis's appear (perhaps one on right side and
>> one on left). I searched R h
On Dec 13, 2013, at 3:01 PM, Roe, Colleen wrote:
> I have a plot I'd like to do wherein I plot to different y data sets and want
> to have two different y axis's appear (perhaps one on right side and one on
> left). I searched R help with all the key phrases I could think of and I
> have thr
I have been trying to run a Fisher's LSD for quite some time now, however the
output I am receiving only ranks the means of each treatment in terms of
significant difference, and will not give me the actual value of "Least
Significant Difference" I am looking for. I am using a data set that has
fo
I get an invalid connection method error message when trying to write an R
object from a user-defined function to my hard drive (running Windows 7)
using write.csv. I have previously not had this problem with the same
user-defined function. The error message is
Error in isOpen(file, "w") : inval
The project I'm working on requires producing a number of large
(250,000x250,000) sparse logical matrices. I'm currently doing this
by updating the elements (turning FALSE to TRUE) of a matrix in
batches as they're identified like so:
x[idx.matrix] <- TRUE
where x is created via Matrix(nrow = n,
Hi,
Try:
mydata <- read.table("data.txt") #or read.table("data.txt",sep="")
str(mydata)
#'data.frame': 6 obs. of 6 variables:
# $ V1: int 1 1 1 1 1 1
# $ V2: int 4 4 4 2 2 2
# $ V3: int 4 2 5 3 3 3
# $ V4: int 1 2 1 1 1 1
# $ V5: int 6 3 2 1 2 4
# $ V6: int 23 28 24 24 40 22
write.tab
Hi,
Try:
d[match(unique(d$fac),d$fac),]
A.K.
On Friday, December 13, 2013 4:17 PM, Gang Chen wrote:
Suppose I have a dataframe defined as
L3 <- LETTERS[1:3]
(d <- data.frame(cbind(x = 1, y = 1:10), fac = sample(L3, 10, replace
= TRUE)))
x y fac
1 1 1 C
2 1 2 A
3 1 3
I have a plot I'd like to do wherein I plot to different y data sets and want
to have two different y axis's appear (perhaps one on right side and one on
left). I searched R help with all the key phrases I could think of and I have
three books covering ggplot but I can't find an example of doi
Hi,
On Dec 13, 2013, at 4:34 PM, Trevor Davies wrote:
> Is there a quick function that can convert minutes (seconds) after midnight
> to a time?
>
> i.e 670.93 (minutes after midnight) --> 11:10:56.**
>
> I know it can be done by hand but I thought there must be a function for
> this already.
I thought that setting colClasses to numeric would coerce errant data to NA.
Instead read.table is throwing
errors. This is not what I remember from prior experience with read.table and
it is not how I read the help page as promising:
BE<-
c(" 1841 96 42.2631.50
The Stoppa distribution is a 3-parameter distribution that generalizes the
Pareto distribution, adding a second shape parameter but no location term.
The CDF is
F(x) = [1-(x/x0)-á]è0 < x0 < x
Kleiber & Kotz (2003). *Statistical Size Distributions in Econom
> > d[match(unique(d$fac),d$fac),]
The following does the same thing a little more directly (and quickly)
d[ !duplicated(d$fac), ]
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] O
On 12/13/2013 1:14 PM, Silvano Cesar da Costa wrote:
Hi,
I'm using Sweave to create some tables. My code is:
<>=
tab1 = table(DISCIPLINA, Q1)
tab1.prop = round(addmargins(100*prop.table(tab1, 1),
FUN=list(Total=sum)), 2)
tab1.txt = xtable(tab1.prop, align="l|rr", label='Q1',
caption=c("Apre
Another neat solution! Thanks a lot, Sarah!
On Fri, Dec 13, 2013 at 4:35 PM, Sarah Goslee wrote:
> What about:
>
> lapply(levels(d$fac), function(x)head(d[d$fac == x,], 1))
>
>
> Thanks for the reproducible example. If you put set.seed(123) before
> the call to sample, then everyone who tries it
What about:
lapply(levels(d$fac), function(x)head(d[d$fac == x,], 1))
Thanks for the reproducible example. If you put set.seed(123) before
the call to sample, then everyone who tries it will get the same data
frame d.
Sarah
On Fri, Dec 13, 2013 at 4:15 PM, Gang Chen wrote:
> Suppose I have a
Perfect! Thanks a lot, A.K!
On Fri, Dec 13, 2013 at 4:21 PM, arun wrote:
>
>
> Hi,
> Try:
> d[match(unique(d$fac),d$fac),]
> A.K.
>
>
> On Friday, December 13, 2013 4:17 PM, Gang Chen
> wrote:
> Suppose I have a dataframe defined as
>
> L3 <- LETTERS[1:3]
> (d <- data.frame(cbind(x
Is there a quick function that can convert minutes (seconds) after midnight
to a time?
i.e 670.93 (minutes after midnight) --> 11:10:56.**
I know it can be done by hand but I thought there must be a function for
this already.
Thank you.
[[alternative HTML version deleted]]
Suppose I have a dataframe defined as
L3 <- LETTERS[1:3]
(d <- data.frame(cbind(x = 1, y = 1:10), fac = sample(L3, 10, replace
= TRUE)))
x y fac
1 1 1 C
2 1 2 A
3 1 3 B
4 1 4 C
5 1 5 B
6 1 6 B
7 1 7 A
8 1 8 A
9 1 9 B
10 1 10 A
I want to extract
Hi,
I'm using Sweave to create some tables. My code is:
<>=
tab1 = table(DISCIPLINA, Q1)
tab1.prop = round(addmargins(100*prop.table(tab1, 1),
FUN=list(Total=sum)), 2)
tab1.txt = xtable(tab1.prop, align="l|rr", label='Q1',
caption=c("Apresentação da proposta de programa a ser desenvolvida na
This will also work:
rownames(Geissler) <- paste0("b", Geissler$boys)
Geissler2 <-
na.omit(as.data.frame(as.table(as.matrix(Geissler[,-1]
names(Geissler2) <- c("Boys", "Girls", "Freq")
Geissler2$Boys <-
as.numeric(substr(as.character(Geissler2$Boys), 2,
nchar(as.character(Geissler2$Boys))
The following puts the data.frame into 'long' format and then drops
rows with NA's for 'n'.
f <- function(data){
df <- data.frame(
expand.grid(
boys = data[["boys"]],
girls = as.integer(sub("^g", "", colnames(data)[-1]))
),
n = unlist(data[, -1])
Perhaps this?
library(reshape2)
library(stringr)
GeisslerLong <- melt (Geissler, id.vars = c("boys"))
GeisslerLong <- transform ( GeisslerLong, girls = as.numeric ( str_replace(
variable, "g", '' )) )
GeisslerLong <- rename ( GeisslerLong, c( value = "Freq"))
GeisslerLong <- arrange ( GeisslerLo
I have data in the form of a two-way table recording the number of
families with varying numbers
of boys (rows) and girls (columns: g0 -- g12) below, also given in
dput() format.
I want to convert this to a data frame containing only the non-NA
entries, with columns
boys, girls, Freq, where Fr
You might want to rethink about getting model averaged coefficients. That
is a bunch of nonsense if you have any multicollinearity among the
predictors. Model averaged predictions might be useful.
Brian
Brian S. Cade, PhD
U. S. Geological Survey
Fort Collins Science Center
2150 Centre Ave., Bl
Hi Folks,
I have data with a format like:
IDyparam1param2groupingFactor1groupingFactor2.
1...
1
1
1
2
2
2
2
3
3
3
so several grouping factors and repeated measures. I am using trellis
and xyplot to get plot with several grouping factors.
something like xyplot(y~x|g
Hello,
I am using a negative binomial distribution in glmmADMB to fit a mixed model
and then using the MuMIn package to get model averaged coefficients. As far as
I can tell, this approach gives no estimates for the variance of the random
effects. I have been taking these from the top model a
Dear Daniel,
The centiles.pred is currently set up for a gamlss object fitted using the
function gamlss, not function lms
(but we will aim to change this soon).
The lms function uses calibration=TRUE as default
(this automatically adjusts the centile curves so that the sample %'s below
each centi
Hi Elham,
>From the (\t), It looks like the data in your data.txt file is
tab-delimited. To take care of that, set the separator string to be: "sep =
'\t' " instead of "," when you read in the file.
text <- read.table(file = "data.txt", sep = "\t")
text
write.table(text, "textfile.csv", row.names
Hi every one,
I have a text file like this:
1 4 4 1 6 23
1 4 2 2 3 28
1 4 5 1 2 24
1 2 3 1 1 24
1 2 3 1 2 40
1 2 3 1 4 22
I want to separate columns by comma, like this:
1,4,4,1,6,23
1,4,2,2,3,28
1,4,5,1,2,24
1
Try:
out[out$No%in% no.ind,]
# No. text
#2 2 def
#3 3 ee
A.K.
On Friday, December 13, 2013 8:03 AM, Mat wrote:
hello together, i want to filter a data.frame. My problem is, that i want to
filter 2 numbers.
My data.frame look like this one.
No. text
1 abc
2 def
3 ee
Dear R-helpers,
After having search everywhere on the R documentation and on R-help forum I
finally come to ask you some help.
I am willing to estimate a model with constraints on parameters. This model is
built from econometrics theory of jumping process and takes the following
reduced form o
Hello,
Try instead
no.ind <- c(2, 3)
out1 <- out[out$No %in% no.ind, ]
Hope this helps,
Rui Barradas
Em 13-12-2013 12:59, Mat escreveu:
hello together, i want to filter a data.frame. My problem is, that i want to
filter 2 numbers.
My data.frame look like this one.
No. text
1 abc
On Dec 11, 2013, at 7:30 PM, Hin-Tak Leung wrote:
> Here is a rather long discussion etc about freetype 2.5.2, problem with the
> survival package, and build R 2.15.x with gcc 4.8.x. Please feel free to skip
> forward.
>
> - freetype 2.5.2:
>
> the fix to cope with one of the Mac OS X's syste
Thanks for taking the time to look at this issue with changes in the survival
package.
There are warnings (different ones) with any of the versions mentioned - so it
is difficult to tell what to not ignore; -). In fact it is somewhat central and
essential to the surrounding text 's argument t
thanks together,
out1 <- out[(out$No %in% no.ind),]
works perfectly :-)
--
View this message in context:
http://r.789695.n4.nabble.com/filter-a-data-frame-tp4682118p4682131.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r
If you need to use cat() (why?) try using deparse() or format() on the function
cat("mytest <- ", deparse(mytest), sep="\n", file=file)
but dump() is easier
dump("mytest",file=file)
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
> -Original Message-
> From: r-help-boun...@r
Hello, Mat,
see below.
hello together, i want to filter a data.frame. My problem is, that i
want to filter 2 numbers.
My data.frame look like this one.
No. text
1 abc
2 def
3 ee
4 ff
5 gg
I want now to filter No. 2 and 3, so my solution should be look like this
on
I think the OP was asking about the agglomeration method in
hclust(), not the distance measure in dist(). And the default in
dist() is not absolute distance which is not an option, but
Euclidean distance:
> dist(cbind(v, v))
12345
2 1.414214
Hello, Ë®¾²Á÷Éî!
mytest<-function(x,f){
sum(x*f)/sum(f)
}
cat(mytest,file="c:/mytest.R")
Error in cat(list(...), file, sep, fill, labels, append) :
argument 1 (type 'closure') cannot be handled by 'cat'
how can i write the mytest function into a file c:/mytest.R with cat
Try %in% instead of ==
Sarah
On Friday, December 13, 2013, Mat wrote:
> hello together, i want to filter a data.frame. My problem is, that i want
> to
> filter 2 numbers.
>
> My data.frame look like this one.
>
> No. text
> 1 abc
> 2 def
> 3 ee
> 4 ff
> 5 gg
>
> I want
On 12/13/2013 05:00 AM, r-help-requ...@r-project.org wrote:
i all,
I am using the coxme function to fit random effects survival models. The
base survival models show a typical "J" shaped curve where survival drops
sharply then plateaus over time interval. I want to include a time
covariate
hello together, i want to filter a data.frame. My problem is, that i want to
filter 2 numbers.
My data.frame look like this one.
No. text
1 abc
2 def
3 ee
4 ff
5 gg
I want now to filter No. 2 and 3, so my solution should be look like this
one.
No. text
2 def
3
I was sent a copy of the data, and this is what I get on a different machine:
fit <- clogit(cc ~ addContr(A) + addContr(C) + addContr(A.C) + strata(set),
data=pscc)
Warning messages:
1: In fitter(X, Y, strats, offset, init, control, weights = weights, :
Loglik converged before variab
You are trying to average coefficients from models fitted to different
data (as you have manipulated Lat+Long values), you cannot do it using
AIC weights.
kamil
On 2013-12-11 11:00, r-help-requ...@r-project.org wrote:
Message: 26
Date: Tue, 10 Dec 2013 15:44:28 -0500
From: Catarina Ferreira
T
mytest<-function(x,f){
sum(x*f)/sum(f)
}
cat(mytest,file="c:/mytest.R")
Error in cat(list(...), file, sep, fill, labels, append) :
argument 1 (type 'closure') cannot be handled by 'cat'
how can i write the mytest function into a file c:/mytest.R with cat function?
how to use the readBin ?
i want to write the extended ascii character `Å` into a file named c:/testbin,
and read it in the R console ,display it as `Å` in R console.
now i can write it .
zz <- file("c:/testbin", "wb")
writeBin(charToRaw("\u0152"), zz)
close(zz)
when i open the file with offic
On 13 Dec 2013, at 08:03 , 水静流深 <1248283...@qq.com> wrote:
> in http://www.ascii-code.com/, you can see the the hex value of Œ is 8C,
>
(Looks like Brian got his version mangled in transmission.)
Anything above 7F is not ASCII.
Various "8-bit extensions" put various non-ASCII characters at va
On 13/12/2013 07:59, Prof Brian Ripley wrote:
On 13/12/2013 07:03, 水静流深 wrote:
in http://www.ascii-code.com/, you can see the the hex value of Å’ is 8C,
I don't see that: that is two characters and they are C5 and 92 in that
table. 8C is a AE ligature, there.
Typo: OE as in your subject lin
On 13/12/2013 07:03, 水静流深 wrote:
in http://www.ascii-code.com/, you can see the the hex value of Å’ is 8C,
I don't see that: that is two characters and they are C5 and 92 in that
table. 8C is a AE ligature, there.
And what the 'hex value' is depends on the locale: see the preamble of
that
58 matches
Mail list logo