Displaying 20 results from an estimated 10000 matches similar to: "Question regarding subsetting"
2008 Apr 11
3
strsplit and sapply
Colleagues,
I have some text:
TEXT <- c("a", "bb;ccc", "dddd;eeeee;ffffff")
I want to retrieve the portion of each element before the first
semicolon. I can split each element using strsplit:
SPLIT <- strsplit(TEXT, ";")
This yields:
> SPLIT
[[1]]
[1] "a"
[[2]]
[1] "bb" "ccc"
[[3]]
[1] "dddd"
2005 Oct 18
6
Subsetting a list
Colleagues,
I have created a list in the following manner:
TEST <- list(c("A1", "A2"), c("B1", "B2"), c("C1", "C2"))
I now want to delete one element from the list, e.g., the third. The
command
TEST[[3]]
yields (as expected):
[1] "C1" "C2"
The command
TEST[[-3]]
yields:
Error:
2011 May 26
4
Applying "toupper" to only portions of text strings
Colleagues
Assume that I have a vector containing some text strings, some of which contain a particular character. I could like to apply "toupper" to the text before the character. For example (in this case, "|" is the particular character):
ORIGINAL:
TEXT <- c("aaaa", "bbb|cc", "|ddd")
AFTER APPLICATION OF toupper:
TEXT <-
2009 Sep 29
3
Deleting a column in a dataframe by name
Colleagues,
Hopefully a simple problem: I want to delete a column with a known
name from a dataframe. I could write:
FRAME <- FRAME[, names(FRAME) != NAMETODELETE]
or
FRAME <- FRAME[, !names(FRAME) %in% c(NAME1, NAME2, ETC)]
Is there some simpler means to accomplish this?
Dennis
Dennis Fisher MD
P < (The "P Less Than" Company)
Phone: 1-866-PLessThan (1-866-753-7784)
2007 Sep 04
2
Recursive concatenation
Colleagues,
I want to create the following array:
"A1", "A2", "A3", "B1", "B2", "B3", "C1", "C2", "C3"
I recall that there is a trick using "c" or "paste" permitting me to
form all combinations of c("A", "B", "C") and 1:3. But, I can't
recall the
2007 Aug 03
3
Sourcing commands but delaying their execution
Colleagues:
I have encountered the following situation:
SERIES OF COMMANDS
source("File1")
MORE COMMANDS
source("File2")
Optimally, I would like File1 and File2 to be merged into a single
file (FileMerged). However, if I wrote the following:
SERIES OF COMMANDS
source("FileMerged")
MORE COMMANDS
I encounter an error: the File2 portion of FileMerged
2008 Dec 15
3
opening a PDF document
Colleagues,
I am interesting in opening a PDF document via the command line from
both Windows, OS X, and Linux ( R version 2.8.0). I found a command
openPDF in Biobase. However, I would rather execute the command
myself. For example, in OS X:
> system("open filename.pdf")
is successful.
Is there a comparable command line command for Windows or Linux?
Dennis
Dennis Fisher
2006 Oct 21
2
Filling in a series
Colleagues
After reading in some clinical data, I discovered that the subject ID
column contains entries only for the first record for each
individual; subsequent rows are recorded as NA. For example:
> 1
> NA
> NA
> NA
> NA
> 2
> NA
> NA
> NA
> NA
> 3
> NA
> NA
> ...
I can think of various approaches to replace the NA values with
appropriate
2009 Jan 30
3
identifying what labels have been created in a plot
Colleagues
R 2.8.0; OS X, Vista, Ubuntu Linux
In some instances, when I create a graphic using plot(XVAR, YVAR), it
would be valuable to know the values that R will display on the y-axis
(e.g., if the range of data is 0-70, it might display 0, 10, 30, 50,
70). Is there a simple means to access these values?
Also, in some instances, additional ticks appear between the displayed
values
2009 Sep 23
2
Updating R for Linux
Colleagues,
Please forgive my ignorance of this topic. I am experienced with the
installation/use of R in OSX and Windows, much less so with Linux.
I just created a virtual machine of Ubuntu 9.0.4. Using the Synaptic
Package Manager, I installed R 2.8.1. I would like to obtain 2.9.x
and I am having trouble doing so using the tools available within
Ubuntu.
I tried
apt-get install
2004 May 05
3
sip.conf and SIP client host= not recognized in some cases
I am seeing an issue with getting certain sip devices to be recognized as
defined SIP clients host= in the sip.conf and the only deference that I can
find btw sources that work and don't work is that devices that send packets
with an Initial Via header of themselves appears to work and pick the
context correctly but those that don't have the Via just get dropped in the
context of the
2008 Nov 07
2
Unexpected behavior of clocktime related to daylight savings time
Colleagues,
I submitted this several days ago and no one responded, so I am trying
again, trying a different subject line:
I just encountered some unexpected behavior of difftime in
relationship to the change from daylight savings to standard time.
My understanding is that DST and ST take effect at 2AM. However, the
results below suggests that R (version 2.8.0 in OS X) implements the
2012 Apr 17
3
Can a matrix have 'list' as rows/columns?
After a lot of processing I get a matrix into M. I expected each row and
column to be a vector. But it is a list.
R-Inferno says...
"Arrays (including matrices) can be subscripted with a matrix of positive
numbers. The subscripting matrix has as many columns as there are dimensions
in the array—so two columns for a matrix. The result is a vector (not an
array)
containing the selected
2003 May 01
4
var[i]
Dear all,
How could I use variables in a loop that their names are in a vector?
For example:
aaa <- 1:10
bbb <- aaa*2
ccc <- aaa+bbb
varn <- c("aaa", "bbb", "ccc")
m <- rep(NA, 3)
for (i in 1:length(varn)) m[i] <- mean(varn[i]) # wrong
thanks in advance
Juli
--
"Wars do not solve problems, wars generate even more problems"
2005 Jan 17
2
Question about time series
I have data in the following format:
> DATE
[1] "01/13/2004"
In order to find the difference between two data points, I presently
use brute force to calculate the day of the year:
> strptime(DATE, format="%m/%d/%Y")$yday
[1] 12
Although this works, it may not be robust over different years. I
assume that R is sufficiently clever that a much simpler approach
2020 Jul 14
6
internal DNS not forwarding
Hello,
I am trying to setup a samba4 AD dc in my network using smb-tool.
Everything seems to work except DNS forwarding.
If I query for the dc
root at dc:~# nslookup dc.local.domain.it
I get the correct answer:
root at dc:~# nslookup dc
Server:???????? aaa.bbb.ccc.ddd
Address:??????? aaa.bbb.ccc.ddd#53
Name:?? dc.xxxx.yyyy.it
Address: aaa.bbb.ccc.ddd
but if I query for an external domain:
root
2006 Jan 22
1
setting up vpn client on a freebsd workstation
I have the following network:
External Interface External Interface
ccc.ccc.ccc.ccc aaa.aaa.aaa.aaa
| |
--> VPN <--> Internet <--> FreeBSD Client (NATed extip: bbb.bbb.bbb.bbb)
|
FW-1 Protected Net
ddd.ddd.ddd.ddd/24
VPN: ipsec freeswan (UDP encapsulated tunnel)
ccc.ccc.ccc.ccc has port 136/UDP open for
2008 Jul 29
1
Removing script file
Colleagues,
(Running R 2.7.0)
I have a script that I want to delete as it completes execution. The
penultimate line of the script (before the quit command) is:
file.remove("Scriptname")
The script is executed as:
R --no-save < Scriptname
In OS X and Linux this is successful and returns:
> > file.remove("x")
> [1] TRUE
and the file is deleted
In Windows XP,
2005 Dec 04
2
tiff graphics
Colleagues
I frequently insert PDF graphics created with R into Word (Office
2004 for Mac) documents. The documents are created on either a
Linux machine (RedHat 9) or a Mac (Tiger). I am using R 2.2.0.
These pdf graphics often lose a great deal of resolution after
insertion into Word compared to their high quality when printed as
PDF documents. I recently learned that converting the
2007 Jun 21
4
"if" within a function
Dear Friends.
I found a puzzling phenomenon in R when you use 'if' within a function:
# defining a function aaa
aaa=function(a)
{if (a==1) {aaa=1};
if (a!=1) {aaa=2}
}
# using the function:
> b=20
> bbb=aaa(b)
> bbb
[1] 2
> typeof(bbb)
[1] "double"
>
>
> c=1
> ccc=aaa(c)
> ccc
NULL
> typeof(ccc)
[1] "NULL"
It seems that only the last