Hi Jun,
Here is one way to do this using the mtcars data set, although there
are probably better ways.
mtcars$sd<-runif(32,1,2)
mpgxhp<-xyplot(mpg~hp,mtcars,
main="Miles per gallon by horsepower",
xlab="Horsepower",ylab="Miles per gallon",
panel=function(x,y,ulim,llim) {
yspace<-diff(range(y)
Sorry for inconvenience. For clarification,
The matrix B looks like
> B
P Q
[1,] 1 1
[2,] 1 2
[3,] 1 3
[4,] 1 4
[5,] 2 1
[6,] 2 2
[7,] 2 3
[8,] 2 4
[9,] 3 1
[10,] 3 2
[11,] 3 3
[12,] 3 4
[13,] 4 1
[14,] 4 2
The matrix E is
> E
P Q
[1,] 4 1
[2,] 4 2
[3,] 4 3
[4,] 4 4
On Tu
On Mon, Jan 26, 2015 at 2:13 PM, hnlki wrote:
> Thank you for your answers. In fact I am using the HFCS dataset,
cool, so survey data. asdfree.com is a good place for examples. also, if
you can match any officially-published statistics, i would love to
collaborate on a post with you :)
>
Dear R users,
Suppose I have a matrix A.
> p <- 1:4
> q <- 1:5
> P<-rep(p, each=5)
> Q<-rep(q, 4)
>
> A <- cbind(P,Q)
> A
P Q
[1,] 1 1
[2,] 1 2
[3,] 1 3
[4,] 1 4
[5,] 1 5
[6,] 2 1
[7,] 2 2
[8,] 2 3
[9,] 2 4
[10,] 2 5
[11,] 3 1
[12,] 3 2
[13,] 3 3
[14,] 3 4
[15,] 3 5
[16,] 4 1
[17,]
Dear list,
I have a couple of lines (superimposed) in an xyplot and just want to add
error bars to each of the data point. It's been a while since this question
was asked last time. But the segplot from latticeExtra is not straight
forward. Just wonder if there is a better way to do this. Apprecia
On 27/01/15 13:42, Boris Steipe wrote:
sum(x, na.rm=!all(is.na(x)))
That's the kind of idiom that brings the poor chap who has to maintain it to
tears.
;-)
It looks perfectly lucid to me. If you think that that's obscure code,
you ain't been around! :-)
cheers,
Rolf Turner
--
Rolf
> sum(x, na.rm=!all(is.na(x)))
That's the kind of idiom that brings the poor chap who has to maintain it to
tears.
;-)
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read
Hi,
To those who pointed out my mistake, thanks. Using ifelse may not
return a sensible arithmetic sum.
Jim
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guid
> On 26 Jan 2015, at 23:10 , Duncan Murdoch wrote:
>
> read.table(, colClasses = "character")
>
> (You might want "factor" instead of character.)
Or maybe not. I'd expect trouble with getting the levels set to
c("C","A","G","T") for all columns.
Is this always one single line of CGAT? If so,
Hi
I have the unfortune to have some data saved as oxmetrics/pcgive file
format (.in7 & .bn7). Is there any way to import data from this format into
R? I have tried both google and the importing/exporting guide without any
luck.
Thanks in advance
Best regards,
/Mikael
[[alternative HTM
On 26/01/2015 4:52 PM, Brian Smith wrote:
> Hi,
>
> I had a table with 'T's in it. When I try to read the table, it replaces
> all the 'T's with TRUE. Is there a way that I can retain the Ts?
That only happens for columns which are all T. (You only have one row,
so every T gets converted.) The
Sven and John,
Thanks for your suggested code ... hits the mark! The code by John is what I
need to be able to use in an apply function, but I really like the simplicity
of Sven's suggestion.
Also thanks to all who replied --- really helped broaden my knowledge of R.
Allen
-Original Messa
Hi,
I had a table with 'T's in it. When I try to read the table, it replaces
all the 'T's with TRUE. Is there a way that I can retain the Ts?
thanks!
Sample table (test.txt):
xx1 xx2 0 0 2 2 A A G G A G A A C C G G G G G G A G A A A G A G A A G G A A
A G G G A G A G G G A G A G G G G G A G G G
Don,
The default for the sum function is to NOT remove NA before summing (i.e.,
option na.rm=FALSE), here's the results with na.rm=TRUE
> sum(NA,na.rm=TRUE)
[1] 0
> sum(c(NA,NA),na.rm=TRUE)
[1] 0
> sum(rep(NA,10),na.rm=TRUE)
[1] 0
> sum(as.numeric(letters[1:4]),na.rm=TRUE)
[1] 0
Warning message:
In case anyone wonders, this behavior is expected and consistent with
the note "the sum of an empty set is zero, by definition" in
help("sum"), i.e.
> x <- numeric(0)
> str(x)
num(0)
> sum(x)
[1] 0
Analogously, prod(numeric(0)) gives 1.0.
To OP, if you're in the end of the day is after the sam
Try with na.rm=TRUE.
On Jan 26, 2015 4:04 PM, "MacQueen, Don" wrote:
> I'm a little puzzled by the assertion that the result is 0.0 when all the
> elements are NA:
>
> > sum(NA)
> [1] NA
>
> > sum(c(NA,NA))
> [1] NA
>
> > sum(rep(NA, 10))
> [1] NA
>
> > sum(as.numeric(letters[1:4]))
> [1] NA
> Wa
First look at the help page for install.packages:
?install.packages
and read about the dependencies argument.
Then try
install.packages("ggplot2", dependencies=TRUE)
--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
On 1/26
I'm a little puzzled by the assertion that the result is 0.0 when all the
elements are NA:
> sum(NA)
[1] NA
> sum(c(NA,NA))
[1] NA
> sum(rep(NA, 10))
[1] NA
> sum(as.numeric(letters[1:4]))
[1] NA
Warning message:
NAs introduced by coercion
Considering that the example snippet of code has seve
I don’t think the ncdf library open netcdf4 files, which your file would seem
to be. You need the library ncdf4 for that. For variety of reasons perhaps
others can explain, ncdf4 for Windows is not on CRAN. You can download it from:
http://cirrus.ucsd.edu/~pierce/ncdf
-Roy
On Jan 26, 2015,
Hello, is there a way to convert a svykm object returned by survey::svykm
into a survfit object? The reason I am asking is that plot.survfit can plot
different transformations of survival curves, a functionality that is
currently not afforded by plot.svykm.
Thanks!
Youyi
[[alternative HTML
The message seems to be clear in that either the directory or file is not
where you think it is. Use 'choose.files()' to navigate to the file and
see what it prints out as the location.
Jim Holtman
Data Munger Guru
What is the problem that you are trying to solve?
Tell me what you want to do, n
Thank you for your answers. In fact I am using the HFCS dataset, but I need
3-SLS and SUR. Does the code work with system.fit as well?
My 5 imputed files are stacked together in one dataset. In order to use
(mitools) I need several imputed datasets. Does that mean
that I have to split my datase
Here is one way to fix the data:
# First note that "value" is a factor so we need to convert it to character
> str(zp)
'data.frame': 20 obs. of 2 variables:
$ variable: Factor w/ 5 levels "ZP.1","ZP.3",..: 1 1 1 1 2 2 2 2 3 3 ...
$ value : Factor w/ 19 levels "<0.030","<1.2",..: 3 4 2 1 7 8
Dear all,
i get the following error when reading *.nc4 data:
Error in R_nc_open: No such file or directoryError in
open.ncdf("D:/Ag/rst_1980_prate.nc4") :
Error in open.ncdf trying to open file D:/Ag/rst_1980_prate.nc4
library("ncdf")
prec <- open.ncdf("D:/Ag/rst_1980_prate.nc4")
lons <- get.
Thanks Ista for youe help, it works and I understand why.
However, I'm still confuse why the previous code lost the "factor key". It
could just have converted to factors and output factors but instead it's
outputing integer...
I'm not a very big fan of the default stringAsFactors=T, but that's
Hello,
I am having some trouble figuring out how to deal with data that has some
observations that are detection limits and others that are integers denoted
by greater and less than symbols. Ideally I would like a column that has
the data as numbers then another column with values "Measured" or "L
On 26/01/2015 16:51, Kenya Carpenter wrote:
Dear R- Help
When installing ggplot2 it seems to install correctly but then I can't load
it. My R session is copied below. Can you help?
See below
install.packages("ggplot2")
Installing package into ‘C:/Users/Kenya/Documents/R/win-library/3.1
Dear R- Help
When installing ggplot2 it seems to install correctly but then I can't load
it. My R session is copied below. Can you help?
> install.packages("ggplot2")
Installing package into ‘C:/Users/Kenya/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror
Thank you!
From: William Dunlap [mailto:wdun...@tibco.com]
Sent: Friday, January 23, 2015 7:14 PM
To: Tan, Richard
Cc: r-help@R-project.org
Subject: Re: [R] get latest dates for different people in a dataset
Here is one way. Sort the data.frame, first by Name then break ties with
CheckInDate.
Thank you!
-Original Message-
From: Chel Hee Lee [mailto:chl...@mail.usask.ca]
Sent: Friday, January 23, 2015 8:09 PM
To: Tan, Richard; 'r-help@R-project.org'
Subject: Re: [R] get latest dates for different people in a dataset
> do.call(rbind, lapply(split(data, data$Name), function(x)
Thank you!
-Original Message-
From: David Barron [mailto:dnbar...@gmail.com]
Sent: Saturday, January 24, 2015 7:56 AM
To: Tan, Richard; r-help@R-project.org
Subject: Re: [R] get latest dates for different people in a dataset
Hi Richard,
You could also do it using the package dplyr:
dta
?aggregate informs you that unless x is a time series it will be
converted to a data.frame. data.frame will convert your character to a
factor unless you tell it not to.
You can prevent this by converting vari to a data.frame yourself,
passing the stringsAsFactors argument, like this:
aggregate(d
hi nate and annelies, the survey of consumer finances and consumer
expenditure survey folders both have examples of how to run a glm on
multiply-imputed survey data.. but these examples are specifically for
complex sample survey data, which might not be what you're working with. :)
https://github
Hello list,
I have found a weird behavior of the aggregate() function when used with
characters. I think the problem as to do with converting characters to factors.
I'm trying to aggregate a character vector using an homemade function. My
function is giving me all the possible pairs of modali
Hi,
I think you want the {mitools} package.
http://cran.r-project.org/web/packages/mitools/mitools.pdf. Anthony
Damico's site, asdfree.com, has a lot of good code examples using various
government datasets.
Nate
On Mon, Jan 26, 2015 at 5:23 AM, hnlki wrote:
> Dear,
>
> My dataset consists out o
Hi Juvin,
The error "dim(X) must have a positive length" usually shows when you are
passing a vector to "apply", ie.
apply(1:5,2,mean)
#Error in apply(1:5, 2, mean) : dim(X) must have a positive length
Also, if your dataset originally has "1206" columns, it is not clear why you
n
Hi, I'd like to remove the +1.96 and - 1.96 in the bland and altman plot
andreplace them by the limits values?Here's my
functionbland.altman.ade(ok$LB_machine,ok$LB_manuel,main="B cells
count",xlim=c(0,700), ylim=c(-300,300),xlab="Mean cell count : (manual count
+digital count)/2",ylab="manual
Forgot to send to list
Dear Analies
Would the package mitools help you? It is available from CRAN.
On 26/01/2015 10:23, hnlki wrote:
Dear,
My dataset consists out of 5 imputed files (that I did not imputed myself).
Is was wondering what is the best way to analyse them in R. I am aware that
p
Ben: You have a statistical problem with a bounded response variable (0 to
100%, or 0.0 to 1.0) and thus, might make use of a logistic quantile
regression model (see Bottai et al. 2010. Logistic quantile regression for
bounded outcomes. Statistics in Medicine 29: 309-317). This requires a
logit
Javad,
You misunderstand what is meant be 'dependent' and 'independent'
variables. What you are describing is with respect to statistical
independence. Please review these basic statistical concepts
http://en.wikipedia.org/wiki/Dependent_and_independent_variables. Perhaps,
the terms 'explanator
you can also define 'na.rm' in sum() by 'NA state' of x (where x is
your vector holding the data):
sum(x, na.rm=!all(is.na(x)))
On 26 January 2015 at 13:45, Martin Maechler
wrote:
>> Jim Lemon
>> on Mon, 26 Jan 2015 11:21:03 +1100 writes:
>
> > Hi Allen, How about this:
>
>
> Jim Lemon
> on Mon, 26 Jan 2015 11:21:03 +1100 writes:
> Hi Allen, How about this:
> sum_w_NA<-function(x) ifelse(all(is.na(x)),NA,sum(x,na.rm=TRUE))
Excuse, Jim, but that's yet another "horrible misuse of ifelse()"
John Fox's reply *did* contain the "proper" solution
Dear,
My dataset consists out of 5 imputed files (that I did not imputed myself).
Is was wondering what is the best way to analyse them in R. I am aware that
packages to perform multiple imputation (like Mice & Amelia) exist, but they
are used to perform MI. As my data is already imputed, I would
Ouch. Please avoid ifelse() in non-vectorized contexts. John Fox has the right
idea.
-pd
On 26 Jan 2015, at 01:21 , Jim Lemon wrote:
> Hi Allen,
> How about this:
>
> sum_w_NA<-function(x) ifelse(all(is.na(x)),NA,sum(x,na.rm=TRUE))
>
> Jim
>
>
> On Mon, Jan 26, 2015 at 10:21 AM, Allen Bing
44 matches
Mail list logo