Re: [R] sample (randomly select) to get a number of successive days

2018-12-09 Thread Dagmar Cimiotti
Hi Marc, Yes, you got it to the point! That is exactly what I want. But I do not know how to do that. I know how to randomly pick the first day but I do not know how to set a range of values which cover the 25 days starting from that random value. Best, Dagmar Hi, I am confused. As far as

[R] repeating the same variable in formula

2018-12-09 Thread Subirana Cachinero, Isaac
I am using terms.formula function to substract the variables from a formula environment. Concretely, with the attr(*, "term.labels") I get the right side terms specified in the formula. However, when introducing the same variable two or more times, this appears only once. For example, when ty

Re: [R] Plotting Very Large lat-lon data in x-y axes graph

2018-12-09 Thread Ogbos Okike
Dear Jim, I used a bit of my data in my attempt to follow the code. I got the attached plot after some tweaks. I would like to add horizontal color bar legend that could be used to explain the number of lightning counts at different points on the latitude band as plotted. Thank you Warm regards

Re: [R] Spark DataFrame: replace NULL cell by NA

2018-12-09 Thread Bert Gunter
"... if("factor" %in% class(x)) x <- as.character(x) ## since ifelse wont work with factors " Nonsense! > x <- factor(c("a","", "b")) > x [1] a b Levels: a b > levels(x) [1] "" "a" "b" > x <- factor(ifelse(x==(""),NA,x)) > x [1] 2 3 Levels: 2 3 Bert Gunter "The trouble with having

[R] Spark DataFrame: replace NULL cell by NA

2018-12-09 Thread Karim Mezhoud
Dear All, ## function to relpace empty cell by NA empty_as_na <- function(x){ if("factor" %in% class(x)) x <- as.character(x) ## since ifelse wont work with factors ifelse(as.character(x)!="", x, NA) } ## connect to spark local sc <- spark_connect(master = "local") # load an example of datafra

Re: [R] Plotting Very Large lat-lon data in x-y axes graph

2018-12-09 Thread Jim Lemon
Hi Ogbos, Here is a slight modification of a method I use to display trip density on a map: oolt<-read.table(text="Lat Lon 30.1426 104.7854 30.5622 105.0837 30.0966 104.6213 29.9795 104.8430 39.2802 147.7295 30.2469 104.6543 26.4428 157.7293 29.4782 104.5590 32.3839 105.3293 26.4746 157.8411 25.10

Re: [R] Plotting Very Large lat-lon data in x-y axes graph

2018-12-09 Thread Bert Gunter
Yes, there are many ways to do this. Search rseek.org for "2d density plots". Also check the CRAN "Spatial" task view. Also see the kde2d function in the MASS package and especially the examples there that use the image() function to plot densities. Cheers, Bert Bert Gunter "The trouble with hav

Re: [R] how to keep colnames of matrix when put it into a data frame

2018-12-09 Thread Rui Barradas
Hello, cbind alone will return a matrix, cbind.data.frame is probably what the OP wants. class(cbind(x = 1:3, mat)) #[1] "matrix" cbind.data.frame(x = 1:3, mat) # x (1) (2) (3) #1 1 1 4 7 #2 2 2 5 8 #3 3 3 6 9 Hope this helps, Rui Barradas Às 15:11 de 09/12/2018, Micha

[R] Plotting Very Large lat-lon data in x-y axes graph

2018-12-09 Thread Ogbos Okike
Dear Contributors, I have a data of the form: Lat Lon 30.1426 104.7854 30.5622 105.0837 30.0966 104.6213 29.9795 104.8430 39.2802 147.7295 30.2469 104.6543 26.4428 157.7293 29.4782 104.5590 32.3839 105.3293 26.4746 157.8411 25.1014 159.6959 25.1242 159.6558 30.1607 104.9100 31.4900 -71.89

Re: [R] how to keep colnames of matrix when put it into a data frame

2018-12-09 Thread Jeff Newmiller
Read ?data.frame In particular, notice the check.names argument. On December 9, 2018 7:11:52 AM PST, Michael Dewey wrote: >Dear Jinsong > >Try cbind(x = 1:3, mat) >and see if that helps > >Michael > >On 09/12/2018 15:05, Jinsong Zhao wrote: >> Hi there, >> >> In the following mini-example, I

Re: [R] how to keep colnames of matrix when put it into a data frame

2018-12-09 Thread Bert Gunter
Your names are not syntactically valid. Consider: > mat <- matrix(1:9, nrow = 3) > colnames(mat) <- letters[1:3] > mat a b c [1,] 1 4 7 [2,] 2 5 8 [3,] 3 6 9 > data.frame(x=1:3,mat) x a b c 1 1 1 4 7 2 2 2 5 8 3 3 3 6 9 See ?make.names, and the "Value" section of ?data.frame for how names

Re: [R] how to keep colnames of matrix when put it into a data frame

2018-12-09 Thread Michael Dewey
Dear Jinsong Try cbind(x = 1:3, mat) and see if that helps Michael On 09/12/2018 15:05, Jinsong Zhao wrote: Hi there, In the following mini-example, I hope to keep the column names of mat, but failed. # mini-example mat <- matrix(1:9, nrow = 3) colnames(mat) <- paste("(", 1:3, ")", sep = "

[R] how to keep colnames of matrix when put it into a data frame

2018-12-09 Thread Jinsong Zhao
Hi there, In the following mini-example, I hope to keep the column names of mat, but failed. # mini-example > mat <- matrix(1:9, nrow = 3) > colnames(mat) <- paste("(", 1:3, ")", sep = "") > mat (1) (2) (3) [1,] 1 4 7 [2,] 2 5 8 [3,] 3 6 9 > data.frame(x = 1:3, mat) x X.

Re: [R] General information

2018-12-09 Thread Rui Barradas
Hello, Às 00:28 de 09/12/2018, David Winsemius escreveu: Most of those answers are in the R-FAQ. It ships with every distribution copy from CRTAN and is also available online. Estimating the number of R users would be difficult. There are probably 20,000+ subscriblers to Rhelp. The OP ask