From emillfilipov at gmail.com Tue Jun 14 20:34:31 2016
From: emillfilipov at gmail.com (phdmonster)
Date: Tue, 14 Jun 2016 11:34:31 -0700 (PDT)
Subject: [datatable-help] Table function deletes non NA values in R
Message-ID: <1465929271856-4721792.post@n4.nabble.com>
This here bugger worked perfectly until i changed the data set:
for (k in m) {
mos_sub <- subset(work_table_ansfreq, !is.na(work_table_ansfreq[,r]) &
work_table_ansfreq$MOS_GROUP==k & !is.na(work_table_ansfreq$MOS_GROUP))
freq_mos<- table(mos_sub[,r])
qa[,k] <- freq_mos
}
For some reason it removes both NA values (which is normal) and one column
that actually has values. I will demonstrate. Output of the above code is:
I provide care for someone who suffers from
Not applicable Prefer not to answer
4
631 14
Someone in my household suffers from
1
And when i include **exclude = NULL** in the table brackets i get this:
I provide care for someone who suffers from
I suffer from Not applicable
22
6 5258
Prefer not to answer Someone in my
household suffers from
94
13 0
How do i fix this? Meaning how do i exclude only the NA which should be the
only one excluded from the table anyway.
Thanks!
--
View this message in context: http://r.789695.n4.nabble.com/Table-function-deletes-non-NA-values-in-R-tp4721792.html
Sent from the datatable-help mailing list archive at Nabble.com.
From fperickson at wisc.edu Tue Jun 14 21:16:15 2016
From: fperickson at wisc.edu (Frank Erickson)
Date: Tue, 14 Jun 2016 15:16:15 -0400
Subject: [datatable-help] Table function deletes non NA values in R
In-Reply-To: <1465929271856-4721792.post@n4.nabble.com>
References: <1465929271856-4721792.post@n4.nabble.com>
Message-ID:
Hi Emil,
This mailing list is only for the data.table package. Find out about other
lists here: https://www.r-project.org/mail.html
For reference, you probably want to link your SO post
http://stackoverflow.com/q/37819796/1191259
--Frank
On Tue, Jun 14, 2016 at 2:34 PM, phdmonster wrote:
> This here bugger worked perfectly until i changed the data set:
>
> for (k in m) {
> mos_sub <- subset(work_table_ansfreq, !is.na(work_table_ansfreq[,r]) &
> work_table_ansfreq$MOS_GROUP==k & !is.na(work_table_ansfreq$MOS_GROUP))
> freq_mos<- table(mos_sub[,r])
> qa[,k] <- freq_mos
> }
> For some reason it removes both NA values (which is normal) and one column
> that actually has values. I will demonstrate. Output of the above code is:
>
> I provide care for someone who suffers from
> Not applicable Prefer not to answer
> 4
> 631 14
> Someone in my household suffers from
> 1
> And when i include **exclude = NULL** in the table brackets i get this:
>
> I provide care for someone who suffers from
> I suffer from Not applicable
> 22
> 6 5258
> Prefer not to answer Someone in my
> household suffers from
> 94
> 13 0
>
> How do i fix this? Meaning how do i exclude only the NA which should be the
> only one excluded from the table anyway.
> Thanks!
>
>
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Table-function-deletes-non-NA-values-in-R-tp4721792.html
> Sent from the datatable-help mailing list archive at Nabble.com.
> _______________________________________________
> datatable-help mailing list
> datatable-help at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
From vedahung1116 at gmail.com Thu Jun 16 14:30:17 2016
From: vedahung1116 at gmail.com (Veda)
Date: Thu, 16 Jun 2016 05:30:17 -0700 (PDT)
Subject: [datatable-help] recode variable regardless of its order
Message-ID: <1466080217763-4721864.post@n4.nabble.com>
Hello experts,
I have two variables in a data frame, say "varA" and "varB".
varA: a, a, a, b, b, b, c, c, c
varB: a, b, c, a, b, c, a, b, c
What I want to do is to create two new variables like bellow
varA: a, a, a, *a*, b, b, *a*, *b*, c
varB: a, b, c, *b*, b, c, *c*, *c*, c
The point is to ignore whether the element is in varA or varB in the
recoding. I really appreciate any suggestion to achieve this. Thanks!
Veda
--
View this message in context: http://r.789695.n4.nabble.com/recode-variable-regardless-of-its-order-tp4721864.html
Sent from the datatable-help mailing list archive at Nabble.com.
From Cedric.Duprez at ign.fr Thu Jun 16 15:36:47 2016
From: Cedric.Duprez at ign.fr (Cedric Duprez)
Date: Thu, 16 Jun 2016 13:36:47 +0000
Subject: [datatable-help] recode variable regardless of its order
In-Reply-To: <1466080217763-4721864.post@n4.nabble.com>
References: <1466080217763-4721864.post@n4.nabble.com>
Message-ID: <5762AB7A.8060208@ign.fr>
Hi,
Perhaps something like this :
> test <- data.table(varA=c("a", "a", "a", "b", "b", "b", "c", "c",
"c"), varB=c("a", "b", "c", "a", "b", "c", "a", "b", "c"))
> test
varA varB
1: a a
2: a b
3: a c
4: b a
5: b b
6: b c
7: c a
8: c b
9: c c
> test[, `:=`(varA2 = pmin(varA, varB), varB2 = pmax(varA, varB))]
> test
varA varB varA2 varB2
1: a a a a
2: a b a b
3: a c a c
4: b a a b
5: b b b b
6: b c b c
7: c a a c
8: c b b c
9: c c c c
The two new variables (varA2 and varB2) look like what you're waiting
for. Isn't it?
Regards,
Cedric
From fperickson at wisc.edu Thu Jun 16 15:49:32 2016
From: fperickson at wisc.edu (Frank Erickson)
Date: Thu, 16 Jun 2016 09:49:32 -0400
Subject: [datatable-help] recode variable regardless of its order
In-Reply-To: <5762AB7A.8060208@ign.fr>
References: <1466080217763-4721864.post@n4.nabble.com>
<5762AB7A.8060208@ign.fr>
Message-ID:
Another way of doing what Cedric did, if you're willing to overwrite the
original vars:
test[varA > varB, `:=`(VarA = VarB, VarB = VarA)]
On Thu, Jun 16, 2016 at 9:36 AM, Cedric Duprez wrote:
> Hi,
>
> Perhaps something like this :
>
> > test <- data.table(varA=c("a", "a", "a", "b", "b", "b", "c", "c",
> "c"), varB=c("a", "b", "c", "a", "b", "c", "a", "b", "c"))
> > test
> varA varB
> 1: a a
> 2: a b
> 3: a c
> 4: b a
> 5: b b
> 6: b c
> 7: c a
> 8: c b
> 9: c c
> > test[, `:=`(varA2 = pmin(varA, varB), varB2 = pmax(varA, varB))]
> > test
> varA varB varA2 varB2
> 1: a a a a
> 2: a b a b
> 3: a c a c
> 4: b a a b
> 5: b b b b
> 6: b c b c
> 7: c a a c
> 8: c b b c
> 9: c c c c
>
> The two new variables (varA2 and varB2) look like what you're waiting
> for. Isn't it?
>
> Regards,
> Cedric
> _______________________________________________
> datatable-help mailing list
> datatable-help at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
From vedahung1116 at gmail.com Thu Jun 16 15:52:05 2016
From: vedahung1116 at gmail.com (Veda)
Date: Thu, 16 Jun 2016 06:52:05 -0700 (PDT)
Subject: [datatable-help] recode variable regardless of its order
In-Reply-To:
References: <1466080217763-4721864.post@n4.nabble.com>
<5762AB7A.8060208@ign.fr>
Message-ID: <1466085125991-4721870.post@n4.nabble.com>
Thanks to Cedric and Frank for the great suggestions.
The thing is that I cannot use `:=`
What package does this function require?
Thanks!
--
View this message in context: http://r.789695.n4.nabble.com/recode-variable-regardless-of-its-order-tp4721864p4721870.html
Sent from the datatable-help mailing list archive at Nabble.com.
From fperickson at wisc.edu Thu Jun 16 17:54:23 2016
From: fperickson at wisc.edu (Frank Erickson)
Date: Thu, 16 Jun 2016 11:54:23 -0400
Subject: [datatable-help] recode variable regardless of its order
In-Reply-To: <1466085125991-4721870.post@n4.nabble.com>
References: <1466080217763-4721864.post@n4.nabble.com>
<5762AB7A.8060208@ign.fr>
<1466085125991-4721870.post@n4.nabble.com>
Message-ID:
You posted on the mailing list for the data.table package, where that
function comes from. Next time, look for a general R mailing list.
On Thu, Jun 16, 2016 at 9:52 AM, Veda wrote:
> Thanks to Cedric and Frank for the great suggestions.
> The thing is that I cannot use `:=`
> What package does this function require?
> Thanks!
>
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/recode-variable-regardless-of-its-order-tp4721864p4721870.html
> Sent from the datatable-help mailing list archive at Nabble.com.
> _______________________________________________
> datatable-help mailing list
> datatable-help at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
From slam-norilsk at mail.ru Tue Jun 21 20:33:05 2016
From: slam-norilsk at mail.ru (sermal)
Date: Tue, 21 Jun 2016 11:33:05 -0700 (PDT)
Subject: [datatable-help] Predict the next state via RHmm package
Message-ID: <1466533985672-4722029.post@n4.nabble.com>
Hi.
How can I predict next state of HMM with discrete distribution? I'm using
RHmm package for this.
--
View this message in context: http://r.789695.n4.nabble.com/Predict-the-next-state-via-RHmm-package-tp4722029.html
Sent from the datatable-help mailing list archive at Nabble.com.
From rana_dandis at yahoo.com Tue Jun 28 12:24:08 2016
From: rana_dandis at yahoo.com (Dandis)
Date: Tue, 28 Jun 2016 03:24:08 -0700 (PDT)
Subject: [datatable-help] Forward Recursive method
Message-ID: <1467109448799-4722233.post@n4.nabble.com>
Hello guys,
I am trying to compute the likelihood for a hidden Markov chain problem
using the forward recursive process, described in the attached pdf,
LikelihoodComputation.pdf
My goal is to find the parameters beta and mu that will maximize the above
likelihood using R software and the following transition and emission
matrices
n=3
h=0.1
x=matrix(data=NA, nrow=n+1, ncol=n+1) # x is the transition matrix
for(i in 0:n){
for(j in 0:n){
if(i==j){ x[i+1,j+1] = 1-beta*j*(n-j)*h-mu*j*h}
else{
if(j==i+1){x[i+1,j+1] = beta*j*(n-j)*h}
else{
if(j==i-1){ x[i+1,j+1] = j*mu*h}
else{x[i+1,j+1] =0}
}}}}
x
E=matrix(data=NA, nrow=n+1, ncol=n+1) # the emission matrix
for(i in 0:n){
for(j in 0:n){
E[i+1,j+1]=dbinom(j, size=i, prob=0.59) }}
E
Can you please help me to program this using R , or just give me a hint how
to start!
Thanks in advance,
Dandis
--
View this message in context: http://r.789695.n4.nabble.com/Forward-Recursive-method-tp4722233.html
Sent from the datatable-help mailing list archive at Nabble.com.
From swright7 at uga.edu Wed Jun 29 15:18:02 2016
From: swright7 at uga.edu (swright71234)
Date: Wed, 29 Jun 2016 06:18:02 -0700 (PDT)
Subject: [datatable-help] Create a new window
Message-ID: <1467206282642-4722299.post@n4.nabble.com>
Hello all,
I am trying to perform image analysis with the following code. The code
works fine and is not the issue here. I would like for the completed images
to pop-up in a new and bigger when each image goes through the analysis.
Does anyone have any suggestions?
par(mfrow=c(2,1))
for (i in 1: length(my_files))
{
img <- brick(my_files[i])
#crop the photo using previously defined parameters
#my_img2 <- crop(img, my_extent)
my_img2<-img
#change band names(to make it easier to code)
names(my_img2) <- c("b1", "b2", "b3")
#remove the trend from the flash for each band ----------------------
#define coordinates from the image
x <- coordinates(my_img2)[,1]
y <- coordinates(my_img2)[,2]
#Regression for each layer, removing the polynomial trend
#band1
reg <- lm(my_img2$b1[] ~ x+ y+I(x^2)+I(y^2) )
b <- coefficients(reg)
my_img2$pred <- b[1] + b[2] * x+ b[3]* y+ b[4]*x^2+b[5]*y^2
my_img2$b1 <- my_img2$b1[] - my_img2$pred[]
#band2
reg <- lm(my_img2$b2[] ~ x+ y+I(x^2)+I(y^2) )
b <- coefficients(reg)
my_img2$pred <- b[1] + b[2] * x+ b[3]* y+ b[4]*x^2+b[5]*y^2
my_img2$b2 <- my_img2$b2[] - my_img2$pred[]
#band3
reg <- lm(my_img2$b3[] ~ x+ y+I(x^2)+I(y^2) )
b <- coefficients(reg)
my_img2$pred <- b[1] + b[2] * x+ b[3]* y+ b[4]*x^2+b[5]*y^2
my_img2$b3 <- my_img2$b3[] - my_img2$pred[]
#
my_img2 <-dropLayer(my_img2, "pred")
my_img2 <- improve_contrast(my_img2)
#
#Plot 2 images so user can see the original plus the added
#The aspect is changed to make it easier to click on the knots
par(mfrow=c(2,1))
plotRGB(my_img2,asp=3)
plotRGB(my_img2,asp=3)
print("Input 0 and hit Enter for no knots or Enter if knots")
numberknots <- readline(paste("Knots for ", my_files[i],": ", sep=' '))
#If knotsforeachpiece = 0 we can skip labeling the knots
if(numberknots==0){
#Add to dataframe that the piece didn't have any knots
lknots <- data.frame(board = my_files[i], x = NA, y = NA,area=NA)
lknots <- as.data.frame(lknots)
my_knots <- rbind(my_knots, lknots)
name<-my_files[i]
name<-gsub(".tif","",name)
#Write the images
#image(my_img2)
#my_img2
#png(paste(name,"_Knots", ".png", sep=''))
#par(mfrow=c(1,1))
#plotRGB(my_img2)
#plot(my_img2.poly, add = TRUE, col = "red", border ="red")
#dev.off()
#Copy file when done
#file.copy(my_files[i], "Complete")
}
else {
#Identify clusters
my_img2.mtrx <- as.matrix(my_img2)
clusters <- kmeans(my_img2.mtrx, centers=7)
my_img2$cl2 <- fitted(clusters)[,1]
my_img2$cl <- clusters$cluster
mV <- minValue(my_img2$cl2)
#pknots will be identified when cluster is equal to minimum value,
otherwise not a knot
my_img2$pknots <- ifelse(my_img2$cl2[] == mV,1,NA)
my_img2.poly <- rasterToPolygons(my_img2$pknots, dissolve = TRUE)
my_img2.poly <- disaggregate(my_img2.poly)
my_img2.poly$area <- sapply(slot(my_img2.poly, "polygons"), slot,
"area")
plot(my_img2.poly, add = TRUE, col = "red", border ="red")
#Joe Add
#Did Algorithm correctly identify all the knots?
#The identification of other stuff is not important since user will
identify the correct ones
print("Input 0 & Enter if not all knots were identified")
print("It does not matter if other stuff was identified but all knots
must be identified")
print("Hit enter if all knots were identified")
knotscorrect <- readline(paste("Knots Correct for ", my_files[i],": ",
sep=' '))
#If knotsforeachpiece = 0 we can skip labeling the knots
if(knotscorrect==0){
#Copy file when done
file.copy(my_files[i], "Incomplete")
}
else {
#Start locator for knots
print("Select knots with mouse and when finished hit esc")
my_points <- locator(type ="p", pch ="x")
my_pointsXY <- rasterToPoints(my_img2$pknots)
#The following code line doesn't work but was included in the code you
sent me
#my_points2 <- identify.map(my_pointsXY[,1], my_pointsXY[,2])
lknots <- data.frame(board = my_files[i], x = my_points$x, y =
my_points$y)
#This isn't used for anything ???
coordinates(lknots) <- ~x+y
#problem when more points than identified (either algorithm doesn't
identify
#Or user clicks outside knot (easy to do on small knots)
my_img2.poly$isKnot <- as.vector(over(my_img2.poly, lknots)[,1])
my_img2.poly <- subset(my_img2.poly, !is.na(my_img2.poly$isKnot))
lknots <- as.data.frame(lknots)
lknots$area <- my_img2.poly$area
#I would like to save the image with the ID'ed knots but this doesn't
work well due to the white space
name<-my_files[i]
name<-gsub(".tif","",name)
#Save raster picture with knots identified
png(paste(name,"_Knots", ".png", sep=''),width = 6000, height = 6000)
par(mfrow=c(1,1))
plotRGB(my_img2)
plot(my_img2.poly, add = TRUE, col = "red", border ="red")
dev.off()
#rbind dataframe
my_knots <- rbind(my_knots, lknots)
#Copy file when done
#file.copy(my_files[i], "Complete")
}
}
}
I would really appreciate any help!
--
View this message in context: http://r.789695.n4.nabble.com/Create-a-new-window-tp4722299.html
Sent from the datatable-help mailing list archive at Nabble.com.