Re: [R] mgcv : 3-way interaction and 3D-plots ?

2019-01-07 Thread Richard M. Heiberger
## Here is an example using the 3-way interaction plot from the HH package


install.packages("HH") ## if necessary

## The HH package supports the book
## Statistical Analysis and Data Display
##Richard M. Heiberger and Burt Holland
## http://www.springer.com/us/book/9781493921218

library(HH)
## find the pathname of the R script file dsgn.R containing this example
HHscriptnames(13)
## open the file dsgn.R in your favorite editor.


## Then run

## chunk 2,
## chunk 3, Figure 13.1
## chunk 4  Table 13.1
## chunk 7  Figure 13.3  three-way interactions

## Rows of the array of panels are  current
## Columns of the array of panels are   n.treats
## differently colored boxes within each panel are  minutes
##
## In this example the 3-way interaction is not significant.
## For a hint of what one could see, compare the panel "60.cycle x 3"
## with "60.cycle x 6".  In "60.cycle x 3", the red box at minutes=5 is
## higher than the other three boxes.  In "60.cycle x 6", the red box at
## minutes=5 is lower than the other boxes.


## Illustrate a minimalist form of this call.
## Create a dataset with simple variable names Y, A, B, C
mydata <- data.frame(Y=cc176$y.adj,
 A=unpositioned(cc176$minutes),
 B=cc176$n.treats,
 C=cc176$current)

## A is an ordinary factor, minutes is a positioned factor, see
?HH::position
## We use xyplot() here, not bwplot(), because bwplot() doesn't handle
"positioned" factors.

## The minimalist form of this call is
useOuterStrips(
xyplot(Y ~ A | B + C, data=mydata,
   groups=A,
   panel=panel.bwplot.superpose, ## take control of colors of the boxes
   horizontal=FALSE,
   between=list(x=1, y=1))
)


On Mon, Jan 7, 2019 at 7:59 PM David Winsemius 
wrote:

>
> On 1/7/19 3:35 PM, varin sacha via R-help wrote:
> > Dear R-experts,
> >
> > I have fitted a model with 2-way and 3-way interactions.
> > I would like, for the 3-way interaction (year,age,by=education), to
> obtain 3D-plots. How could I do that ?
>
> Forget ggplot2. It has ignored this sort of visualization effort. Use
> lattice or base plotting methods.
>
>
> In order to plot a 2way interaction one needs a pseudo-3way plot
> (`wireframe`) or a single `levelplot`. For display of a 3way interaction
> in lattice (given the human minds inability to "see" in 4 dimensions)
> you will need to specify levels for one of the variables to display
> slices perhaps using multiple displays of 2way "sub-interactions"
> calculated ad meaningul levels of the variable you choose to slive
> with.  I'm not sure what the "native" plotting method for pkg:mgcv might
> be. I suspect it was base graphics,; if so, look at ?persp and ?contour.
>
> --
>
> David
>
> >
> > Many thanks for your response.
> >
> > Here is the reproducible example:
> >
> > #
> > install.packages("ISLR")
> >
> > library(ISLR)
> >
> > install.packages("mgcv")
> >
> > library(mgcv)
> >
> > mod1<-gam(wage
> ~education+s(age,bs="ps")+year+te(age,year,bs="ps")+s(year,bs="ps",by=education,m=1)+te(year,age,by=education,bs=rep("ps",2)),data=Wage)
> >
> > plot(mod1)
> > #
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] mgcv : 3-way interaction and 3D-plots ?

2019-01-07 Thread David Winsemius



On 1/7/19 3:35 PM, varin sacha via R-help wrote:

Dear R-experts,

I have fitted a model with 2-way and 3-way interactions.
I would like, for the 3-way interaction (year,age,by=education), to obtain 
3D-plots. How could I do that ?


Forget ggplot2. It has ignored this sort of visualization effort. Use 
lattice or base plotting methods.



In order to plot a 2way interaction one needs a pseudo-3way plot 
(`wireframe`) or a single `levelplot`. For display of a 3way interaction 
in lattice (given the human minds inability to "see" in 4 dimensions) 
you will need to specify levels for one of the variables to display 
slices perhaps using multiple displays of 2way "sub-interactions" 
calculated ad meaningul levels of the variable you choose to slive 
with.  I'm not sure what the "native" plotting method for pkg:mgcv might 
be. I suspect it was base graphics,; if so, look at ?persp and ?contour.


--

David



Many thanks for your response.

Here is the reproducible example:

#
install.packages("ISLR")

library(ISLR)

install.packages("mgcv")

library(mgcv)

mod1<-gam(wage 
~education+s(age,bs="ps")+year+te(age,year,bs="ps")+s(year,bs="ps",by=education,m=1)+te(year,age,by=education,bs=rep("ps",2)),data=Wage)

plot(mod1)
#

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] mgcv : 3-way interaction and 3D-plots ?

2019-01-07 Thread varin sacha via R-help
Dear R-experts,

I have fitted a model with 2-way and 3-way interactions. 
I would like, for the 3-way interaction (year,age,by=education), to obtain 
3D-plots. How could I do that ?

Many thanks for your response.

Here is the reproducible example:

# 
install.packages("ISLR")

library(ISLR)

install.packages("mgcv")

library(mgcv)

mod1<-gam(wage 
~education+s(age,bs="ps")+year+te(age,year,bs="ps")+s(year,bs="ps",by=education,m=1)+te(year,age,by=education,bs=rep("ps",2)),data=Wage)

plot(mod1)
#

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Fit CMARS with R possible (Packages) ?

2019-01-07 Thread varin sacha via R-help
Dear Bert, Dear Marc,

Many thanks for your feedbacks.

Best,






Le samedi 5 janvier 2019 à 00:26:47 UTC+1, Marc Schwartz  
a écrit : 





Hi,

Like Bert, I was not able to find anything built in R.

It is possible that CMARS has not yet been implemented in R, or may be in 
development but not yet ready for release.

