similar to: different behavior of $ with string literal vs string variable as argument

Displaying 20 results from an estimated 40000 matches similar to: "different behavior of $ with string literal vs string variable as argument"

2012 Nov 15
4
using ifelse to remove NA's from specific columns of a data frame containing strings and numbers
Hi everyone, I have a data frame one of whose columns is a character vector and the rest are numeric, and in debugging a script, I noticed that an ifelse call seems to be coercing the character column to a numeric column, and producing unintended values as a result. Roughly, here's what I tried to do: df: a data frame with, say, the first column as a character column and the second and
2012 Dec 04
3
odd behavior of browser()
Hi everyone, I normally include a call to browser() as I'm working out the kinks in my scripts, and I am always able to step through each line by hitting "Return", but for some reason, in the scripts I'm working on now, hitting "Return" seems to cause execution of *all* the lines in my script. I've restarted R several times in case it was stuck in a bad state for
2013 Feb 06
3
how to "multiply" list of matrices by list of vectors
Hi everyone, I'd like to be able to apply lda to each 2D matrix slice of a 3D array, and then use the scalings to obtain the corresponding lda scores. I can use 'apply' to get a list of the lda output for each 2D slice, and can create a list of the resulting scalings, but I'm not sure how to multiply them in a vectorized way. Here's how I made a list of 2D matrices
2013 May 03
2
how to parallelize 'apply' across multiple cores on a Mac
Hi everyone, I'm trying to use apply (with a call to zoo's rollapply within) on the columns of a 1.5Kx165K matrix, and I'd like to make use of the other cores on my machine to speed it up. (And hopefully also leave more memory free: I find that after I create a big object like this, I have to save my workspace and then close and reopen R to be able to recover memory tied up by R, but
2012 Dec 12
2
using 'apply' to apply princomp to an array of datasets
Hi everyone, Suppose I have a 3D array of datasets, where say dimension 1 corresponds to cases, dimension 2 to datasets, and dimension 3 to observations within a dataset. As an example, suppose I do the following: > x <- sample(1:20, 48, replace=TRUE) > datasets <- array(x, dim=c(4,3,2)) Here, for each j=1,2,3, I'd like to think of datasets[,j,] as a single data matrix with
2013 Feb 06
1
how to extract test for collinearity and constantcy used in lda
Hi everyone, I'm trying to vectorize an application of lda to each 2D slice of a 3D array, but am running into trouble: It seems there are quite a few 2D slices that trigger either the "variables are collinear" warning, or worse, trigger a "variable appears to be constant within groups" error and fails (i.e., ceases computation rather than skips bad slice). There are
2013 May 04
1
how to best add columns to a matrix with many columns
Hi everyone, I have large data frame, say df1, with 165K columns, and all but the first four columns of df1 are numeric. I transformed the numeric data and obtained a matrix, call it data.m, with 165K - 4 columns, and then tried to create a second data frame by replacing the numeric columns of df1 by data.m. I did this in two ways, and both ways instantly used up all the available memory, so
2011 Dec 01
2
Counting the occurences of a charater within a string
I am new to R but am experienced SAS user and I was hoping to get some help on counting the occurrences of a character within a string at a row level. My dataframe, x, is structured as below: Col1 abc/def ghi/jkl/mno I found this code on the board but it counts all occurrences of "/" in the dataframe. chr.pos <- which(unlist(strsplit(x,NULL))=='/') chr.count <-
2012 Jan 20
4
extract fixed width fields from a string
Hi, I have a data frame with one column containing string of the form "ABC...|XYZ..." where ABC etc are fields of 6 alphanumeric characters each and XYZ etc are fields of 8 alphanumeric characters each; "|" is a mandatory separator; I do not know in advance how many fields of each kind will each row contain. I need to extract these fields from the string. === How do I do that?
2007 May 18
2
writing variables
Can anyone give me insight into upsrw? I have a cyberpower PR2200 UPS (running an experimental version of the powerpanel driver hot off the presses by Arjen (thanks Arjen!!)). When I try to run "upsrw -s xyz=abc" to set any available variable, I get "Set variable failed: Access denied". What user name and password is it looking for here? My upsd.users file has 2 users
2012 Aug 27
4
?nchar ?strsplit
Hi, my data frame is x<-data.frame(ID=c("abc/def","abc/def/ghi","abc","mno/pqr/st/ab")) I want to split my column ID using "/" as the place to split. How can I do that without telling the code how many sub-columns. I could use nchar(gsub("[^/]","",x$ID)) to get how many "/" are in each row of the column, but could
2013 Apr 29
2
Adding elements in data.frame subsets and also subtracting an element from the rest elements in data.frame
Dear R forum I have a data.frame as cashflow_df = data.frame(instrument = c("ABC","ABC","ABC","ABC","ABC","ABC","ABC","ABC","ABC","ABC","ABC","ABC","ABC","ABC", "ABC", "PQR", "PQR",
2012 May 25
4
Hash Table - Select and Change Data iniside Matrix
Hi, Here i have been a matrix like this, *NAME AGE PALCE TRUE/FALSE* ABC 20 INDIA XYZ 30 FRANCE PQR 40 USA MNO 30 KENIYA DEF 25 AUSTRALIA Here,* TRUE/FALSE* Column containing empty values. So my requirement what is , need to change all the *TRUE/FALSE *column value into "*TRUE*" where *AGE =
2013 Apr 26
2
Splitting data.frame and saving to csv files
Dear R Forum, I have a data.frame as df = data.frame(date = c("2013-04-15", "2013-04-14", "2013-04-13", "2013-04-12", "2013-04-11"), ABC_f = c(62.80739769,81.04525895,84.65712455,12.78237251,57.61345256), LMN_d = c(21.16794336,54.6580401,63.8923307,87.59880367,87.07693716), XYZ_p = c(55.8885464,94.1358684,84.0089114,98.99746696,64.71083712),
2012 Apr 19
2
Trouble with [sv]apply
Friends I clearly donot understand how sapply and vapply work. What I have is a function that returns a matrix with an indeterminate number of rows (some times zero) but a constant number of columns. I cannot reliably use an apply function to assemble the matrices into a matrix. I am not sure it is possible. I can demonstrate the core of my confusion with this simple code. A.f <-
2013 Feb 25
1
quesion about SS of ANOVA
Hi all: I have a quesion about ANOVA: Is SS(Sum of Square) of a specific factor constant with the number of factors changing? dat1 includes one factor g1,and g1's SS is called SS_g1_dat1. dat2 includes two factors g1,g2,and g1's SS is called SS_g1_dat2. My quesion is: Is SS_g1_dat1 equals to SS_g1_dat2? I have both "yes" and "no" reasons for the quesion,but
2002 Mar 01
2
Weakness in Knuth-TAOCP RNG (fwd) (PR#1336)
This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. Send mail to mime@docserver.cac.washington.edu for more info. ---559023410-1141662977-1014960253=:3119 Content-Type: TEXT/PLAIN; CHARSET=iso-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Content-ID:
2017 Jun 15
2
Interesting split-brain...
I am new to gluster but already like it. I did a maintenance last week where I shutdown both nodes (one after each others). I had many files that needed to be healed after that. Everything worked well, except for 1 file. It is in split-brain, with 2 different GFID. I read the documentation but it only covers the cases where the GFID is the same on both bricks. BTW, I am running Gluster 3.10. Here
2012 Apr 25
2
r-square for non-linear regression
Hi, I saw you discussed about the meaning of the R squared in a nls regression. Do you have a source or a quotation please? kind regards, Pierre Grison Tel: 06 01 79 74 22 Mail: pgrison@hotmail.fr [[alternative HTML version deleted]]
2012 Sep 07
6
splitting character vectors into multiple vectors using strsplit
Hi folks, Suppose I create the character vector charvec by > charvec<-c("a1.b1","a2.b2") > charvec [1] "a1.b1" "a2.b2" and then I use strsplit on charvec as follows: > splitlist<-strsplit(charvec,split=".",fixed=TRUE) > splitlist [[1]] [1] "a1" "b1" [[2]] [1] "a2" "b2" I was wondering