Displaying 20 results from an estimated 2000 matches similar to: "For loop..."
2012 Feb 05
1
Covariate model in nlme
Dear R users,
I am using nlme to fit a pharmacokinetic model. The base model is
parameterized in terms of CL, V1, V2 and Q.
basemodel<-nlme(Conc ~TwoCompModel(CL,Q,V1,V2,Time,ID),
data = data2, fixed=list(CL+Q+V1+V2~1),
random = pdDiag(CL+V1+V2~1),
start=c(CL=log(20),Q=log(252),V1=log(24.9),V2=log(120)),
control=list(returnObject=TRUE,msVerbose=TRUE,
msMaxIter=20,pnlsMaxIter=20,pnlsTol=1),
2013 Mar 27
9
conditional Dataframe filling
Hi everyone:
This may be trivial but I just have not been able to figure it out.
Imagine the following dataframe:
a b c d
TRUE TRUE TRUE TRUE
FALSE FALSE FALSE TRUE
FALSE TRUE FALSE FALSE
I would like to create a new dataframe, in which TRUE gets 0 but if
false then add 1 to the cell to the left. So the results for the
example above should be something like:
a b c
2012 Oct 26
3
Delete row if two values in a matrix are equal
Hi all and thank you for your time.
I would like to delete rows from this matrix I call "var" if the character
in Ref_Allele is equal to the character in Var_Allele. I have attached a
before and after, to help my poor explanation. If someone could provide me
with some code, or some guidance I would really appreciate it.
Thank you again.
"Before"
> var
Ref_Pos Ref_Allele
2013 May 13
2
reduce three columns to one with the colnames
Ein eingebundener Text mit undefiniertem Zeichensatz wurde abgetrennt.
Name: nicht verf?gbar
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130513/fe848ce7/attachment.pl>
2012 Oct 24
2
Recode function car package erases previous values
Hi all,
I am attempting to create a new variable based on values of other variables. The variable is called pharm. It basically takes the numeric code of 1 as yes and 0 to be No from the variable B20_C1 (a question on a survey). However, I would also like to have a level for non-respondents and these are captured in the variable nr.B20C, which is a 1 when there is a non-response on the whole group
2013 Feb 07
4
why "object 'x' not found"?
Dear Listers,
I try to change the structure of my data. i have an indicator-matrix and
want to end up with a factor.
i have
v1 v2 v3
1 0 0
0 1 0
0 0 1
and want
v1 v2 v3 v4
1 0 0 1
0 1 0 2
0 0 1 3
amongst other things i tried the following
d <- data.frame(d1=c(1,0,0), d2=c(0,1,0), d3=c(0,0,1))
d$nr <- NA
sapply(1:3, function(x)
2013 Feb 08
2
How to debug the C programs associated with R-packages?
hello,
I was having some problems in debugging C codes assocaited with R-packages.
I don't have much experience with debugging tools used in C language. Is
there any methods similar to R-debugging tools such as browser ,debug etc
which can be used to debug such C files.
I was using the foreign package and found a bug in reading dta files
containing empty strings "" in the data. I
2012 Jul 18
2
Letor: Post Mid-Term plan
Hello Rishabh,
As per our previous discussion, we will talk each week now about the
project. Please update the timeline/todo/journal accordingly so that we can
check the status on this saturday for this week.
Please remember that this half of the programme is smaller and hence we
would need to be very punctual about the goals.
Regards,
Parth.
-------------- next part --------------
An HTML
2012 Jul 12
2
Mid-term progress
Hi Rishabh,
As per our last progress meeting, I am off for some days and as now its the
time to mid-term evaluation, it would be better to generate a progress
report.
For that, you should first commit the code as it is and then write 2 to 3
page summary explaining the deliverables so far and then the future plan.
Tomorrow is the last day, so better by tomorrow morning, send this across
and by
2018 May 11
3
add one variable to a data frame
Hi Sarah,
Thank you so much!! I got your good ideas.
Ding
-----Original Message-----
From: Sarah Goslee [mailto:sarah.goslee at gmail.com]
Sent: Friday, May 11, 2018 11:40 AM
To: Ding, Yuan Chun
Cc: r-help mailing list
Subject: Re: [R] add one variable to a data frame
[Attention: This email came from an external source. Do not open attachments or click on links from unknown senders or
2018 May 11
0
add one variable to a data frame
Sarah's solutions are good, and here's another, even more basic:
tmp1 <- unique(dat1$B)
tmp2 <- seq_along(tmp1)
dat1$C <- tmp2[ match( dat1$B, tmp1) ]
> dat1
N B C
1 1 29_log 1
2 2 29_log 1
3 3 29_log 1
4 4 27_cat 2
5 5 27_cat 2
6 6 1_log 3
7 7 1_log 3
8 8 1_log 3
9 9 1_log 3
10 10 1_log 3
11 11 3_cat 4
12 12 3_cat 4
As a single line
2018 May 11
3
add one variable to a data frame
Hi All,
I have a data frame dat1:
dat1 <-data.frame(N=seq(1, 12,1), B=c("29_log","29_log", "29_log", "27_cat", "27_cat",
"1_log", "1_log", "1_log", "1_log", "1_log",
2013 May 07
4
create unique ID for each group
Hey All,
I have a dataset(dat1) like this:
ObsNumber ID Weight
1 0001 12
2 0001 13
3 0001 14
4 0002 16
5 0002 17
And another dataset(dat2) like this:
ID Height
0001 3.2
0001 2.6
0001
2013 Sep 21
1
Translating recoding syntax from SPSS to R
Colleagues,
I am in the process of learning R. I've been able to import my dataset (from Stata) and do some simple coding. I have now come to coding situation that requires some assistance. This is some code in SPSS that I would like to be able to execute in R:
if (race eq 1 and usborn=0) confused=1 .
if (race eq 2 and usborn=0) confused=1 .
if (race eq 1 and usborn=1) confused=0 .
if (race
2010 Mar 30
2
Need help to split a given matrix is a "sequential" way
I need to split a given matrix in a sequential order. Let my matrix is :
> dat <- cbind(sample(c(100,200), 10, T), sample(c(50,100, 150, 180), 10,
> T), sample(seq(20, 200, by=20), 10, T)); dat
[,1] [,2] [,3]
[1,] 200 100 80
[2,] 100 180 80
[3,] 200 150 180
[4,] 200 50 140
[5,] 100 150 60
[6,] 100 50 60
[7,] 100 100 100
[8,] 200 150 100
[9,]
2013 Jan 08
2
plot residuals per factor
Dear R-users,
I want to plot residuals vs fitted for multiple groups with ggplot2.
I try this code, but unsuccessful.
library("plyr")
models<-dlply(dat1,"d",function(df)
mod<-lm(y~x,data=df)
ggplot(models,aes(.fitted,.resid), color=factor(d))+
geom_hline(yintercept=0,col="white",size=2)+
geom_point()+
geom_smooth(se=F)
--
---
Catalin-Constantin ROIBU
2013 Apr 29
4
expanding a presence only dataset into presence/absence
Hello,
I'm working with a very large dataset (250,000+ lines in its' current form)
that includes presence only data on various species (which is nested within
different sites and sampling dates). I need to convert this into a dataset
with presence/absence for each species. For example, I would like to expand
"My current data" to "Desired data":
My current data
2008 Mar 25
2
Compare two data sets
I would like to compare two data sets saved as text files (example below) to determine if both sets are identical(or if dat2 is missing information that is included in dat1) and if they are not identical list what information is different between the two sets(ie output "a1", "a3" as the differing information). The overall purpose would be to remove "a1" and
2013 Jan 09
4
select partial name and full name columns
Hi, I have the following function:
getDataFromDVFileCustom <- function (file, hasHeader = TRUE, separator =
"\t")
{
DVdatatmp <- as.matrix(read.table(file, sep = "\t", fill = TRUE,
comment.char = "#", as.is = TRUE, stringsAsFactors = FALSE, na.strings =
"NA"))
DVdatatmper <- as.matrix(DVdatatmp[ , c("datetime",
2018 May 11
0
add one variable to a data frame
Hi,
Here's one way to approach it, using the coercion of factor to numeric.
Note that I changed your data.frame() statement to avoid coercing
strings to factors, just to make it simpler to set the levels.
dat1 <-data.frame(N=seq(1, 12,1), B=c("29_log","29_log", "29_log",
"27_cat", "27_cat", "1_log", "1_log",