I found several references to the use of MOSEK (https://www.mosek.com) along 
with MATLAB, but both are commercial products.

The MOSEK developers appear to have an Rmosek interface package:

  https://docs.mosek.com/8.1/rmosek/index.html

which provides access to the MOSEK functionality via R. But, it requires 
MOSEK...

Perhaps others with more refined knowledge will jump in. It might also be 
reasonable to consider contacting what appears to be a small-ish group of 
common authors that I came across in the search who have described the 
methodology (e.g. Taylan or Yerlikaya-Özkurt) to see if they are aware of any R 
implementations.

Regards,

Marc Schwartz


> On Jan 4, 2019, at 5:16 PM, Bert Gunter  wrote:
> 
> rseek.org might be a better place to search if you haven't tried t
> herealready. However, my minimal effort there did not turn up any R
> software.  Maybe you can do better.
> 
> -- Bert
> 
> Bert Gunter
> 
> "The trouble with having an open mind is that people keep coming along and
> sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
> 
> 
> On Fri, Jan 4, 2019 at 11:31 AM varin sacha via R-help 
> wrote:
> 
>> Dear R-experts,
>> 
>> We can fit MARS regression using the packages "earth" and/or "mda" or
>> others packages.
>> However, I am wondering if it is possible to fit a CMARS (Conic
>> multivariate adaptive regression splines) using R ?
>> I have googled "conic MARS with R software", I did not get anything, so
>> Google is not my friend anymore !
>> 
>> If you have any solution, would be highly appreciated.
>> 
>> Best,

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] error in plotting model from kernlab

2019-01-07 Thread Luigi Marongiu
Sorry but I don't understand the questions. I sent this question to
R-help, not to an individual. I will use the REPLY TO ALL function
when replying, apologies if I missed before. The question is related
to an R package so I placed to the R community.

On Mon, Jan 7, 2019 at 5:47 PM Jeff Newmiller  wrote:
>
> a) When re-posting a question, whether on the same or different forums, it is 
> best practice (netiquette) to link to or reply to the earlier question. [1]
>
> b) Note the guidance in the Posting Guide:
>
> For questions about functions in standard packages distributed with R (see 
> the FAQ Add-on packages in R), ask questions on R-help.
> If the question relates to a contributed package , e.g., one downloaded from 
> CRAN, try contacting the package maintainer first. You can also use 
> find("functionname") and packageDescription("packagename") to find this 
> information. Only send such questions to R-help or R-devel if you get no 
> reply or need further assistance. This applies to both requests for help and 
> to bug reports.
>
> You have not communicated whether you have followed this recommendation.
>
> [1] https://stat.ethz.ch/pipermail/r-help/2018-December/461010.html
>
> On January 7, 2019 4:26:20 AM PST, Luigi Marongiu  
> wrote:
> >Dear all,
> >I have a set of data in this form:
> >> str 
> >'data.frame': 1574 obs. of  14 variables:
> >$ serial: int  12751 14157 7226 15663 11088 10464 1003 10427 11934 3999
> >...
> > $ plate : int  43 46 22 50 38 37 3 37 41 11 ...
> > $ well  : int  79 333 314 303 336 96 235 59 30 159 ...
> > $ sample: int  266 295 151 327 231 218 21 218 249 84 ...
> > $ target: chr  "HEV 2-AI5IQWR" "Dientamoeba fragilis-AIHSPMK" "Astro
> >2 Liu-AI20UKB" "C difficile GDH-AIS086J" ...
> > $ ori.ct: num  0 33.5 0 0 0 ...
> > $ ct.out: int  0 1 0 0 0 0 0 1 0 0 ...
> >$ mr: num  -0.002 0.109 0.002 0 0.001 0.006 0.015 0.119 0.003 0.004
> >...
> > $ fcn   : num  44.54 36.74 6.78 43.09 44.87 ...
> > $ mr.out: int  0 1 0 0 0 0 0 1 0 0 ...
> > $ oper.a: int  0 1 0 0 0 0 0 1 0 0 ...
> > $ oper.b: int  0 1 0 0 0 0 0 1 0 0 ...
> > $ oper.c: int  0 1 0 0 0 0 0 1 0 0 ...
> > $ cons  : int  0 1 0 0 0 0 0 1 0 0 ...
> >from which I have selected two numerical variables correspondig to x
> >and y in a Cartesian plane and one outcome variable (z):
> >> df = subset(t.data, select = c(mr, fcn, cons))
> >>  df$cons = factor(c("negative", "positive"))
> >> head(df)
> >  mr   fcn cons
> >1 -0.002 44.54 negative
> >2  0.109 36.74 positive
> >3  0.002  6.78 negative
> >4  0.000 43.09 positive
> >5  0.001 44.87 negative
> >6  0.006  2.82 positive
> >
> >I created an SVM the method with the KERNLAB package with:
> >> mod = ksvm(cons ~ mr+fcn, # i prefer it to the more canonical "." but
> >the outcome is the same
> >data = df,
> >type = "C-bsvc",
> >kernel = "rbfdot",
> >kpar = "automatic",
> >C = 10,
> >prob.model = TRUE)
> >
> >> mod
> >Support Vector Machine object of class "ksvm"
> >
> >SV type: C-bsvc  (classification)
> > parameter : cost C = 10
> >
> >Gaussian Radial Basis kernel function.
> > Hyperparameter : sigma =  42.0923201429106
> >
> >Number of Support Vectors : 1439
> >
> >Objective Function Value : -12873.45
> >Training error : 0.39263
> >Probability model included.
> >
> >First of all, I am not sure if the model worked because 1439 support
> >vectors out of 1574 data points means that over 90% of the data is
> >required to fix the hyperplane. this does not look like a model but a
> >patch. Secondly, the prediction is rubbish -- but this is another
> >story -- and when I try to create a confusion table of the processed
> >data I get:
> >>  pred = predict(mod, df, type = "probabilities")
> >>  acc = table(pred, df$cons)
> >Error in table(pred, df$cons) : all arguments must have the same length
> >which again is weird since mod, df and df$cons are made from the same
> >dataframe.
> >
> >Coming to the actual error, I tried to plot the model with:
> >> plot(mod, data = df)
> >> kernlab::plot(mod, data = df)
> >but I get this error:
> >
> >Error in .local(x, ...) :
> >  Only plots of classification ksvm objects supported
> >
> >Would you know what I am missing?
> >Thank you
>
> --
> Sent from my phone. Please excuse my brevity.



-- 
Best regards,
Luigi

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Merge the data from multiple text files

2019-01-07 Thread David L Carlson
Thank you. I couldn't have said it better myself. It would probably be simpler 
if you process the lines first to remove duplicates and break compound 
statements into simple statements. Even then it will be a challenge to not end 
up with statements that are internally contradictory, e.g. (A and B) and not(B).

David C

