gmane.comp.lang.r.general
http://blog.gmane.org/gmane.comp.lang.r.general
hourly11901-01-01T00:00+00:00Gmanehttp://gmane.org/img/gmane-25t.png
http://gmane.org
Matrix Manipulation
http://comments.gmane.org/gmane.comp.lang.r.general/321786
<pre>Hi guys,
Suppose I have an extremely large data frame with 2 columns and .5 mil
rows. For example, the last 6 rows may look like this:
.
..
...
89 100
93 120
95 125
101 NA
115 NA
123 NA
124 NA
I would like to manipulate this data frame to output a data frame that
looks like:,
100 89, 93, 95
120 101, 115
125 123, 124
What would be the absolute quickest way to do this, given that there are
many rows? Currently I have this:
# m is the large two column data frame
end <- na.omit(m[,'V2']);
out <- data.frame(End=end,
Start=unname(sapply(split(m[,'V1'],findInterval(m[,'V1'],end))[as.character(0:c(length(end)-1))],paste,collapse='.')))
However this is taking a little bit too long.
Thank you for your help!
[[alternative HTML version deleted]]
</pre>Alex Kim via R-help2015-07-04T10:05:04Matrix Manipulation R
http://comments.gmane.org/gmane.comp.lang.r.general/321783
<pre>Hi guys,
Suppose I have an extremely large data frame with 2 columns and .5 mil
rows. For example, the last 6 rows may look like this:
.
..
...
89 100
93 120
95 125
101 NA
115 NA
123 NA
124 NA
I would like to manipulate this data frame to output a data frame that
looks like:,
100 89, 93, 95
120 101, 115
125 123, 124
What would be the absolute quickest way to do this, given that there are
many rows? Currently I have this:
# m is the large two column data frame
end <- na.omit(m[,'V2']);
out <- data.frame(End=end,
Start=unname(sapply(split(m[,'V1'],findInterval(m[,'V1'],end))[as.character(0:c(length(end)-1))],paste,collapse='.')))
However this is taking a little bit too long.
Thank you for your help!
[[alternative HTML version deleted]]
</pre>Alex Kim2015-07-04T10:09:39Matrix Manipulation R
http://comments.gmane.org/gmane.comp.lang.r.general/321782
<pre>Hi guys,
Suppose I have an extremely large data frame with 2 columns and .5 mil
rows. For example, the last 6 rows may look like this:
.
..
...
89 100
93 120
95 125
101 NA
115 NA
123 NA
124 NA
I would like to manipulate this data frame to output a data frame that
looks like:,
100 89, 93, 95
120 101, 115
125 123, 124
What would be the absolute quickest way to do this, given that there are
many rows? Currently I have this:
# m is the large two column data frame
end <- na.omit(m[,'V2']);
out <- data.frame(End=end,
Start=unname(sapply(split(m[,'V1'],findInterval(m[,'V1'],end))[as.character(0:c(length(end)-1))],paste,collapse='.')))
However this is taking a little bit too long.
Thank you for your help!
[[alternative HTML version deleted]]
</pre>Alex Kim2015-07-04T07:36:11How to feed graphic device (png,jpeg etc) with different files names
http://comments.gmane.org/gmane.comp.lang.r.general/321771
<pre>Dear list,
I define a function to export a bunch of plots. A sample code is something
like the follow
export.plots<-function(export.type='pdf',...){
match.fun(export.type) (...)
print(plot.func1(...))
print(plot.func2(...))
print(plot.func3(...))
...
print(plot.funcn(...))
dev.off()
}
If I do pdf , everything can be exported into one file. But for other
devices, each graph is one file. Since I have so many graphs to export, I
can't tell which is what from the file names. I was thinking if I can
construct a file name for each of the 'print" function then to feed the
information to the graphic device to have an informative file name. Is it
possible? Thanks.
Jun
[[alternative HTML version deleted]]
</pre>Jun Shen2015-07-04T03:05:44matrix -> delete last row -> list
http://comments.gmane.org/gmane.comp.lang.r.general/321754
<pre>Good day R-community,
i just wondered if it is a bug or a feature...
When i have a matrix "mat" with one column and i delete the last row with
mat <- mat[-nrow(mat),] the result is a list.
So my next call mat[10,] will throw an "wrong dimension" error.
The proper call must be:
mat <- as.matrix(mat[-nrow(mat),])
So is this desired behavior or a bug?
I use R-version 2.15.3, but reconstructed this behavior in 3.2.0 as well.
greetings
</pre>Zander, Joscha2015-07-03T14:33:32timePlot legend
http://comments.gmane.org/gmane.comp.lang.r.general/321753
<pre>Dear all
I am plotting a time series using time Plot function. All goes well until i
try to modify the legend by taking it from the standard location at the
bottom, to the right side in a vertical way.
How can i do this?
This is my code:
filename <- sprintf('%s/TS_CO_all.png',folderPLOTS)
y_lab <- sprintf('CO (ug/m3)')
tit <- sprintf('EU Receptors 2010')
png(filename, width = 18 * 360, height = 9 * 360, res = 360, pointsize=240)
timePlot(data2,pollutant=models, group=TRUE, y.relation="same", avg.time
="month",
lwd = 3, ylab = y_lab, main = tit) #pLOT THE DATA AS IS
dev.off()
Best regards
--
View this message in context: http://r.789695.n4.nabble.com/timePlot-legend-tp4709366.html
Sent from the R help mailing list archive at Nabble.com.
</pre>ulasim772015-07-03T10:20:59Variance estimates for survreg vs. lm
http://comments.gmane.org/gmane.comp.lang.r.general/321750
<pre>I would like help understanding why a survival regression with no censored
data-points does not give the same variance estimates as a linear model
(see code below).
I think it must be something to do with the fact that the variance is an
actual parameter in the survival version via the log(scale), and possibly
that different assumptions are made about the distribution of the variance.
But I really don't know, I'm just guessing.
The reason I ask is because I am moving a process, that has always been
modelled using a linear model, to a survival model (because there are
sometimes a few censored data points). In the past, the censored data
points have been treated as missing which imparts bias. The variance of the
estimates in this process is key, so I need to know why they are changing
in this systematic way?!
library(survival)
ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
ctl.surv <- Surv(ctl)
trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
lmod <- lm (ctl ~ trt </pre>Richard Perry2015-07-03T15:06:56Getting predictions for skewed t-distribution
http://comments.gmane.org/gmane.comp.lang.r.general/321742
<pre>I have a small dataframe xxF, a summary of which looks like this:
T Dev
Min. :10.44 Min. :0.008929
1st Qu.:10.44 1st Qu.:0.012048
Median :18.61 Median :0.031250
Mean :17.87 Mean :0.028286
3rd Qu.:22.24 3rd Qu.:0.041667
Max. :30.37 Max. :0.050000
I managed to make a non-linear fit after a lot of fiddling with
initial values but it looks overly complicated and biologically
unconvincing in part. The general form of a skewed t-distribution
looks more appropriate so I tried selm from the sn package thus:
(Intercept.DP) T omega alpha nu
-0.015895099 0.002689226 0.002306132 -5.660870446 1.473210455
I wish to get predictions for values of T between 10 and 32 but I can't
figure out how to use those coefficients.
With an linear model or glm, even without a prediction method, it's
fairly simple to get predictions from a range of values of the
independent variable/s. For a skewed-t i</pre>Patrick Connolly2015-07-03T09:17:49what constitutes a 'complete sentence'?
http://comments.gmane.org/gmane.comp.lang.r.general/321738
<pre>Hi All,
I am upgrading a package for CRAN, and I get this note:
checking DESCRIPTION meta-information ... NOTE
Malformed Description field: should contain one or more complete sentences.
This is puzzling because:
cat DESCRIPTION
...
Description: Functions designed to test for single gene/phenotype association and for pleiotropy on genetic and genomic data.
...
In my understanding "Functions designed to test for single gene/phenotype association and for pleiotropy on genetic and genomic data.” *is* a complete sentence. So, what is complete sentence in the opinion of whomever coded that check?
Best
F
--
Federico Calboli
Ecological Genetics Research Unit
Department of Biosciences
PO Box 65 (Biocenter 3, Viikinkaari 1)
FIN-00014 University of Helsinki
Finland
federico.calboli< at >helsinki.fi
______________________________________________
R-help< at >r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.or</pre>Federico Calboli2015-07-03T08:09:54igraph plot slowness
http://comments.gmane.org/gmane.comp.lang.r.general/321735
<pre>Hi,
With the following data
ibcore01ibswitch01
ibcore01ibswitch02
ibcore01ibswitch03
ibcore02ibswitch01
ibcore02ibswitch02
ibcore02ibswitch03
ibswitch01node001
ibswitch01node002
ibswitch01node003
ibswitch02node004
ibswitch02node005
ibswitch02node006
ibswitch03node007
ibswitch03node008
ibswitch03node009
in the file "topology.txt"
and the following code:
library("igraph")
topo_data <- read.csv(file="topology.txt",head=FALSE,sep="\t")
network_data <-graph.data.frame(topo_data, directed=F)
plot(network_data)
it takes about 5 seconds for the plot to be drawn with R 3.2.0 on a
12-core 2.67 GHz Xeon X5650 server with no other CPU-intensive processes
running.
This strikes me as rather slow, particularly as my full network has over
120 components and the plot takes around 50 seconds.
Am I doing anything wrong?
(I am working over an ssh connection with X forwarding, but plotting to
a PDF file on the server does not seem to be faster.)
Cheers,
Loris
</pre>Loris Bennett2015-07-03T07:21:02Removing rows in a data frame
http://comments.gmane.org/gmane.comp.lang.r.general/321733
<pre>I have a data frame whose rows are 678013 . I would like to remove rows
from 30696 to 678013 and then attach a new column with a length of 30595.
I tried
Y<- X[-30595:678013,] and its not working
In addition how do i add a new column
Kindly assist.
Charles
[[alternative HTML version deleted]]
</pre>Charles Thuo2015-07-03T05:23:28no slot of name "fixef" for this object of class "lmerMod"
http://comments.gmane.org/gmane.comp.lang.r.general/321727
<pre> Hello everyone.
I am trying to re-analyse some data with an R function I last used in 2011. Everything seemed to work fine then, but now, using the same code, it gives me this error:
Error in R.pe(y, group1, group2, returnR = FALSE) :
no slot of name "fixef" for this object of class "lmerMod"
This is the part of the function that I think is relevant for the problem:
# preparation
#n <- rowSums(y)
N <- length(y)
k <- length(unique(group1)) # clone
g <- length(unique(group2)) # round
#
require(lme4)
# functions
R.pe <- function(y, group1, group2, returnR=TRUE) {
mod <- lmer(y ~ 1 + (1|group1)+(1|group2),verbose=FALSE)
VarComp <- lme4::VarCorr(mod)
beta0 <- as.numeric(mod< at >fixef)
var.e <- attr(VarComp, "sc")^2 # residual variance
var.a1 <- (as.numeric(VarComp[1])) # e.g. get clone R
var.a2 <- (as.numeric(VarComp[2])) # e.g. get round R
</pre>Iker Vaquero Alba2015-07-02T17:14:16checkConv problems in R
http://comments.gmane.org/gmane.comp.lang.r.general/321711
<pre>Hi All,
I hope you will give me a hand with the checkConv problems. have two
datasets, vowels and qaaf, and both have many columns. I am interested in
these 8 columns clarified as follows:
1. convergence: DV (whether participants succeeded to use CA (Cairo
Arabic) instead of MA (Minia Arabic)
2. speaker: 62 participants
3. item: as pronounced
4. style: careful/casual
5. gender: males/females
6. age: continues variable
7. residence: urbanite/rural migrant/villager
8. education: secondary or below/university/postgraduate
The only difference between the two datasets is the number of items. With
the vowels dataset, there are 1339 items; in the qaaf dataset there are
4064 items.
The aim of the test done was to know which independent variable is more
responsible for using CA forms. I used the lme4 package, function glmer.
I ran the model:
A. modelvowels <- glmer(convergence ~ gender + age + residence +
education + style+ (1|lexica</pre>Saudi Sadiq2015-07-02T11:37:40Ramanujan and the accuracy of floating point computations - using Rmpfr in R
http://comments.gmane.org/gmane.comp.lang.r.general/321709
<pre>Hi,
Ramanujan supposedly discovered that the number, 163, has this interesting property that exp(sqrt(163)*pi), which is obviously a transcendental number, is real close to an integer (close to 10^(-12)).
If I compute this using the Wolfram alpha engine, I get:
262537412640768743.99999999999925007259719818568887935385...
When I do this in R 3.1.1 (64-bit windows), I get:
262537412640768256.0000
The absolute error between the exact and R's value is 488, with a relative error of about 1.9x10^(-15).
In order to replicate Wolfram Alpha, I tried doing this in "Rmfpr" but I am unable to get accurate results:
library(Rmpfr)
1 'mpfr' number of precision 120 bits
[1] 262537412640767837.08771354274620169031
The above answer is not only inaccurate, but it is actually worse than the answer using the usual double precision. Any thoughts as to what I am doing wrong?
Thank you,
Ravi
[[alternative HTML version deleted]]
</pre>Ravi Varadhan2015-07-02T14:28:19Lattice: set col = "black" for box.rectangle and box.umbrella
http://comments.gmane.org/gmane.comp.lang.r.general/321705
<pre> Lattice's bwplot() displays and prints (using pdf()) the box.rectangle and
box.umbrella in a pale blue that is a pale gray on b&w laser printer output.
I would like to set default options so the box and whiskers are displayed
and printed in black by modifying ~/.Rprofile by adding a .First() function.
Reading Chapter 7 in Deepayan's book and the ?Startup man page did not
result in my understanding the correct syntax for
lattice.options(default.args = list(...)) in ~/.Rprofile. Web searches did
not find guidance, either.
Would appreciate help on learning how to set these options so they are
effective when R is invoked.
Rich
</pre>Rich Shepard2015-07-02T14:46:53as.numeric looses precision
http://comments.gmane.org/gmane.comp.lang.r.general/321701
<pre>I have a string that contains a number and when I convert it to a number I loose precision and I would like to know if there is a way to avoid that. Here is my example:
p <- "1087.003489"
as.numeric(p, digits=6)
R gives me 1087.003:
[1] 1087.003
I would be nice if I could keep all the decimal places after the conversion.
Thanks,
Roger
***************************************************************
This message and any attachments are for the intended recipient's use only.
This message may contain confidential, proprietary or legally privileged
information. No right to confidential or privileged treatment
of this message is waived or lost by an error in transmission.
If you have received this message in error, please immediately
notify the sender by e-mail, delete the message, any attachments and all
copies from your system and destroy any hard copies. You must
not, directly or indirectly, use, disclose, distribute,
print or copy any part of this message or any attachments if you are not
the inte</pre>Bos, Roger2015-07-02T13:54:46question
http://comments.gmane.org/gmane.comp.lang.r.general/321689
<pre>I have 682 variables in a data frame , and a function that I should feed
682 variables in this function one by one and each time save the file as a
special name!
for emaple:
my data frame file includes 682 names :
1 aaa
2 bbb
3 dfdsfg
4 fghh
.
682 fgfhg
and a function like prep(Z, aaa, .....) and each time I should change the
variable name in this function and read the variable from the data frame
and each time I should save the file as a special name such as:
prep1<- prep(z, aaa,...)
prep2<- prep(z, bbb,...)
prep3<- prep(z, dfdsfg,..)
Prep4<- prep(z, fghh,...)
How can I use loop function in R to that?
Thanks
[[alternative HTML version deleted]]
</pre>Lida Zeighami2015-07-01T18:07:55How to specified contrasts in anova (lm)
http://comments.gmane.org/gmane.comp.lang.r.general/321688
<pre>Dear list,
I have the following anova that I want to fit in R:
y_{ijk} = \mu + \alpha_i + \beta_{j(i)} + \epsilon_{ijk}
This is an application in biology, in which we are measuring a certain
(continuous) characteristic of a group of cells.
Hence y_{ijk} corresponds to the measurement on cell k of type i in batch j.
Batch is nested in type, meaning that we have multiple batches for each
cell type and each batch contains only cells of a given type. To complicate
things, the design is unbalanced.
I can "manually" fit the model, with the following constraints:
\sum_{i=1}^m \alpha_i = 0
and
\sum_{j=1}^{n_i} \beta_{j(i)} = 0.
This gives me m + 1 constraints, where m is the number of types.
A minimal (toy) example in R is:
a <- as.factor(c(rep(1, 4), rep(2, 6)))
b <- as.factor(rep(1:5, each=2))
y <- rnorm(10)
fit <- lm(y ~ a + b)
This call to lm will fit the wrong model, using two constraints (with the
"contr.sum" specification), \sum_{i=1}^m \alpha_i = 0 and \sum_{j=1}^{n}
\beta_{j} = 0, and resulting i</pre>Davide Risso2015-07-01T19:30:55checkConv and as.data.frame.default problems in R
http://comments.gmane.org/gmane.comp.lang.r.general/321684
<pre>Hi All,
I have two datasets, vowels and qaaf, and both have 8 columns clarified as
follows:
1. convergence: DV (whether participants succeeded to use CA (Cairene
Arabic) or fail to do so; hence, they use MA (Minia Arabic)
2. speaker: 62 participants
3. lexical.item: as pronounced
4. style: careful and casual
5. gender: males and females
6. age: continues variable
7. residence: urbanite, migrant to town or villager
8. education: secondary or below, university or postgraduate
The only difference between the two datasets is the number of items. With
the vowels dataset, there are 1339 items; in the qaaf dataset there are
4064 items.
The aim of the test done was to know which independent variable is more
responsible for using CA forms. I used the lme4 package, function glmer.
I ran the model:
1. modelvowels <- glmer(convergence ~ gender + age + residence +
education + style+ (1|lexical.item) + (1|speaker), data=vowels,
family='binomial')
The message came on the screen:
2. Warning message</pre>Saudi Sadiq2015-07-01T14:40:48applying coda package effectiveSize function to a list
http://comments.gmane.org/gmane.comp.lang.r.general/321679
<pre>Please help,I am spinning my wheels behind what should be a pretty simple solution. I found a solution by asking another question on here but it seems to not be effective on all my files of similar make up to the test case. I am simply trying to read data into R, group/order it by chain and atom number (V2 and V3 in the test data) and apply the effectiveSize function from the coda package to the grouped data. Previously I have tried splitting the data, and then applying the function over the new list, which, as I previously stated, only works in the test case.sapply(lst, function(x) coda::effectiveSize(x["variable"])) see comments Apply a function from a specific R package to all files in folderI have tried aggregate, ddply, and a host of other commands/packages to no avail.My data files are very large so I am hoping that someone willing to help can retrieve a file from hereI cannot interpret the error I that I am getting, that seems to pop up no matter what I do.Error in ar.yw.default(x, aic = aic, order.m</pre>debra ragland via R-help2015-07-01T13:23:03Help with order.max in ar.yw.default
http://comments.gmane.org/gmane.comp.lang.r.general/321678
<pre>Hello,
I am trying to fit my data to the default autoregressive models in R. I'm trying to apply the effectiveSize function from the coda package to a list of data frames using;
sapply(splits, function(x) coda::effectiveSize(x["V5"]))
However when I do, I get the error;
Error in ar.yw.default(x, aic = aic, order.max = order.max, na.action = na.action, :
'order.max' must be >= 1
For some reason the command above works fine if my list is smaller (otherwise, not properly split). And it works perfectly fine on one of my data sets. If I apply it to anything else (data of a similar set up) I get the error. I've tried looking for solutions on the internet but so far I've come up with nothing.
Has this happened to anyone before? Can I bypass this order. max call?
[[alternative HTML version deleted]]
______________________________________________
R-help< at >r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide </pre>debra ragland via R-help2015-07-01T12:50:21Search EngineSearch the mailing list at Gmanequery
http://search.gmane.org/?group=$group=gmane.comp.lang.r.general