Displaying 20 results from an estimated 29 matches for "tdat".
Did you mean:
dat
2017 Dec 13
3
match and new columns
Hi all,
I have a data frame
tdat <- read.table(textConnection("A B C Y
A12 B03 C04 0.70
A23 B05 C06 0.05
A14 B06 C07 1.20
A25 A23 A12 3.51
A16 A25 A14 2,16"),header = TRUE)
I want match tdat$B with tdat$A and populate the column values of tdat$A
( col A and Col B) in the newly created columns (col D and col E)....
2017 Dec 13
2
match and new columns
...output from your script
A B C Y D E
1 A12 B03 C04 0.70 0 0
2 A23 B05 C06 0.05 0 0
3 A14 B06 C07 1.20 0 0
4 A25 A23 A12 3.51 1 1
5 A16 A25 A14 2,16 4 4
On Wed, Dec 13, 2017 at 4:36 PM, Rui Barradas <ruipbarradas at sapo.pt> wrote:
> Hello,
>
> Here is one way.
>
> tdat$D <- ifelse(tdat$B %in% tdat$A, tdat$A[tdat$B], 0)
> tdat$E <- ifelse(tdat$B %in% tdat$A, tdat$A[tdat$C], 0)
>
>
> Hope this helps,
>
> Rui Barradas
>
>
> On 12/13/2017 9:36 PM, Val wrote:
>
>> Hi all,
>>
>> I have a data frame
>> tdat <...
2017 Dec 14
1
match and new columns
Hi Bill,
I put stringsAsFactors = FALSE
still did not work.
tdat <- read.table(textConnection("A B C Y
A12 B03 C04 0.70
A23 B05 C06 0.05
A14 B06 C07 1.20
A25 A23 A12 3.51
A16 A25 A14 2,16"),header = TRUE ,stringsAsFactors = FALSE)
tdat$D <- 0
tdat$E <- 0
tdat$D <- (ifelse(tdat$B %in% tdat$A, tdat$A[tdat$B], 0))
tdat$E <- (ifelse(tdat$B...
2017 Dec 13
0
match and new columns
Hello,
Here is one way.
tdat$D <- ifelse(tdat$B %in% tdat$A, tdat$A[tdat$B], 0)
tdat$E <- ifelse(tdat$B %in% tdat$A, tdat$A[tdat$C], 0)
Hope this helps,
Rui Barradas
On 12/13/2017 9:36 PM, Val wrote:
> Hi all,
>
> I have a data frame
> tdat <- read.table(textConnection("A B C Y
> A12 B03 C04 0...
2017 Dec 14
0
match and new columns
...0 0
> 2 A23 B05 C06 0.05 0 0
> 3 A14 B06 C07 1.20 0 0
> 4 A25 A23 A12 3.51 1 1
> 5 A16 A25 A14 2,16 4 4
>
>
> On Wed, Dec 13, 2017 at 4:36 PM, Rui Barradas <ruipbarradas at sapo.pt>
> wrote:
>
> > Hello,
> >
> > Here is one way.
> >
> > tdat$D <- ifelse(tdat$B %in% tdat$A, tdat$A[tdat$B], 0)
> > tdat$E <- ifelse(tdat$B %in% tdat$A, tdat$A[tdat$C], 0)
> >
> >
> > Hope this helps,
> >
> > Rui Barradas
> >
> >
> > On 12/13/2017 9:36 PM, Val wrote:
> >
> >> Hi all,...
2007 Dec 06
5
Help rewriting looping structure?
...ey Folks,
Could somebody help me rewrite the following code?
I am looping through all records across 5 fields to calculate the cumulative
percentage of each record (relative to each individual field).
Is there a way to rewrite it so I don't have to loop through each individual
record?
##### tdat is my data frame
##### j is my field index
##### k is my record index
##### tsum is the sum of all values in field j
##### tmp is a vector containing the values in field j
##### tdat[k,paste("cpct,j,sep="")] creates new fields "cpct1",...,"cpct5"
for(j in 1:5)...
2018 May 18
3
exclude
Hi All,
I have a sample of data set show as below.
tdat <- read.table(textConnection("stat year Y
AL 2003 25
AL 2003 13
AL 2004 21
AL 2006 20
AL 2007 12
AL 2009 16
AL 2010 15
FL 2006 63
FL 2007 14
FL 2007 25
FL 2009 64
FL 2009 47
FL 2010 48
NY 2003 50
NY 2004 51
NY 2006 57
NY 2007 62
NY 2007...
2018 May 18
0
exclude
... and similar to Jim's suggestion but perhaps slightly simpler (or not!):
> cross <- xtabs( Y ~ stat + year, data = tdat)
> keep <- apply(cross, 1, all)
> keep <- names(keep)[keep]
> cross[keep,]
year
stat 2003 2004 2006 2007 2009 2010
AL 38 21 20 12 16 15
NY 50 51 57 98 183 230
> ## for counts just do:
> xtabs( ~ stat + year, data = tdat[tdat$stat %in% keep, ])...
2018 May 18
1
exclude
...AL 2 1 1
NY 1 1 2
Thank you again.
On Thu, May 17, 2018 at 8:48 PM, Bert Gunter <bgunter.4567 at gmail.com> wrote:
> ... and similar to Jim's suggestion but perhaps slightly simpler (or not!):
>
> > cross <- xtabs( Y ~ stat + year, data = tdat)
> > keep <- apply(cross, 1, all)
> > keep <- names(keep)[keep]
> > cross[keep,]
> year
> stat 2003 2004 2006 2007 2009 2010
> AL 38 21 20 12 16 15
> NY 50 51 57 98 183 230
>
>
>
> > ## for counts just do:
> > xt...
2010 Nov 01
2
transforming a dataset for association analysis RESHAPE2
I get the following message when using the reshape2 package line
> tDat.m<- melt(Dataset)
Using Item, Subject as id variables
> tDatCast<- acast(tDat.m,Subject~Item)
Aggregation function missing: defaulting to length
Note Problem Statement-
convert dataframe
Subject Item Score
1 Subject 1 Item 1 1
2 Subject 1 Item 2 0
3 Subject 1 Item 3 1
4...
2012 Apr 20
1
Ternaryplot as an inset graph
...but It doesn't seem to work for this particular
function. It overlays the old plot rather than plotting as an inset.
Here is a simple version of what I'm trying. Note that if I change the
inset plot to be an ordinary scatter, for instance, it works as
expected.
library(ade4)
library(vcd)
tdat <- data.frame(x=runif(20), y=rlnorm(20), z=rlnorm(20))
insetPlot <- function(data){
ternaryplot(data)
}
ternaryplot(tdat)
add.scatter(insetPlot(tdat), posi="topleft", ratio=.2)
Thanks very much,
Jennifer Young
Fisheries and Oceans Canada
Jennifer.Young@dfo-mpo.gc.ca
[[alterna...
2016 Apr 22
1
npudens(np) Error missing value where TRUE/FALSE needed
...concerning the npudens function
in the np package.
I am trying to find a kernel density function of a
multivariate dataset and the density evaluated at each of the 176 points.
I have 2 continuous and 3 ordered discrete variables. My
sample size is 176.
So edata is a 176x(2+3) data frame, while tdat is a 1x(2+3)
vector.
bw_cx[i,] is a 1x (2+3) vector representing the bandwidths h for each variable, which were calculated using the npcdensbw function. (no this is not a mistake, I deliberately use the conditional one)
For this I use the below function in R.
kerz <-
npudens(bws=(bw_cx[i,])...
2004 Sep 21
2
Bootstrap ICC estimate with nested data
...g the bootstrap functions in the
library "bootstrap" to estimate confidence intervals of ICC values
calculated in lme.
In lme, the ICC is calculated as tau/(tau+sigma-squared). So, for instance
the ICC in the following example is 0.116:
> tmod<-lme(CINISMO~1,random=~1|IDGRUP,data=TDAT)
> VarCorr(tmod)
IDGRUP = pdLogChol(1)
Variance StdDev
(Intercept) 0.1829931 0.427777
Residual 1.3907732 1.179310
> 0.18299/(0.18299+1.39077)
[1] 0.1162757
Using the bootstrap library, I can set up theta to do the ICC as follows:
>theta<-function(x,DATA){tmod<-lm...
2007 Aug 11
1
xyplot() with segments() superposed?
...ode came from a solution given by Deepayan Sarkar.
-------------------
library(lattice)
set.seed(12345)
x <- 0:20
y.male.obs <- - 1.2 * x + 22 + rnorm(length(x), sd = 3)
y.male.prd <- - 1.2 * x + 22
y.fema.obs <- - 2.2 * x + 30 + rnorm(length(x), sd = 2)
y.fema.prd <- - 2.2 * x + 30
tdat <- data.frame(x = rep(x, 8),
y = rep(c(y.male.obs, y.male.prd, y.fema.obs, y.fema.prd), 2),
sex = rep(rep(c("m", "f"), each = 2*length(x)), 2),
cohort = rep(c("1970", "1980"), each = 4*length(x)),
source = rep(rep(c("...
2010 Oct 30
2
transforming a dataset for association analysis
Hi
I would like to transform a data frame like
Subject Item Score
Subject 1 Item 1 1
Subject 1 Item 2 0
Subject 1 Item 3 1
Subject 2 Item 1 1
Subject 2 Item 2 1
Subject 2 Item 3 0
....
*to *
Subject Item1 Item2 Item3 .....Item N
Subject1 1 0 1
Subject2 1 1 0
........
SubjectP..
Apologize for the simple nature of my query but I am stuck.
2009 Jan 22
1
Problem with cex=0.1 when making jpegs
I am using the following script to make .jpg files.
jpeg('plotx.jpg')
ddat <-read.table("file",header=T)
attach(ddat)
tdat<-read.table("file1")
plot(xx1,yy1,type='p',pch=1,col="blue",cex=0.2,xlim=c(0,3.5),ylim=c(-75,75))
points(tdat,col="green",pch=1,cex=0.2)
dev.off()
The problem is that I want the points to be very small; however, if I make
cex any smaller than 0.2 the plot...
2007 Jun 26
1
Subscripting specified variables in a function
I'm trying to create a function which will allow me to subset a data set
based on values of various specified variables. I also want to then
apply some other function(s) (e.g., summary).
This is what I've tried so far....
> test.fx <- function(dta, expvar, expval) {
+ newdta <- subset(dta, eval(expvar)>expval)
+ summary(newdta$eval(expvar))
+ }
>
>
2008 Oct 11
1
problem with cut.Date/date plotting in ggplot2
...splines grid stats graphics grDevices utils datasets
[8] methods base
other attached packages:
[1] ggplot2_0.7 MASS_7.2-44 RColorBrewer_1.0-2 proto_0.3-8
[5] reshape_0.8.1 plyr_0.1
Here's the context in which I encountered the problem:
library(ggplot2)
tdat <- data.frame(date=seq.Date(as.Date("2008-07-07"),
as.Date("2008-10-10"),by="day"),
x=1:96)
q2 = qplot(date,x,data=tdat,geom="smooth")
print(q2+geom_point())
I can track the problem down to a call like
floor_date...
2010 Nov 14
1
R package 'np' problems
...g the same results
when I compare the point of interest to samples of which it is not a part
(density estimates that are either extremely small, which is acceptable, or
much greater than one, which doesn't seem right to me). Any thoughts would
be greatly appreciated,
Chris
> fitted(npudens(tdat=training_df[training_cols_select][training_df$cat ==
i,]))
[1] 7.762187e+18 9.385532e+18 6.514318e+18 7.583486e+18 6.283017e+18
[6] 6.167344e+18 9.820551e+18 7.952821e+18 7.882741e+18 1.744266e+19
[11] 6.653258e+18 8.704722e+18 8.631365e+18 1.876052e+19 1.995445e+19
[16] 2.323802e+19 1.203780e+19...
2007 Oct 17
2
nmle: gnls freezes on difficult case
...svn rev 43063
language R
version.string R version 2.6.0 (2007-10-03)
start=c(-1.5, 9.5, 0.09, 10.25)
names(start)<-c("A","B","xmid","scal")
gnls(response~SSllogis(conc,A,B,xmid,scal),tdat,start=start,weights=varPower(),verbose=TRUE)
**Iteration 1
GLS step: Objective: NULLvarStruct parameters:
power
0.3373199
NLS step: RSS = 0
model parameters:-0.799941 8.99983 -0.522623 212.314
iterations: 2
Convergence:
params varStruct
1.172208 1.000000
### After about 1...