-Original Message-
From: Jeff Newmiller [mailto:jdnew...@dcn.davis.ca.us] 
Sent: Monday, January 7, 2019 11:04 AM
To: Priya Arasu ; Priya Arasu via R-help 
; David L Carlson ; David Winsemius 
; r-help@r-project.org
Subject: Re: [R] Merge the data from multiple text files

I think it is rather presumptuous of you to think that anyone is going to write 
an expression optimizer for some unspecified language on the R-help mailing 
list. I am sure that such tasks can be handled in R, but it is non-trivial and 
the background needed would be very off-topic here.

On January 7, 2019 4:49:04 AM PST, Priya Arasu via R-help 
 wrote:
>Thank you David Winsemius and David L Carlson. 
>@David L Carlson, Thank you for the code. I have one more issue, while
>merging the files. Please advice.For example
>In text file 1:
>A = not(B or C)B = A and CC = D
>In text file 2:
>A = not(C or D) and (D and E)
>
>So when I merge using your code, it merges A = not(B or C) and (D and
>E). How do I merge A as A= not(B or C or D) and (D and E) ?  I also
>have duplicates like A= not(B or C) and not (C or D) instead as A=
>not(B or C or D) ThanksPriya 
>
>On Sunday, 6 January 2019 4:39 AM, David L Carlson 
>wrote:
> 
>
>To expand on David W's answer, here is an approach to your example. If
>you have many text files, you would want to process them together
>rather than individually. You gave us two examples so I'll use those
>and read them from the console using readLines(), but you would use the
>same function to open the files on your computer:
>
>> TF1 <- readLines(n=3)
>A = not(B or C)
>B = A and C
>C = D
>> 
>> TF2 <- readLines(n=2)
>A = D and E
>B = not(D)
>> 
>> TF <- sort(c(TF1, TF2))
>> TF
>[1] "A = D and E"    "A = not(B or C)" "B = A and C"    "B = not(D)"
>[5] "C = D"
>
>Now we have combined the files into a single character vector called TF
>and sorted them. Next we need to parse them into the left and right
>hand sides. We will replace " = " with "\t" (tab) to do that:
>
>> TF.delim <- gsub(" = ", "\t", TF)
>> TF.data <- read.delim(text=TF.delim, header=FALSE, as.is=TRUE)
>> colnames(TF.data) <- c("LHS", "RHS")
>> print(TF.data, right=FALSE)
>  LHS RHS
>1 A  D and E
>2 A  not(B or C)
>3 B  A and C
>4 B  not(D)
>5 C  D
>
>TF.data is a data frame with two columns. The tricky part is to add
>surrounding parentheses to rows 1 and 3 to get your example output:
>
>> paren1 <- grepl("and", TF.data$RHS)
>> paren2 <- !grepl("\\(*\\)", TF.data$RHS)
>> paren <- apply(cbind(paren1, paren2), 1, all)
>> TF.data$RHS[paren] <- paste0("(", TF.data$RHS[paren], ")")
>> print(TF.data, right=FALSE)
>  LHS RHS
>1 A  (D and E)
>2 A  not(B or C)
>3 B  (A and C)
>4 B  not(D)
>5 C  D
>
>The first three lines identify the rows that have the word "and" but do
>not already have parentheses. The fourth line adds the surrounding
>parentheses. Finally we will combine the rows that belong to the same
>LHS value with split and create a list:
>
>> TF.list <- split(TF.data$RHS, TF.data$LHS)
>> TF.list
>$`A`
>[1] "(D and E)"  "not(B or C)"
>
>$B
>[1] "(A and C)" "not(D)"  
>
>$C
>[1] "D"
>
>> TF.and <- lapply(TF.list, paste, collapse=" and ")
>> TF.final <- lapply(names(TF.and), function(x) paste(x, "=",
>TF.and[[x]]))
>> TF.final <- do.call(rbind, TF.final)
>> TF.final
>    [,1]                          
>[1,] "A = (D and E) and not(B or C)"
>[2,] "B = (A and C) and not(D)"
>[3,] "C = D"
>> write(TF.final, file="TF.output.txt")
>
>The text file "TF.output.txt" contains the three lines.
>
>--
>David L. Carlson
>Department of Anthropology
>Texas A University
>
>-Original Message-
>From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of David
>Winsemius
>Sent: Saturday, January 5, 2019 1:12 PM
>
>Subject: Re: [R] Merge the data from multiple text files
>
>
>On 1/5/19 7:28 AM, Priya Arasu via R-help wrote:
>> I have multiple text files, where each file has Boolean rules.
>> Example of my text file 1 and 2
>> Text file 1:
>> A = not(B or C)
>> B = A and C
>> C = D
>> Text file 2:
>> A = D and E
>> B = not(D)
>>
>> I want to merge the contents in text file as follows
>> A = not(B or C) and (D and E)
>> B = not(D) and (A and C)
>> C = D
>> Is there a code in R to merge the data from multiple text files?
>
>
>There is a `merge` function. For this use case you would need to first 
>parse your expressions so that the LHS was in one character column and 
>the RHS was in another character column in each of 2 dataframes. Then 
>merge on the LHS columns and `paste` matching values from the two 
>columns. You will probably need to learn how to use `ifelse` and
>`is.na`.
>
>> Thank you
>> 

Re: [R] Merge the data from multiple text files

2019-01-07 Thread Jeff Newmiller
I think it is rather presumptuous of you to think that anyone is going to write 
an expression optimizer for some unspecified language on the R-help mailing 
list. I am sure that such tasks can be handled in R, but it is non-trivial and 
the background needed would be very off-topic here.

On January 7, 2019 4:49:04 AM PST, Priya Arasu via R-help 
 wrote:
