Re: [R] function which returns number of occurrences of a pattern in string

2016-10-24 Thread Jan Kacaba
ctions with not too much more typing. > > On Thu, Oct 20, 2016 at 5:47 PM, Jan Kacaba wrote: > > Hello dear R-help > > > > I tried to find function which returns number of occurrences of a pattern > > in string. The closest match I've found is str_locate_all in

[R] function which returns number of occurrences of a pattern in string

2016-10-20 Thread Jan Kacaba
Hello dear R-help I tried to find function which returns number of occurrences of a pattern in string. The closest match I've found is str_locate_all in stringr package. I can use str_locate_all but write my function but I don't want reinvent wheel. JK [[alternative HTML version deleted]

Re: [R] strange output of cat function used in recursive function

2016-10-01 Thread Jan Kacaba
2016-10-01 18:02 GMT+02:00 David Winsemius : > >> On Oct 1, 2016, at 8:44 AM, Jan Kacaba wrote: >> >> Hello Dear R-help >> >> I tried to understand how recursive programming works in R. Bellow is >> simple recursive function. >> >> binary1 <-

[R] strange output of cat function used in recursive function

2016-10-01 Thread Jan Kacaba
Hello Dear R-help I tried to understand how recursive programming works in R. Bellow is simple recursive function. binary1 <- function(n) { if(n > 1) { binary(as.integer(n/2)) } cat(n %% 2) } When I call binary1(10) I get 1010. I believe that cat function stores value to a buffer appen

[R] R Studio: Run script upon saving or exiting

2016-08-13 Thread Jan Kacaba
Dear R help, I would like to run script upon saving project files or exiting the R Studio. For example I would like to backup whole project in another directory. The backup directory should be named such that incremental version number will added to project name. Is it somehow possible? Even bet

[R] print all variables inside function

2016-05-23 Thread Jan Kacaba
Hello dear R-help I would like to use some short and simple names multiple times inside one script without collisions. I need to wrap the variables inside some object. I know I can use class function or environment. For example as follows: exmp1<-function(){ # knowns pa=0.35 pb=0.35 pc=

Re: [R] break string at specified possitions

2016-05-17 Thread Jan Kacaba
ends)) > } > > Will be much faster than substring (e.g. 100x or 1000x) when > chopping a string like a Human chromosome into hundreds or > thousands of fragments. > > Biostrings is a Bioconductor package: > > https://bioconductor.org/packages/Biostrings >

Re: [R] break string at specified possitions

2016-05-12 Thread Jan Kacaba
t 10:05 AM, Jim Lemon wrote: >> Hi Jan, >> This might be helpful: >> >> chop_string<-function(x,ends) { >> starts<-c(1,ends[-length(ends)]-1) >> return(substring(x,starts,ends)) >> } >> >> Jim >> >> >> On Thu,

Re: [R] break string at specified possitions

2016-05-11 Thread Jan Kacaba
7; package: > https://cran.r-project.org/web/packages/stringr/stringr.pdf > > Cheers, > > 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

[R] break string at specified possitions

2016-05-11 Thread Jan Kacaba
Dear R-help I would like to split long string at specified precomputed positions. 'substring' needs beginings and ends. Is there a native function which accepts positions so I don't have to count second argument? For example I have vector of possitions pos<-c(5,10,19). Substring needs input first

[R] row names, coulmn names

2016-05-01 Thread Jan Kacaba
Hello dear R helpers, Is it possible to have more than 1 row for column names in data.frame, array, tbl_df? I would like to have column numbers in the first row, string names in the second row, physical unit in third row. How would I do it? Derek [[alternative HTML version deleted]] ___

[R] inserting row(column) in array or dataframe at specified row(column)

2016-05-01 Thread Jan Kacaba
Hello dear R users, Is there a function or package which can insert row, column or array in another array at specified place (row or column)? I have made several attempts at this function optimizing both speed, code readability and ease of use. The functions are of following format: appcol=funct

[R] (windows) opening document with particular exe file

2016-04-26 Thread Jan Kacaba
Hello dear R, I dont have specific task on mind just learning R. 1) Is it possible to open a document for example path1\myfile.pdf with program path2\pdfviewer.exe ? How would I do it in win? Does it differ in linux? 2) Is it possible to run a program and supply to it some streams? The streams a

Re: [R] Accented characters, windows

2016-03-30 Thread Jan Kacaba
eed to write string to a file. I hope there is no problem processing strings with other functions like paste, strsplit, grep though. Derek 2016-03-30 0:56 GMT+02:00 Duncan Murdoch : > On 29/03/2016 5:39 PM, Jan Kacaba wrote: > >> I have problem with accented characters. My OS is Win 8

[R] Accented characters, windows

2016-03-29 Thread Jan Kacaba
I have problem with accented characters. My OS is Win 8.1 and I'm using RStudio. I make string : av="ěščřž" When I call "av" I get result bellow. > av [1] "ìšèøž" The resulting characters are different. I have similar problem when I write string to a file. In RGUI if I call "av" it prints charac

[R] R studio kniter

2016-03-22 Thread Jan Kacaba
Hello, is it possible to run kiniter by script instead by clicking on button compile PDF? Say I have "texfile.rnw" and "myscript.R". I would like to knit texfile.rnw by runnig script "myscript.R". In "myscript.R" I would write something like this: knit("texfile.rnw") [[alternative HTML ve

[R] treating integer(0) and NULL in conditions and loops

2016-03-11 Thread Jan Kacaba
Hello, I have following problem in loops. It occurred to me multiple times bellow is an example. Inside if() I have sometimes function f(x) which may return integer(0). If I test f(x)>1 and f(x)=integer(0) I get error. Maybe it can be solved more eloquently without loop or swithces. I don't know.

[R] assign a vector to list sequence

2016-03-09 Thread Jan Kacaba
Hello I would like to assign a vector to list sequence. I'm trying my code bellow, but the output is not what inteded. # my code mls=vector(mode="list") # my list cseq=c(1:3) # my vector mls[cseq]=cseq I get following: [[1]] [1] 1 [[1]] [2] 2 [[1]] [2] 3 What I need is this: [[1]] [1] 1 2 3 [[1]

[R] trying to reach R-help

2016-03-05 Thread Jan Kacaba
Hello, I'm rather desperate so please excuse me if I'm using wrong emails. I'm sad that the forum at nabble is not functinal as before. I'm by no way want to critique something. I just don't understand in which way is mailing better than forum. I'm subscriber to R-help, but it seems that I'm unabb

[R] missing values in csv file

2016-02-17 Thread Jan Kacaba
In my original data a csv file I have missing values. If I use read.table the missing values are replaced by NAs. Is it possible to get object where missing values aren't replaced with NAs? Is it possible to replace NAs with empty space? [[alternative HTML version deleted]] _