Displaying 20 results from an estimated 3000 matches similar to: "strange behaviour when sourcing inside function"
2012 Aug 22
1
Plot label axis with expression
Hi all,
I need help with axis in plot.
I want to edit y axis label of my plot. My data is like:
x <- c(100,50,10,1,0.1,0.05,0.001)
plot(log(x))
axTicks(2) # Label of y axis
[1] -6 -4 -2 0 2 4
I'd like that y axis label was like: e^-6, e^-4, etc. (with text "e"
superscript -6, -4, etc.) I try to use expression(), but don't work.
plot(log(x), yaxt="n")
2012 Aug 24
1
Regular expressions: stuck again...
Hi,
I'm currently reworking a report, originating from a MS Access database, but
should be implemented in R.
Now I'm facing the task to convert a lot of queries to postgreSQL.
What I want to do is make a function which takes the MS Access query as an
argument and returns the pgSQL version.
So:
SELECT [public_tblFiche].[Fichenr], [public_tblArtnr].[Artnr] FROM
[public_tblFiche],
2012 Aug 24
1
RJSONIO/rjson maximum depth?
Hi All,
has anyone run into maximum depth of nested JSON arrays in either rjson or
RJSONIO ?
I seem to be able to get up to 10 depth levels without problem, but
crossing over to 11 either causes an error or fails to load the nodes
properly.
with RJSONIO I tried:
a = fromJSON('data/myJSON.json', depth=1000)
but I still get this error:
Error in fromJSON(content, handler, default.size,
2012 Aug 25
2
sourcecode for the balloonplot function from the gplots package
Hi,
I want to take a look at the sourcecode for balloonplot. I would appreciate it if I could get help on overcoming the following problem :
> methods(balloonplot)
[1] balloonplot.default* balloonplot.table* ?
? ?Non-visible functions are asterisked
> balloonplot.default
Error: object 'balloonplot.default' not found
>
How do I access the non-visible functions?
Thanks,
Ravi??
2012 Aug 21
2
Entering a table
I'm trying to enter a frequency table manually so that I can run a
goodness of fit test (I only have the frequencies, I don't have the
raw data).
So for example, let's say I want to re-create the HorseKicks table:
library(vcd)
data(HorseKicks)
str(HorseKicks)
'table' int [1:5(1d)] 109 65 22 3 1
- attr(*, "dimnames")=List of 1
..$ nDeaths: chr [1:5]
2012 Aug 21
7
Regular Expressions in grep
Dear r-help members,
I have a number in the form of a string, say:
a<-"-01020.909200"
I'd like to extract "1020." as well as ".9092"
Front<-grep(pattern="[1-9]+[0-9]*\\.", value=TRUE, x=a, fixed=FALSE)
End<-grep(pattern="\\.[0-9]*[1-9]+", value=TRUE, x=a, fixed=FALSE)
However, both strings give "-01020.909200", exactly
2012 Aug 28
5
return first index for each unique value in a vector
I would like to efficiently find the first index of each unique value in a
very large vector.
For example, if I have a vector
A<-c(9,2,9,5)
I would like to return not only the unique values (2,5,9) but also their
first indices (2,4,1).
I tried using a for loop with which(A==unique(A)[i])[1] to find the first
index of each unique value but it is very slow.
What I am trying to do is easily
2012 Aug 17
3
Error: level sets of factors are different?
Why the error is coming? even though the length of outcome.new$compkey and outcome.new$armkey were exactly same.
Can anyone help?
setwd("D:/AZ")
library("RODBC")
cdb_cnct <- odbcConnectExcel("AZIF_DC_GVK_NSCLC_MSALL_287papers_02072012_141450_v1_4.xls")
outcomes <- sqlFetch(cdb_cnct, "Outcomes_info")
odbcClose(cdb_cnct)
rm(cdb_cnct)
2012 Aug 20
7
relating data in two data frames
Hi,
My data.frame "A" has FID like this
FID
a
a
b
b
b
c
c
d
d
d
d
Now my second data.frame "B" has age value for a, b, c, d like
FID Age
a 5
b 7
c 9
d 3
How can search for the Age column in "B" and replace the values in "A" so that my new "A" looks like this
FID Age
a 5
a 5
b 7
b 7
b 7
2011 Apr 27
3
setting options only inside functions
Dear list members,
is it possible to set some options only inside a function so that the original options are restored once the function is finished or aborted due to an error? Until now I do something like:
dummy=function()
{
old.options=options(error=dummy1())
....
options(old.options)
}
This works for most cases but when the function terminates because of an error and its last
2012 Aug 24
6
updating elements of a vector sequentially - is there a faster way?
I would like to know whether there is a faster way to do the below
operation (updating vec1).
My objective is to update the elements of a vector (vec1), where a
particular element i is dependent on the previous one. I need to do this on
vectors that are 1 million or longer and need to repeat that process
several hundred times. The for loop works but is slow. If there is a faster
way, please let
2010 Dec 16
5
test whether all elements of a vector are identical
Dear list,
this might be an easy one, but I could figure out a solution (or how to
google the right term).
Is there any way to test whether all elements of a vector are identical?
For numeric vectors I would use
sum(diff(vector)==0)==0
but I have character vectors. Any Ideas?
Cheers
Jannis
2011 Jun 16
7
[PATCH] replace fchmod()-based heartbeat with raindrops
This means we no longer waste an extra file descriptor per
worker process in the master. Now there''s no need to set a
higher file descriptor limit for systems running >= 1024
workers.
---
I just pushed this out to git://bogomips.org/unicorn.git and it''ll
be in Unicorn 4.x.
The subset of raindrops used by Unicorn should work on all machines
with mmap(2) +
2011 Jan 20
2
Procuct of a sequence or vector
Dear list,
is there a function in R that returns the product of a vector?
E.g. if the vector is c(1,2,3,4) it should return 1*2*3*4=24
Cheers
Jannis
2011 Feb 06
6
Request queue length
Is there a way to get the number of requests that are currently awaiting
to be executed by my rails app by unicorn?
Or there is no queue in unicorn and I should look for this information
somewhere in nginx or other front-end server?
Couldn''t find much information about this topic, so decided to ask here
first.
2012 Feb 27
2
problem with assign and get
Dear list members,
does anyone have an idea why the following construction does not work
but gives the following error message:
assign('test', array(1:10, dim=c(10,10)))
dimnames(get('test')) <- list(1:10,1:10)
Error in dimnames(get("test")) <- list(1:10, 1:10) :
target of assignment expands to non-language object
What could be a way to get this to work?
2012 Jun 15
2
time zones and the chron to POSIXct conversion
Hey R folks,
i found some strange (to me) behaviour with chron to POSIXct conversion.
The two lines of code result in two different results, on ewith the
correct time zone, one without:
library(chron)
as.POSIXct(chron('12/12/2000'), tz = 'UTC')
as.POSIXlt(chron('12/12/2000'), tz = 'UTC')
Only the code below would give me a POSIXct object with the correct time
2011 Oct 05
3
help with regexp
Dear list memebers,
I am stuck with using regular expressions.
Imagine I have a vector of character strings like:
test <- c('filename_1_def.pdf', 'filename_2_abc.pdf')
How could I use regexpressions to extract only the 'def'/'abc' parts of these strings?
Some try from my side yielded no results:
testresults <-
2011 May 04
1
Problems saving ff objects
Dear list,
I am trying to understand and use the ff package. As I had some problems saving some ff objects, and as I did not fully manage to understand the whole concept of *.ff, *.ffData and *.RData with the help of the documentation, I tried to reproduce the examples from the help of ffsave.
When I ran, however : (copied from the help)
message("let's create some ff objects")
2013 Apr 08
4
checkUsage from codetools shows errors when function uses functions from loaded packages
Dear list members,
I frequently program small scripts and wrap them into functions to be
able to check them with checkUsage. In case these functions (loaded via
source or copy pasted to the R console) use functions from other
packages, I get this error:
no visible global function definition for ?xxxxxxx?
For example:
test = function() {
require(plotrix)
color.legend()
}