>Thank you David Winsemius and David L Carlson. 
>@David L Carlson, Thank you for the code. I have one more issue, while
>merging the files. Please advice.For example
>In text file 1:
>A = not(B or C)B = A and CC = D
>In text file 2:
>A = not(C or D) and (D and E)
>
>So when I merge using your code, it merges A = not(B or C) and (D and
>E). How do I merge A as A= not(B or C or D) and (D and E) ?  I also
>have duplicates like A= not(B or C) and not (C or D) instead as A=
>not(B or C or D) ThanksPriya 
>
>On Sunday, 6 January 2019 4:39 AM, David L Carlson 
>wrote:
> 
>
>To expand on David W's answer, here is an approach to your example. If
>you have many text files, you would want to process them together
>rather than individually. You gave us two examples so I'll use those
>and read them from the console using readLines(), but you would use the
>same function to open the files on your computer:
>
>> TF1 <- readLines(n=3)
>A = not(B or C)
>B = A and C
>C = D
>> 
>> TF2 <- readLines(n=2)
>A = D and E
>B = not(D)
>> 
>> TF <- sort(c(TF1, TF2))
>> TF
>[1] "A = D and E"    "A = not(B or C)" "B = A and C"    "B = not(D)"
>[5] "C = D"
>
>Now we have combined the files into a single character vector called TF
>and sorted them. Next we need to parse them into the left and right
>hand sides. We will replace " = " with "\t" (tab) to do that:
>
>> TF.delim <- gsub(" = ", "\t", TF)
>> TF.data <- read.delim(text=TF.delim, header=FALSE, as.is=TRUE)
>> colnames(TF.data) <- c("LHS", "RHS")
>> print(TF.data, right=FALSE)
>  LHS RHS
>1 A  D and E
>2 A  not(B or C)
>3 B  A and C
>4 B  not(D)
>5 C  D
>
>TF.data is a data frame with two columns. The tricky part is to add
>surrounding parentheses to rows 1 and 3 to get your example output:
>
>> paren1 <- grepl("and", TF.data$RHS)
>> paren2 <- !grepl("\\(*\\)", TF.data$RHS)
>> paren <- apply(cbind(paren1, paren2), 1, all)
>> TF.data$RHS[paren] <- paste0("(", TF.data$RHS[paren], ")")
>> print(TF.data, right=FALSE)
>  LHS RHS
>1 A  (D and E)
>2 A  not(B or C)
>3 B  (A and C)
>4 B  not(D)
>5 C  D
>
>The first three lines identify the rows that have the word "and" but do
>not already have parentheses. The fourth line adds the surrounding
>parentheses. Finally we will combine the rows that belong to the same
>LHS value with split and create a list:
>
>> TF.list <- split(TF.data$RHS, TF.data$LHS)
>> TF.list
>$`A`
>[1] "(D and E)"  "not(B or C)"
>
>$B
>[1] "(A and C)" "not(D)"  
>
>$C
>[1] "D"
>
>> TF.and <- lapply(TF.list, paste, collapse=" and ")
>> TF.final <- lapply(names(TF.and), function(x) paste(x, "=",
>TF.and[[x]]))
>> TF.final <- do.call(rbind, TF.final)
>> TF.final
>    [,1]                          
>[1,] "A = (D and E) and not(B or C)"
>[2,] "B = (A and C) and not(D)"
>[3,] "C = D"
>> write(TF.final, file="TF.output.txt")
>
>The text file "TF.output.txt" contains the three lines.
>
>--
>David L. Carlson
>Department of Anthropology
>Texas A University
>
>-Original Message-
>From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of David
>Winsemius
>Sent: Saturday, January 5, 2019 1:12 PM
>
>Subject: Re: [R] Merge the data from multiple text files
>
>
>On 1/5/19 7:28 AM, Priya Arasu via R-help wrote:
>> I have multiple text files, where each file has Boolean rules.
>> Example of my text file 1 and 2
>> Text file 1:
>> A = not(B or C)
>> B = A and C
>> C = D
>> Text file 2:
>> A = D and E
>> B = not(D)
>>
>> I want to merge the contents in text file as follows
>> A = not(B or C) and (D and E)
>> B = not(D) and (A and C)
>> C = D
>> Is there a code in R to merge the data from multiple text files?
>
>
>There is a `merge` function. For this use case you would need to first 
>parse your expressions so that the LHS was in one character column and 
>the RHS was in another character column in each of 2 dataframes. Then 
>merge on the LHS columns and `paste` matching values from the two 
>columns. You will probably need to learn how to use `ifelse` and
>`is.na`.
>
>> Thank you
>> Priya
>>
>>     [[alternative HTML version deleted]]
>
>
>You also need to learn that R is a plain text mailing list and that
>each 
>mail client has its own method for building mail in plain text.

-- 
Sent from my phone. Please excuse my brevity.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] error in plotting model from kernlab

2019-01-07 Thread Jeff Newmiller
a) When re-posting a question, whether on the same or different forums, it is 
best practice (netiquette) to link to or reply to the earlier question. [1]

b) Note the guidance in the Posting Guide:

For questions about functions in standard packages distributed with R (see the 
FAQ Add-on packages in R), ask questions on R-help.
If the question relates to a contributed package , e.g., one downloaded from 
CRAN, try contacting the package maintainer first. You can also use 
find("functionname") and packageDescription("packagename") to find this 
information. Only send such questions to R-help or R-devel if you get no reply 
or need further assistance. This applies to both requests for help and to bug 
reports.

You have not communicated whether you have followed this recommendation.

[1] https://stat.ethz.ch/pipermail/r-help/2018-December/461010.html

