Displaying 20 results from an estimated 20000 matches similar to: "Subsetting by number of observations in a factor"
2018 Apr 30
1
Overlay line on a bar plot - multiple axis
Hi Miluji,
Using Jim's interpretation of your desired graph,
you could do it in ggplot2 using your dat DF by:
ggplot() +
geom_bar(data=dat,
aes(x=week,y=count,fill=city),stat="identity",position="dodge") +
coord_flip() +
geom_line(data=dat, aes(x=week, y=mean_tmin))
There would still need some work to be done to get the weekly mean
into a legend, but it is
2007 May 18
2
Problem loading library
Hi,
I have a fresh install of R 2.5.0, I then installed the pls package.
When trying to load this package I get:
> library(pls)
Attaching package: 'pls'
The following object(s) are masked from package:stats :
loadings
>
Searches show this to most often be related to attaching data,
but I haven't got any data in here: this is the first command
given
2012 Sep 28
1
Lattice bwplot(): Conditioning on one factor
I'm not able to create the proper syntax to specify a lattice bwplot() for
only one of two conditioning factors.
The syntax that produces a box plot of each of the two conditioning
factors is:
bwplot(quant ~ param | era, data=mg.d, main='Dissolved Magnesium', ylab='Concentration (mg/L)')
What I've tried unsuccessfully are:
bwplot(quant ~ param |
2007 Aug 29
2
Recoding multiple columns consistently
Hi,
I have a dataframe that contains pedigree information;
that is individual, sire and dam identities as separate
columns. It also has date of birth.
These identifiers are not numeric, or not sequential.
Obviously, an identifier can appear in one or two columns,
depending on whether it was a parent or not. These should
be consistent.
Not all identifiers appear in the individual column - it
is
2012 Dec 31
4
error when using subset (0 observations)
Hi, how are you?
My name is Irucka Embry and I would like assistance on properly
subsetting some data obtained from a .csv file.
> file <-"info_n.csv"
> INFO<- getMetaDataFromFile(file)
INFO is 92 observations of 14 variables
> INFO<- subset(INFO,site.no==02169570)
INFO is 0 observations of 14 variables
When the site.no is used I should have 1 observation of 14
2013 Aug 17
1
[LLVMdev] [brlcad-devel] Clang vs. gcc for building BRL-CAD
On Sat, Aug 17, 2013 at 7:08 AM, Tom Browder <tom.browder at gmail.com> wrote:
> On Sat, Aug 17, 2013 at 6:15 AM, Tom Browder <tom.browder at gmail.com>wrote:
>
>> On Fri, Aug 16, 2013 at 2:58 PM, Tom Browder <tom.browder at gmail.com>wrote:
>>
>>> On Fri, Aug 16, 2013 at 2:55 PM, Tom Browder <tom.browder at gmail.com>wrote:
>>>
2011 Nov 02
2
Proper Syntax for Logical Subset in Subset()
I have measured values for 47 chemicals in a stream. After processing
the original data frame through reshape2, the recast data frame has this
structure:
'data.frame': 256 obs. of 47 variables:
$ site : Factor w/ 143 levels "BC-0.5","BC-1",..: 1 1 1 2 2 2 2 2 2 2
...
$ sampdate : Date, format: "1996-04-19" "1996-05-21" ...
$ Acid :
2023 Jul 08
1
Getting an error calling MASS::boxcox in a function
Try this for your function:
BoxCoxLambda <- function(z){
y <- z
b <- boxcox(y + 1 ~ 1,lambda = seq(-5, 5, length.out = 61), plotit =
FALSE)
b$x[which.max(b$y)] # best lambda
}
***I think*** (corrections and clarification strongly welcomed!) that `~`
(the formula function) is looking for 'z' in the GlobalEnv, the caller of
apply(), and not finding it. It finds
2023 Jul 08
1
Getting an error calling MASS::boxcox in a function
No, I'm afraid I'm wrong. Something went wrong with my R session and gave
me incorrect answers. After restarting, I continued to get the same error
as you did with my supposed "fix." So just ignore what I said and sorry for
the noise.
-- Bert
On Sat, Jul 8, 2023 at 8:28?AM Bert Gunter <bgunter.4567 at gmail.com> wrote:
> Try this for your function:
>
>
2013 Apr 03
1
Superscript and for loops
Hi,
If I have data as follows:
DATA_names<-c(
"A mg kg"
"B mg kg"
"C mg kg"
"D mg kg"
"E mg kg"
"F mg kg"
"G mg kg"
"H mg kg"
How do I convert to:
-1
A (mg kg )
-1
B (mg kg )
-1
C (mg kg )
-1
D (mg kg )
-1
E (mg kg )
-1
F (mg
2010 May 02
2
Calculation error
Dear Rxperts,
Running the following code:
=======================================================
twlo=10; twhi=20; wt=154; vd=0.5; cl=0.046; tau=6; t=3; F=1;
wtkg <- wt/2.2 # convert lbs to kg
vd.pt <- wtkg * vd # compute weight-based vd (L)
cl.pt <- wtkg * cl # compute CL (L/hr)
k <- cl.pt/vd.pt # compute k (hr^-1)
cave <-
2023 Jul 08
1
Getting an error calling MASS::boxcox in a function
Hi,
Firstly, apologies as I have posted this on community.rstudio.com too.
I want to optimise a Box-Cox transformation on columns of a matrix (ie, a unique lambda for each column). So I wrote a function that includes the call to MASS::boxcox in order that it can be applied to each column easily. Except that I'm getting an error when calling the function. If I just extract a column of the
2012 Apr 16
2
Problems with subset, droplevels and lm: variable lengths differ
[Env: R 2.14.2 / Win Xp]
In the script below, I want to select some variables from
rrcov::OsloTransect, delete cases with
any missing data, and subset the data frame Oslo to remove cases for two
levels of the
factor litho that occur with low frequency.
The checks I run on my new data frame Oslo look OK, but I when I try to
fit a multivariate
linear model with lm(), I am getting an error:
2023 Jul 08
1
Getting an error calling MASS::boxcox in a function
Dear Ron and Bert,
First (and without considering why one would want to do this, e.g.,
adding a start of 1 to the data), the following works for me:
------ snip ------
> library(MASS)
> BoxCoxLambda <- function(z){
+ b <- boxcox(z + 1 ~ 1,
+ lambda = seq(-5, 5, length.out = 101),
+ plotit = FALSE)
+ b$x[which.max(b$y)]
+ }
> mrow <- 500
2012 Oct 12
4
dotchart ordering problem
I'm having an sorting problem in dotchart. I want to change the order of the
BA in groups to AB, but I haven't found any solution yet. What should I do?
And what if I want to change the groups order as well? At the bottom from
Conrol up to 10 mg/L on the top. Thank you!
x = c(39, 23, 23, 35, 30, 26, 30, 30, 29, 29, 26, 29, 34, 33)
y = c("Control", "DMSO", "0,1
2006 Nov 21
4
means over factors in mlm terms
I'm trying to write a function to find the means over factors of the
responses in a mlm (something I would do easily in SAS with PROC SUMMARY).
The not-working stub of a function to do what I want is below,
and my problem is that I don't know how to call aggregate (or
some other function) in the context of terms in a linear model
extracted from a lm/mlm object.
means.mlm <-
2013 Sep 13
1
Creating dummy vars with contrasts - why does the returned identity matrix contain all levels (and not n-1 levels) ?
Hello,
I have a problem with creating an identity matrix for glmnet by using the
contrasts function.
I have a factor with 4 levels.
When I create dummy variables I think there should be n-1 variables (in this
case 3) - so that the contrasts would be against the baseline level.
This is also what is written in the help file for 'contrasts'.
The problem is that the function
2005 Oct 11
1
a problem in random forest
Hi, there:
I spent some time on this but I think I really cannot figure it out, maybe I
missed something here:
my data looks like this:
> dim(trn3)
[1] 7361 209
> dim(val3)
[1] 7427 209
> mg.rf2<-randomForest(x=trn3[,1:208], y=trn3[,209], data=trn3, xtest=val3[,
1:208], ytest=val3[,209], importance=T)
my test data has 7427 observations but after prediction,
> dim(mg.rf2$votes)
2003 Jan 23
2
send_files failed to open filename ...
Hi everybody,
I'm mirroring some websites with rsync (daemon on the source), and I
noticed in the destination host some error messages 'send_files failed
to open filenames',
Actually, the concerned files are deleted on the source host, but I
would like to ask :
* why does rsync say these (in which phase) ?
* is these messages harmful or not ?
Here below my rsync command and some
2011 Jul 13
1
How to remove last 3 letters
Hello to everybody
I have vector of drug dosage in string format
1.5 mg , 50 mg , 100 mg , 0.5 mg ...
The task is to remove last free symbols: ' mg'
Any suggestions are highly appreciated