Displaying 20 results from an estimated 40000 matches similar to: "add a new column to data frame"
2018 Mar 20
2
Elements of Sets as dataframe column names
Hello all,
I have a set B and a dataframe df. I want to name the columns of the
dataframe after the elements of the set B.
For example, for set B with elements {{"P1"}, {"P2"}, {"P3", "P4"}} I want
to create a new dataframe with 3 columns named {"P1"} and {"P2"} and
{"P3","P4"}.
I tried colnames(df)<-(B). But it
2000 Jan 06
1
nlme
Among others, datam contains the columns: logconc, tm, dose, subj, bilirubin.
None of these are factor variables.
The following compartment models work (the first still has not
converged after 100 interations):
res1 <- nlme(logconc~p2+p3+log(dose/(exp(p1)-exp(p2))*
(exp(-exp(p2)*tm)-exp(-exp(p1)*tm))),start=list(fixed=c(5,-2,-0.1)),
fixed=list(p1+p2+p3~1),control=list(maxIter=100),
2011 Feb 02
2
Help with one of "those" apply functions
Hello there,
I'm still struggling with the *apply commands. I have 5 people with id's
from 10 to 14. I have varying amounts (nrep) of repeated outcome (value)
measured on them.
nrep <- 1:5
id <- rep(c("p1", "p2", "p3", "p4", "p5"), nrep)
value <- rnorm(length(id))
I want to create a new vector that contains the sum of the
2011 Dec 26
2
Recoding multiple TRUE/FALSE columns into a single list of TRUE columns
Hi everyone,
I need to recode multiple columns in a dataframe into a single column in a
variety of different ways. Often the values will be TRUE/FALSE and I want a
list of the columns that are true as in the Result column below:
P1 P2 P3 P4 Result
1 0 0 1 1 P3,P4
2 0 1 1 1 P2,P3,P4
3 1 0 0 0 P1
4 0 0 0 0 NA
5 1 1 1
2006 Jul 14
1
Optim()
Dear all,
I have two functions (f1, f2) and 4 unknown parameters (p1, p2, p3, p4). Both
f1 and f2 are functions of p1, p2, and p3, denoted by f1(p1, p2, p3) and
f2(p1,p2,p3) respectively.
The goal is to maximize f1(p1, p2, p3) subject to two constraints:
(1) c = k1*p4/(k1*p4+(1-k1)*f1(p1,p2,p3)), where c and k1 are some known
constants
(2) p4 = f2(p1, p2, p3)
In addition, each parameter
2007 Jun 18
4
triangle contour plots
Suppose I have three numbers p1, p2, p3 with
0 <= p1,p2,p3 <= 1 and p1+p2+p3=1,
and a function f=f(p1,p2,p3) = f(p1,p2,1-p1-p2).
How to draw a contour plot of f() on the p1+p2+p3=1 plane,
that is, an equilateral triangle?
Functions triplot(), triangle.plot(), and ternaryplot() give
only scatterplots, AFAICS
--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre,
2010 Jun 13
1
Pairwise cross correlation from data set
Dear list,
Following up on an earlier post, I would like to reorder a dataset and
compute pairwise correlations. But I'm having some real problems
getting this done.
My data looks something like:
Participant Stimulus Measurement
p1 s`1 5
p1 s`2 6.1
p1 s`3 7
p2 s`1 4.8
p2
2010 May 06
2
Data frame "pivoting"
Dear R experts,
I am trying to solve this problem, related to the possibility of
changing the shape of a data frame using a "pivoting-like" function.
I have a dataframe df of observations as follows:
ID VALIDITY YEAR PROPERTY PROPERTY VALUE
A1 2007 P1 V1
A1 2007 P2 V2
A1 2007 P3 V3
A1 2008 P1 V10
A1 2008 P2 V20
A2 2007 P5 V50
A2 2008 P6 V20
A3 2007
2011 Mar 29
4
Creating 3 vectors that sum to 1
I have 3 vectors: p1, p2, and p3. I would like each vector to be any
possible value between 0 and 1 and p1 + p2 + p3 = 1. I want to graph these
and I've thought about using scatterplot3d(). Here's what I have so far.
library(scatterplot3d)
p1 <- c(1,0,0,.5,.5,0,.5,.25,.25,.34,.33,.33,.8,.1,.1,.9,.05,.05)
p2 <- c(0,1,0,.5,0,.5,.25,.5,.25,.33,.34,.33,.1,.8,.1,.05,.9,.05)
p3 <-
2012 Oct 05
2
problem with convergence in mle2/optim function
Hello R Help,
I am trying solve an MLE convergence problem: I would like to estimate
four parameters, p1, p2, mu1, mu2, which relate to the probabilities,
P1, P2, P3, of a multinomial (trinomial) distribution. I am using the
mle2() function and feeding it a time series dataset composed of four
columns: time point, number of successes in category 1, number of
successes in category 2, and
2009 Feb 12
1
Optim
Dear R user I follow the steps defined in Modern applied statistics page(453)
to use optim. However, when I run the following code the parameters seems
way off and the third parameter(p3) stayed as the initial value.
below is the code:
## data
da=c(418,401,416,360,411,425,537,379,484,388,486,380,394,363,405,383,392,363,398,526)
### initial values
pars=c(392.25, 507.25, 0.80)
2006 Mar 15
2
Regarding aov Error()
The following dummy data frame has factor Q (with 2 levels) nesting
factor P (with levels p1 and p2 nested under q1, and p3 and p4 nested
under q2), but both crossing the random variate s, which has 8
levels. The dependent measure is dv.
> # The data frame:
> testnest
dv s P Q
1 1 s1 p1 q1
2 2 s2 p1 q1
3 1 s3 p1 q1
4 2 s4 p1 q1
5 1 s5 p1 q1
6 3 s6 p1 q1
7 3 s7
2023 Mar 09
1
reemplazar valores en texto según condiciones
Hola,
Algo que me está pasando con esta función es lo siguiente:
A "p1" lo tengo que reemplazar por "p1_integra_datos" y a "p10" por
"p10_cuales_rep", pero como p10 contiene p1, y así pasa con otras preguntas
(p2 y p20, por ejemplo),
me los reemplaza en ambas, cuándo lo que busco es otra cosa.
reglas$condicion_final <-
2008 Aug 22
1
How to handle "~" character after csv importation
Dear R users,
I have to import some csv files in which column headers contain the
character "~". Following the following import call, the character seems
to be replaced by dots in the column names of my data frame. Plus, I
cannot query names(mydata) to find the column index which header should
contain "~" or "."
> mydata <-
2023 Mar 07
1
reemplazar valores en texto según condiciones
Hola, como andan! Espero que bien!
Tengo dos bases, A) tiene una variable texto en la que deseo reemplazar
ciertas partes y B) tengo las condiciones para cambiar ese texto de la base
A.
Base A
texto
si p1 = 1 o 2 = 1,3
si p1 = 3 o 4 = 1
si p1 = 5 = 0,7
si p1 = 5 = 0,7
si p1 = 6 = 0
si p1 = 7 = "no aplica"
si p2 = 1 & p3 = 1 = 0,5
si p2 = 1 & p3 = 2 = 0,7
si p2 = 1 & p3 = 4
2023 Mar 09
1
reemplazar valores en texto según condiciones
Buenas,
Se me hace raro que la función no admita un parámetro para eso.
Una opción es hacerlo en dos pasos:
P1: Reemplaza p10, p20, ... por algo como q10, q20, ...
P2: Haz el reemplazo que quieres.
Igualmente puedes hacer el reemplazo que haces y en un segundo paso reemplazar p10_integra_datos por p10_cuales_rep, ...
Un saludo, Manuel.
El jue, 09-03-2023 a las 10:20 -0300, juan manuel dias
2005 Jun 21
2
TEQL and Subnet problem
TEQL and Subnet problem
I have a network topology shown below, and I am trying to use TEQL. My
problem is: When I ping to P3.teql0 from P2 ("[P2]# ping 16.119.144.66"),
the traffic can never go from P2.eth1, and all traffic only goes to
P1.eth0. What P2.eth1 (16.119.144.33) did is broadcasting an ARP asking
for the MAC address of 16.119.144.66, although I have specified the route
to
2018 Mar 18
1
How to take difference of sets when there is an empty subset involved
Hello,
Problem I am facing is as follows:
Set A is made of 2 sets x and y
x<-{"P1", "P2", "P3", "P4"}
y<-{}
A<-set(x,y)
#A={{}, {"P1", "P2", "P3", "P4"}}
i need to use A in a recursive loop where i need to take set difference of
A and it 's elements.
Example:
for (i in A){
print(i)
2010 Jul 23
1
(no subject)
Dear R list,
I use the constrOptim to maximize a function with four constriants but the answer does not leave from the starting value and there is only one outer iteration. The function is defined as follows:
tm<-function(p){
p1<-p[1]; p2<-p[2]; p3<-p[3];
p4<-1-p1-p2-p3;
p1*p2*p3*p4}
##the constraints are p1>=0; p2>=0; p3>=0 and p4>=0 i.e. p1+p2+p3<=1
2011 Jan 13
1
setting up a genoud run
Hello - and sorry for a possibly stupid question, I'm just starting to
learn rgenoud.
I am defining a function with 5 parameters (p1, p2, p3, p4a, and p4b)
and then want to optimize it using genoud. But I am doing something
wrong.
Before genoud is even able to run it says: "Error in p2 + 1.2 : 'p2'
is missing".
I assume I did not specify it right. My code is below.
The task