On January 7, 2019 4:26:20 AM PST, Luigi Marongiu  
wrote:
>Dear all,
>I have a set of data in this form:
>> str 
>'data.frame': 1574 obs. of  14 variables:
>$ serial: int  12751 14157 7226 15663 11088 10464 1003 10427 11934 3999
>...
> $ plate : int  43 46 22 50 38 37 3 37 41 11 ...
> $ well  : int  79 333 314 303 336 96 235 59 30 159 ...
> $ sample: int  266 295 151 327 231 218 21 218 249 84 ...
> $ target: chr  "HEV 2-AI5IQWR" "Dientamoeba fragilis-AIHSPMK" "Astro
>2 Liu-AI20UKB" "C difficile GDH-AIS086J" ...
> $ ori.ct: num  0 33.5 0 0 0 ...
> $ ct.out: int  0 1 0 0 0 0 0 1 0 0 ...
>$ mr: num  -0.002 0.109 0.002 0 0.001 0.006 0.015 0.119 0.003 0.004
>...
> $ fcn   : num  44.54 36.74 6.78 43.09 44.87 ...
> $ mr.out: int  0 1 0 0 0 0 0 1 0 0 ...
> $ oper.a: int  0 1 0 0 0 0 0 1 0 0 ...
> $ oper.b: int  0 1 0 0 0 0 0 1 0 0 ...
> $ oper.c: int  0 1 0 0 0 0 0 1 0 0 ...
> $ cons  : int  0 1 0 0 0 0 0 1 0 0 ...
>from which I have selected two numerical variables correspondig to x
>and y in a Cartesian plane and one outcome variable (z):
>> df = subset(t.data, select = c(mr, fcn, cons))
>>  df$cons = factor(c("negative", "positive"))
>> head(df)
>  mr   fcn cons
>1 -0.002 44.54 negative
>2  0.109 36.74 positive
>3  0.002  6.78 negative
>4  0.000 43.09 positive
>5  0.001 44.87 negative
>6  0.006  2.82 positive
>
>I created an SVM the method with the KERNLAB package with:
>> mod = ksvm(cons ~ mr+fcn, # i prefer it to the more canonical "." but
>the outcome is the same
>data = df,
>type = "C-bsvc",
>kernel = "rbfdot",
>kpar = "automatic",
>C = 10,
>prob.model = TRUE)
>
>> mod
>Support Vector Machine object of class "ksvm"
>
>SV type: C-bsvc  (classification)
> parameter : cost C = 10
>
>Gaussian Radial Basis kernel function.
> Hyperparameter : sigma =  42.0923201429106
>
>Number of Support Vectors : 1439
>
>Objective Function Value : -12873.45
>Training error : 0.39263
>Probability model included.
>
>First of all, I am not sure if the model worked because 1439 support
>vectors out of 1574 data points means that over 90% of the data is
>required to fix the hyperplane. this does not look like a model but a
>patch. Secondly, the prediction is rubbish -- but this is another
>story -- and when I try to create a confusion table of the processed
>data I get:
>>  pred = predict(mod, df, type = "probabilities")
>>  acc = table(pred, df$cons)
>Error in table(pred, df$cons) : all arguments must have the same length
>which again is weird since mod, df and df$cons are made from the same
>dataframe.
>
>Coming to the actual error, I tried to plot the model with:
>> plot(mod, data = df)
>> kernlab::plot(mod, data = df)
>but I get this error:
>
>Error in .local(x, ...) :
>  Only plots of classification ksvm objects supported
>
>Would you know what I am missing?
>Thank you

-- 
Sent from my phone. Please excuse my brevity.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Two statistics courses in Lisbon

2019-01-07 Thread Highland Statistics Ltd

Apologies for cross-posting

We would like to announce the following two statistics course in Lisbon.

Course: Data exploration, regression, GLM & GAM with introduction to R
Where:  Lisbon, Portugal.
When:   18-22 February 2019
Course website: http://highstat.com/index.php/courses-upcoming
Course flyer: 
http://highstat.com/Courses/Flyers/2019/Flyer2019_02Lisbon_RGG.pdf



Course: Introduction to GAM and GAMM with R.
Where:  Lisbon, Portugal.
When:   25 February 2019 - 1 March 2019
Course website: http://highstat.com/index.php/courses-upcoming
Course flyer: 
http://highstat.com/Courses/Flyers/2019/Flyer2019_02Lisbon_GAMM_V3.pdf


Kind regards,


Alain Zuur

--

Dr. Alain F. Zuur
Highland Statistics Ltd.
9 St Clair Wynd
AB41 6DZ Newburgh, UK
Email: highs...@highstat.com
URL:   www.highstat.com

And:
NIOZ Royal Netherlands Institute for Sea Research,
Department of Coastal Systems, and Utrecht University,
P.O. Box 59, 1790 AB Den Burg,
Texel, The Netherlands



Author of:
1. Beginner's Guide to Spatial, Temporal and Spatial-Temporal Ecological Data 
Analysis with R-INLA. (2017).
2. Beginner's Guide to Zero-Inflated Models with R (2016).
3. Beginner's Guide to Data Exploration and Visualisation with R (2015).
4. Beginner's Guide to GAMM with R (2014).
5. Beginner's Guide to GLM and GLMM with R (2013).
6. Beginner's Guide to GAM with R (2012).
7. Zero Inflated Models and GLMM with R (2012).
8. A Beginner's Guide to R (2009).
9. Mixed effects models and extensions in ecology with R (2009).
10. Analysing Ecological Data (2007).

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Merge the data from multiple text files

2019-01-07 Thread Priya Arasu via R-help
Thank you David Winsemius and David L Carlson. 
@David L Carlson, Thank you for the code. I have one more issue, while merging 
the files. Please advice.For example
In text file 1:
A = not(B or C)B = A and CC = D
In text file 2:
A = not(C or D) and (D and E)

So when I merge using your code, it merges A = not(B or C) and (D and E). How 
do I merge A as A= not(B or C or D) and (D and E) ?  I also have duplicates 
like A= not(B or C) and not (C or D) instead as A= not(B or C or D) ThanksPriya 

On Sunday, 6 January 2019 4:39 AM, David L Carlson  
wrote:
 

 To expand on David W's answer, here is an approach to your example. If you 
have many text files, you would want to process them together rather than 
individually. You gave us two examples so I'll use those and read them from the 
console using readLines(), but you would use the same function to open the 
files on your computer:

> TF1 <- readLines(n=3)
A = not(B or C)
B = A and C
C = D
> 
> TF2 <- readLines(n=2)
A = D and E
B = not(D)
> 
> TF <- sort(c(TF1, TF2))
> TF
[1] "A = D and E"    "A = not(B or C)" "B = A and C"    "B = not(D)"
[5] "C = D"

Now we have combined the files into a single character vector called TF and 
sorted them. Next we need to parse them into the left and right hand sides. We 
will replace " = " with "\t" (tab) to do that:

> TF.delim <- gsub(" = ", "\t", TF)
> TF.data <- read.delim(text=TF.delim, header=FALSE, as.is=TRUE)
> colnames(TF.data) <- c("LHS", "RHS")
> print(TF.data, right=FALSE)
  LHS RHS
1 A  D and E
2 A  not(B or C)
3 B  A and C
4 B  not(D)
5 C  D

TF.data is a data frame with two columns. The tricky part is to add surrounding 
parentheses to rows 1 and 3 to get your example output:

> paren1 <- grepl("and", TF.data$RHS)
> paren2 <- !grepl("\\(*\\)", TF.data$RHS)
> paren <- apply(cbind(paren1, paren2), 1, all)
> TF.data$RHS[paren] <- paste0("(", TF.data$RHS[paren], ")")
> print(TF.data, right=FALSE)
  LHS RHS
1 A  (D and E)
2 A  not(B or C)
3 B  (A and C)
4 B  not(D)
5 C  D

The first three lines identify the rows that have the word "and" but do not 
already have parentheses. The fourth line adds the surrounding parentheses. 
Finally we will combine the rows that belong to the same LHS value with split 
and create a list:

> TF.list <- split(TF.data$RHS, TF.data$LHS)
> TF.list
$`A`
[1] "(D and E)"  "not(B or C)"

