Displaying 20 results from an estimated 10000 matches similar to: "process id of an R script"
2007 Feb 02
2
Help with OS X (BSD) ps command
My fame package has a function that checks to see if a FAME SERVER process is
already running. On Linux, I can do this in one of two ways:
pid <- Sys.getpid()
user <- Sys.info()["user"]
cmd <- paste("pgrep -fU", user, "-P", pid, "'FAME SERVER'")
fameRunning <- as.logical(length(system(cmd, intern = T)))
or I can use
cmd
2006 Jan 27
3
substituting an object not found
Is there any function in R like
is.not.found(x, y)
meaning if you can't find object x, then use object
y??
Mikkel Grum
2010 Dec 28
4
batch file output
I run a batch file with the following command in Windows XP:
C:\R\R-2.12.1\bin\Rterm.exe --no-save --no-restore <C:\users\me\file.R> C:\users\me\file.out 2>&1
Is there any way to get only the output of R in file.out, without getting all the code from file.R too?
Any help greatly appreciated,
Mikkel
2007 Dec 30
3
Date formats
Is the following expected behaviour for a date used in
an ifelse function?
> date <- Sys.Date()
> date
[1] "2007-12-30"
> ifelse(TRUE, date-1, date)
[1] 13876
> ifelse(FALSE, date-1, date)
[1] 13877
> ifelse(TRUE, as.character(date-1), date)
[1] "2007-12-29"
> if (TRUE) {date}
[1] "2007-12-30"
It would seem more natural to me if a date produced
2006 Jan 02
1
"7:9, 12:14" in dataframe to c(7:9, 12:14)
I want to do something like df[df$b %in% df2[i, 2], ]
where df$b is a numeric vector and df2[i, 2] is a
factor with
levels like "7:9, 12:14". For example:
a <- c(paste("A", 1:10, sep = ""), paste("B", 1:10,
sep = ""))
b <- 1:20
df <- as.data.frame(cbind(a, b))
df$b <- as.numeric(levels(df$b))[as.integer(df$b)]
f <-
2005 Jun 01
3
x[x$a=="q",,drop=TRUE]
I'm trying to select a subset of a dataframe while
dropping some factors. While the dataset gets smaller
all Factor levels remain and I need to get rid of
them. Strangely enough, I am almost certain that the
same code on the same data worked OK earlier today -
and it is not the first time that I'm not able to
replicate earlier results with this command (I know, I
might just be going
2004 Dec 31
2
Supressing empty sections with Sweave
Dear useRs,
I'm writing regular survey reports using Sweave. Each
report has several sections along the lines of:
\section*{Disease X}
<<MapX,fig=TRUE,echo=FALSE>>=
image(vectorx,vectory,matrixz)
@
Notes with or without Sexpr{a}.
\vfill
\pagebreak
\section*{Disease Y}
<<MapY,fig=TRUE,echo=FALSE>>=
...etc.
Often one or more of the diseases is not observed (all
2007 Aug 07
2
backslash c
How do I get output with "\color{blue}", i.e. with
only one backslash???
> "\color{blue}"
[1] "color{blue}"
Warning messages:
1: '\c' is an unrecognized escape in a character
string
2: unrecognized escape removed from "\color{blue}"
> "\\color{blue}"
[1] "\\color{blue}"
>
Any help greatly appreciated.
Best regards,
2004 Dec 21
1
scheduling R tasks under windows
I'm trying to schedule R tasks in Windows Server 2003.
I can run the following from the DOS prompt without
any difficulty:
c:\Reports>c:\r\rw2001\bin\rterm.exe --no-restore
--no-save <test.R> test.out
where test.r has two lines: library(tools);
Sweave("rlr.Rnw").
When I try to run the same from the task scheduler, I
fill in the dialogue box as follows:
Run:
2007 Nov 24
2
truncated fields with RODBC
I'm changing some functions from storing data in
SQLite (using RSQLite) to storing it in PostgreSQL
(using RODBC). When trying to store very long
character fields I get the following message:
> sqlSave(pg, Grids, rownames = FALSE, append =
TRUE)
Warning messages:
1: In odbcUpdate(channel, query, mydata, paramdata,
test = test, verbose = verbose, :
character data truncated in column
2004 Aug 22
1
latitude longitude data
Dear R-helpers,
I get GPS readings with bug counts (bugs meaning
insects in this case) made along rows in crop fields
and use these to make maps of bug distribution. The
GPS readings are not quite accurate enough for my
purpose, so since I know what row each reading is made
in, I adjust the latitudinal coordinate using:
grd<-lm(lat~lon+Row,data)
2011 Sep 12
1
Superimposing titles on dotcharts
I've created a chart with times that employees have entered data on named tasks as in the following example:
Employee <- c(rep("Tom", 127),?
rep("Dick", 121),?
rep("Sally", 130)
)
Time <- c(seq(as.POSIXct("2011-09-12 07:00:00"), as.POSIXct("2011-09-12 14:00:00"), 200),
seq(as.POSIXct("2011-09-12 07:00:00"),
2011 May 02
2
INSERT OR UPDATE
I'm trying to insert rows of a data.frame into a database table, or update where the key fields of a record already exist in the table. I've come up with a possible solution below, but would like to hear if anyone has a better solution.
# The problem demonstrated:
# Create a data.frame with test values
library(RODBC)
tbl <- data.frame(
key1 = rep(1:3, each = 2),
key2 =
2012 Oct 29
6
export variable from bash to R
Dear R experts
This probably seems very easy to you guys, but I'm a beginner and would be
really glad if someone helped me with this:
I am trying to automate the execution of an R script (let's call it
"myscript.R") by passing a variable from a bash script to myscript.R.
I know I can use the command Rscript, but I don't know how to declare in
bash which variable will be
2002 Jan 08
6
Subsets without NA
Is there a way of removing all rows with missing values from a data frame?
I usually use
subset(x, var1!="NA")
and repeat for each variable. It would be nice to be able to do it in one
fell swoop. Also, surprisingly, it doesn't always work. Sometimes I'm left
with an empty set even though not all rows have missing values for the
variable.
Cheers,
mikkel
Mikkel Grum,
2005 Feb 25
3
passing command line arguments to 'R CMD BATCH myScript.R'
Hi Community,
I have a question about how to pass command line parameters to R script
running in the batch mode. The problem is: there is a banch of data
files which are to be processed by R script called from a web-server,
i.e. in the batch mode. The web server generates data files and passes
their names calling 'R CMD BATCH' one by one for every file. Now the
question is how to
2002 Jan 08
3
colour coding and different point types in a plot
I'm trying to plot four different sorghum types on a plot using a different
colour/symbol combination for each sorghum type (TYPBOTA in the script
below). What am I doing wrong?:
plot(xx$LATITUDE,xx$SFD1,
points(xx$SFD1,xx$LATITUDE,
col=1:4[codes(xx$TYPBOTA)],pch=c(4,3,1,2)[codes(xx$TYPBOTA)])
grid()
I get the following error message
Error in 1:4[codes(xx$TYPBOTA)] : NA/NaN argument
2003 Jan 07
2
Extracting means for given strata from dissimilarity object
Is there a way of extracting mean distance or dissimilarity for a given
strata from a 'dist' or 'dissimilarity' object, e.g. extract mean distances
for each species in Anderson's iris data?
data(iris)
iris.dist<-dist(iris[,1:4])
then what?
Mikkel Grum, PhD
Genetic Diversity Scientist
International Plant Genetic Resources Institute (IPGRI)
Sub-Saharan Africa Group
***
2001 Aug 13
3
subset syntax
Can anyone tell me what's wrong with this command??
xx<-subset(x,LOCAL.NAME==c("Chifumbata","Chikota"),select=c(13,16,19,23,26,2
9,30,33:48))
Warning message:
longer object length
is not a multiple of shorter object length in: LOCAL.NAME ==
c("Chifumbata", "Chikota")
both of the following commands work fine
2003 Sep 02
1
Plotting dates
I'm trying to plot observations against observation dates and getting julian
dates along the x-axis:
library(date)
Week<-as.date(c("05/02/03","05/09/03","05/16/03","05/23/03","05/30/03","06/0
7/03","06/14/03"))
Leafminers<-c(0,2,5,10,4,6,5)
Diglyphus<-c(0,0,4,5,7,3,1)
LeafDig<-cbind(Week,Leafminers,Diglyphus)