$B
[1] "(A and C)" "not(D)"  

$C
[1] "D"

> TF.and <- lapply(TF.list, paste, collapse=" and ")
> TF.final <- lapply(names(TF.and), function(x) paste(x, "=", TF.and[[x]]))
> TF.final <- do.call(rbind, TF.final)
> TF.final
    [,1]                          
[1,] "A = (D and E) and not(B or C)"
[2,] "B = (A and C) and not(D)"
[3,] "C = D"
> write(TF.final, file="TF.output.txt")

The text file "TF.output.txt" contains the three lines.

--
David L. Carlson
Department of Anthropology
Texas A University

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of David Winsemius
Sent: Saturday, January 5, 2019 1:12 PM

Subject: Re: [R] Merge the data from multiple text files


On 1/5/19 7:28 AM, Priya Arasu via R-help wrote:
> I have multiple text files, where each file has Boolean rules.
> Example of my text file 1 and 2
> Text file 1:
> A = not(B or C)
> B = A and C
> C = D
> Text file 2:
> A = D and E
> B = not(D)
>
> I want to merge the contents in text file as follows
> A = not(B or C) and (D and E)
> B = not(D) and (A and C)
> C = D
> Is there a code in R to merge the data from multiple text files?


There is a `merge` function. For this use case you would need to first 
parse your expressions so that the LHS was in one character column and 
the RHS was in another character column in each of 2 dataframes. Then 
merge on the LHS columns and `paste` matching values from the two 
columns. You will probably need to learn how to use `ifelse` and `is.na`.

> Thank you
> Priya
>
>     [[alternative HTML version deleted]]


You also need to learn that R is a plain text mailing list and that each 
mail client has its own method for building mail in plain text.


-- 

David.

>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

   
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 

[R] error in plotting model from kernlab

2019-01-07 Thread Luigi Marongiu
Dear all,
I have a set of data in this form:
> str 
'data.frame': 1574 obs. of  14 variables:
 $ serial: int  12751 14157 7226 15663 11088 10464 1003 10427 11934 3999 ...
 $ plate : int  43 46 22 50 38 37 3 37 41 11 ...
 $ well  : int  79 333 314 303 336 96 235 59 30 159 ...
 $ sample: int  266 295 151 327 231 218 21 218 249 84 ...
 $ target: chr  "HEV 2-AI5IQWR" "Dientamoeba fragilis-AIHSPMK" "Astro
2 Liu-AI20UKB" "C difficile GDH-AIS086J" ...
 $ ori.ct: num  0 33.5 0 0 0 ...
 $ ct.out: int  0 1 0 0 0 0 0 1 0 0 ...
 $ mr: num  -0.002 0.109 0.002 0 0.001 0.006 0.015 0.119 0.003 0.004 ...
 $ fcn   : num  44.54 36.74 6.78 43.09 44.87 ...
 $ mr.out: int  0 1 0 0 0 0 0 1 0 0 ...
 $ oper.a: int  0 1 0 0 0 0 0 1 0 0 ...
 $ oper.b: int  0 1 0 0 0 0 0 1 0 0 ...
 $ oper.c: int  0 1 0 0 0 0 0 1 0 0 ...
 $ cons  : int  0 1 0 0 0 0 0 1 0 0 ...
from which I have selected two numerical variables correspondig to x
and y in a Cartesian plane and one outcome variable (z):
> df = subset(t.data, select = c(mr, fcn, cons))
>  df$cons = factor(c("negative", "positive"))
> head(df)
  mr   fcn cons
1 -0.002 44.54 negative
2  0.109 36.74 positive
3  0.002  6.78 negative
4  0.000 43.09 positive
5  0.001 44.87 negative
6  0.006  2.82 positive

I created an SVM the method with the KERNLAB package with:
> mod = ksvm(cons ~ mr+fcn, # i prefer it to the more canonical "." but the 
> outcome is the same
data = df,
type = "C-bsvc",
kernel = "rbfdot",
kpar = "automatic",
C = 10,
prob.model = TRUE)

> mod
Support Vector Machine object of class "ksvm"

SV type: C-bsvc  (classification)
 parameter : cost C = 10

Gaussian Radial Basis kernel function.
 Hyperparameter : sigma =  42.0923201429106

Number of Support Vectors : 1439

Objective Function Value : -12873.45
Training error : 0.39263
Probability model included.

First of all, I am not sure if the model worked because 1439 support
vectors out of 1574 data points means that over 90% of the data is
required to fix the hyperplane. this does not look like a model but a
patch. Secondly, the prediction is rubbish -- but this is another
story -- and when I try to create a confusion table of the processed
data I get:
>  pred = predict(mod, df, type = "probabilities")
>  acc = table(pred, df$cons)
Error in table(pred, df$cons) : all arguments must have the same length
which again is weird since mod, df and df$cons are made from the same dataframe.

Coming to the actual error, I tried to plot the model with:
> plot(mod, data = df)
> kernlab::plot(mod, data = df)
but I get this error:

Error in .local(x, ...) :
  Only plots of classification ksvm objects supported

Would you know what I am missing?
Thank you
-- 
Best regards,
Luigi

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] data frame transformation

2019-01-07 Thread Andras Farkas via R-help
Thanks Bert this will do...
Andras

Sent from Yahoo Mail on Android 
 
  On Sun, Jan 6, 2019 at 1:09 PM, Bert Gunter wrote:   
... and my reordering of column indices was unnecessary:    merge(dat, d, all.y 
= TRUE)will do.
Bert Gunter

"The trouble with having an open mind is that people keep coming along and 
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Sun, Jan 6, 2019 at 5:16 AM Andras Farkas via R-help  
wrote:

Hello Everyone,

would you be able to assist with some expertise on how to get the following 
done in a way that can be applied to a data set with different dimensions and 
without all the line items here?

we have:

id<-c(1,1,1,2,2,2,2,3,3,4,4,4,4,5,5,5,5)#length of unique IDs may differ of 
course in real data set, usually in magnitude of 1
letter<-c(sample(c("A","B","C","D","E"),3),sample(c("A","B","C","D","E"),4),sample(c("A","B","C","D","E"),2),
          
sample(c("A","B","C","D","E"),4),sample(c("A","B","C","D","E"),4))#number of 
unique "letters" is less than 4000 in real data set and they are no duplicates 
within same ID
weight<-c(sample(c(1:30),3),sample(c(1:30),4),sample(c(1:30),2),
          sample(c(1:30),4),sample(c(1:30),4))#number of unique weights is 
below 50 in real data set and they are no duplicates within same ID


data<-data.frame(id=id,letter=letter,weight=weight)

#goal is to get the following transformation where a column is added for each 
unique letter and the weight is pulled into the column if the letter exist 
within the ID, otherwise NA
#so we would get datatransform like below but without the many steps described 
here

datatransfer<-data.frame(data,apply(data[2],2,function(x) 
ifelse(x=="A",data$weight,NA)))
datatransfer<-data.frame(datatransfer,apply(datatransfer[2],2,function(x) 
ifelse(x=="B",data$weight,NA)))
datatransfer<-data.frame(datatransfer,apply(datatransfer[2],2,function(x) 
ifelse(x=="C",data$weight,NA)))
datatransfer<-data.frame(datatransfer,apply(datatransfer[2],2,function(x) 
ifelse(x=="D",data$weight,NA)))
datatransfer<-data.frame(datatransfer,apply(datatransfer[2],2,function(x) 
ifelse(x=="E",data$weight,NA)))

colnames(datatransfer)<-c("id","weight","letter","A","B","C","D","E")
much appreciate the help,

thanks

Andras 

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

  

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Mailinglist

2019-01-07 Thread PIKAL Petr
And depending on your further intentions with data, functions ave or aggregate 
could also be worth to check.

Cheers
Petr

>
> Hi Rachel.
>
> You already have got several suggestions, but results depend on structure of
> your data. The best way from your side would be just copy a part of your data
> directly to email and preferable way is to use "dput".
>
> Assuming your data already transfered to R are called "mydata".
>
> You can just copy otput of
>
> dput(mydata[1:30,])
>
> to your next mail.
>
> Cheers
> Petr
>
>
> > -Original Message-
> > From: R-help  On Behalf Of Rachel
> > Thompson
> > Sent: Sunday, January 6, 2019 7:49 PM
> > To: Rich Shepard 
> > Cc: r-help mailing list 
> > Subject: Re: [R] Mailinglist
> >
> > Hi Rich,
> >
> > I really feel lost at this point.
> > I need a code that helps me count the phone activity
> > level(high/low/none), the screen activity (on/off) and the amount calls and
> SMS of each subject.
> >
> > 1. I want to have a summary of how many times a specific subject got
> > called
> > (CallLogProbe)
> > 2. I want to have a summary of how many times a specific subject got a
> > text message (SMS probe) 3. I want to have a summary of how many times
> > a specific subject
> > - Turned their screen on - True  (ScreenProbe)
> > - Or did not turn their screen on - False (ScreenProbe) 4.  I want to
> > have a summary of the activity level of a specific subject
> > - Activity level - none (ActivityProbe)
> > - Activity level- low (ActivityProbe)
> > - Activity level - High  (ActivityProbe)
> >
> > I want to do this for all the 36 subjects(Participants).
> > In the end, I have to define the percentages and cutoff points of what
> > is considered low-medium-high, based on what the results of all the
> > subjects are. So I am able to see if a specific subject has low social
> > interaction etc.
> >
> > I have tried a lot, with the help of youtube etc. But I feel as if I
> > am trying a lot of things but without clearly knowing if it is the right 
> > step.
> > I have a csv file, but I need to look into what Jeff said about the guides.
> > So I am able to share it.
> >
> > Best.
> >
> >
> > On Sun, Jan 6, 2019 at 11:51 AM Rich Shepard
> > 
> > wrote:
> >
> > > On Sun, 6 Jan 2019, Rachel Thompson wrote:
> > >
> > > > I am an intern from Amsterdam and I have to do an analysis in R. I
> > > > spoke to my professor in Amsterdam and my supervisor's here in
> > > > Boston. But they are to busy to help. I informed them from the
> > > > start that I am not
> > > familiar
> > > > with R(Rstudio) and they told me that I would receive guidance. So
> > > > since they can not help me, I decided to share my problem online.
> > > > (It is a CVS file imported into R)
> > >
> > > Rachel,
> > >
> > >I find it interesting that you're put in such a difficult
> > > position. I've not followed this thread from the start so my
> > > comments might be redundant or inappropriate.
> > >
> > >If you can, describe the problem. That is, what are you being
> > > asked to find and what are the available data? This information
> > > helps us to guide you to learning the mechanics for accomplishing
> > > your task with R.
> > >
> > > Regards,
> > >
> > > Rich
> > >
> > > __
> > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide
> > > http://www.R-project.org/posting-guide.html
> > > and provide commented, minimal, self-contained, reproducible code.
> > >
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> Osobní údaje: Informace o zpracování a ochraně osobních údajů obchodních
> partnerů PRECHEZA a.s. jsou zveřejněny na: https://www.precheza.cz/zasady-
> ochrany-osobnich-udaju/ | Information about processing and protection of
> business partner’s personal data are available on website:
> https://www.precheza.cz/en/personal-data-protection-principles/
> Důvěrnost: Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné
> a podléhají tomuto právně závaznému prohláąení o vyloučení odpovědnosti:
> https://www.precheza.cz/01-dovetek/ | This email and any documents
> attached to it may be confidential and are subject to the legally binding
> disclaimer: https://www.precheza.cz/en/01-disclaimer/
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Osobní údaje: 

Re: [R] Mailinglist

2019-01-07 Thread Hasan Diwan
dput(sample(mydata, n=25)) is probably going to be more representative. -- H

On Mon, 7 Jan 2019 at 00:56, PIKAL Petr  wrote:

> Hi Rachel.
>
> You already have got several suggestions, but results depend on structure
> of your data. The best way from your side would be just copy a part of your
> data directly to email and preferable way is to use "dput".
>
> Assuming your data already transfered to R are called "mydata".
>
> You can just copy otput of
>
> dput(mydata[1:30,])
>
> to your next mail.
>
> Cheers
> Petr
>
>
> > -Original Message-
> > From: R-help  On Behalf Of Rachel Thompson
> > Sent: Sunday, January 6, 2019 7:49 PM
> > To: Rich Shepard 
> > Cc: r-help mailing list 
> > Subject: Re: [R] Mailinglist
> >
> > Hi Rich,
> >
> > I really feel lost at this point.
> > I need a code that helps me count the phone activity
> level(high/low/none),
> > the screen activity (on/off) and the amount calls and SMS of each
> subject.
> >
> > 1. I want to have a summary of how many times a specific subject got
> called
> > (CallLogProbe)
> > 2. I want to have a summary of how many times a specific subject got a
> text
> > message (SMS probe)
> > 3. I want to have a summary of how many times a specific subject
> > - Turned their screen on - True  (ScreenProbe)
> > - Or did not turn their screen on - False (ScreenProbe)
> > 4.  I want to have a summary of the activity level of a specific subject
> > - Activity level - none (ActivityProbe)
> > - Activity level- low (ActivityProbe)
> > - Activity level - High  (ActivityProbe)
> >
> > I want to do this for all the 36 subjects(Participants).
> > In the end, I have to define the percentages and cutoff points of what is
> > considered low-medium-high, based on what the results of all the subjects
> > are. So I am able to see if a specific subject has low social interaction
> > etc.
> >
> > I have tried a lot, with the help of youtube etc. But I feel as if I am
> > trying a lot of things but without clearly knowing if it is the right
> step.
> > I have a csv file, but I need to look into what Jeff said about the
> guides.
> > So I am able to share it.
> >
> > Best.
> >
> >
> > On Sun, Jan 6, 2019 at 11:51 AM Rich Shepard 
> > wrote:
> >
> > > On Sun, 6 Jan 2019, Rachel Thompson wrote:
> > >
> > > > I am an intern from Amsterdam and I have to do an analysis in R. I
> spoke
> > > > to my professor in Amsterdam and my supervisor's here in Boston. But
> they
> > > > are to busy to help. I informed them from the start that I am not
> > > familiar
> > > > with R(Rstudio) and they told me that I would receive guidance. So
> since
> > > > they can not help me, I decided to share my problem online. (It is a
> CVS
> > > > file imported into R)
> > >
> > > Rachel,
> > >
> > >I find it interesting that you're put in such a difficult position.
> I've
> > > not followed this thread from the start so my comments might be
> redundant
> > > or
> > > inappropriate.
> > >
> > >If you can, describe the problem. That is, what are you being asked
> to
> > > find and what are the available data? This information helps us to
> guide
> > > you
> > > to learning the mechanics for accomplishing your task with R.
> > >
> > > Regards,
> > >
> > > Rich
> > >
> > > __
> > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide
> > > http://www.R-project.org/posting-guide.html
> > > and provide commented, minimal, self-contained, reproducible code.
> > >
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> Osobní údaje: Informace o zpracování a ochraně osobních údajů obchodních
> partnerů PRECHEZA a.s. jsou zveřejněny na:
> https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ | Information
> about processing and protection of business partner’s personal data are
> available on website:
> https://www.precheza.cz/en/personal-data-protection-principles/
> Důvěrnost: Tento e-mail a jakékoliv k němu připojené dokumenty jsou
> důvěrné a podléhají tomuto právně závaznému prohláąení o vyloučení
> odpovědnosti: https://www.precheza.cz/01-dovetek/ | This email and any
> documents attached to it may be confidential and are subject to the legally
> binding disclaimer: https://www.precheza.cz/en/01-disclaimer/
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>


-- 

Re: [R] Mailinglist

2019-01-07 Thread PIKAL Petr
Hi Rachel.

You already have got several suggestions, but results depend on structure of 
your data. The best way from your side would be just copy a part of your data 
directly to email and preferable way is to use "dput".

Assuming your data already transfered to R are called "mydata".

You can just copy otput of

dput(mydata[1:30,])

to your next mail.

Cheers
Petr


> -Original Message-
> From: R-help  On Behalf Of Rachel Thompson
> Sent: Sunday, January 6, 2019 7:49 PM
> To: Rich Shepard 
> Cc: r-help mailing list 
> Subject: Re: [R] Mailinglist
>
> Hi Rich,
>
> I really feel lost at this point.
> I need a code that helps me count the phone activity level(high/low/none),
> the screen activity (on/off) and the amount calls and SMS of each subject.
>
> 1. I want to have a summary of how many times a specific subject got called
> (CallLogProbe)
> 2. I want to have a summary of how many times a specific subject got a text
> message (SMS probe)
> 3. I want to have a summary of how many times a specific subject
> - Turned their screen on - True  (ScreenProbe)
> - Or did not turn their screen on - False (ScreenProbe)
> 4.  I want to have a summary of the activity level of a specific subject
> - Activity level - none (ActivityProbe)
> - Activity level- low (ActivityProbe)
> - Activity level - High  (ActivityProbe)
>
> I want to do this for all the 36 subjects(Participants).
> In the end, I have to define the percentages and cutoff points of what is
> considered low-medium-high, based on what the results of all the subjects
> are. So I am able to see if a specific subject has low social interaction
> etc.
>
> I have tried a lot, with the help of youtube etc. But I feel as if I am
> trying a lot of things but without clearly knowing if it is the right step.
> I have a csv file, but I need to look into what Jeff said about the guides.
> So I am able to share it.
>
> Best.
>
>
> On Sun, Jan 6, 2019 at 11:51 AM Rich Shepard 
> wrote:
>
> > On Sun, 6 Jan 2019, Rachel Thompson wrote:
> >
> > > I am an intern from Amsterdam and I have to do an analysis in R. I spoke
> > > to my professor in Amsterdam and my supervisor's here in Boston. But they
> > > are to busy to help. I informed them from the start that I am not
> > familiar
> > > with R(Rstudio) and they told me that I would receive guidance. So since
> > > they can not help me, I decided to share my problem online. (It is a CVS
> > > file imported into R)
> >
> > Rachel,
> >
> >I find it interesting that you're put in such a difficult position. I've
> > not followed this thread from the start so my comments might be redundant
> > or
> > inappropriate.
> >
> >If you can, describe the problem. That is, what are you being asked to
> > find and what are the available data? This information helps us to guide
> > you
> > to learning the mechanics for accomplishing your task with R.
> >
> > Regards,
> >
> > Rich
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Osobní údaje: Informace o zpracování a ochraně osobních údajů obchodních 
partnerů PRECHEZA a.s. jsou zveřejněny na: 
https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ | Information about 
processing and protection of business partner’s personal data are available on 
website: https://www.precheza.cz/en/personal-data-protection-principles/
Důvěrnost: Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a 
podléhají tomuto právně závaznému prohláąení o vyloučení odpovědnosti: 
https://www.precheza.cz/01-dovetek/ | This email and any documents attached to 
it may be confidential and are subject to the legally binding disclaimer: 
https://www.precheza.cz/en/01-disclaimer/

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.