similar to: How to get the source code for the assignment of a variable?

Displaying 20 results from an estimated 2000 matches similar to: "How to get the source code for the assignment of a variable?"

2011 Jan 10
5
Changing a logical matrix into a numeric matrix
Hi, I would like to turn my TRUE/FALSE matrix into a 1/0 matrix (i.e. True=1 and False=0) [,1] [,2] [,3] [1,] TRUE FALSE FALSE [2,] TRUE TRUE FALSE [3,] TRUE TRUE TRUE [,1] [,2] [,3] [1,] 1 0 0 [2,] 1 1 0 [3,] 1 1 1 Is there a quick way of doing this without a loop? Thanks Emma -- View this message in context:
2018 Jul 24
2
oddity in transform
The idea is that one wants to write the line of code below in a general way which works the same whether you specify ix as one column or multiple columns but the naming entirely changes when you do this and BOD[, 1] and transform(BOD, X=..., Y=...) or other hard coding solutions still require writing multiple cases. ix <- 1:2 transform(BOD, X = BOD[ix] * seq(6)) On Tue, Jul 24, 2018 at
2018 Jul 23
2
oddity in transform
Note the inconsistency in the names in these two examples. X.Time in the first case and Time.1 in the second case. > transform(BOD, X = BOD[1:2] * seq(6)) Time demand X.Time X.demand 1 1 8.3 1 8.3 2 2 10.3 4 20.6 3 3 19.0 9 57.0 4 4 16.0 16 64.0 5 5 15.6 25 78.0 6 7 19.8 42 118.8 >
2009 Sep 28
6
SAS user now converting to R - Help with Transpose
I am just starting to code in R and need some help as I am used to doing this in SAS. I have a dataset that looks like this: Chemical Well1 Well2 Well3 Well4 BOD 13.2 14.2 15.5 14.2 O2 7.8 2.6 3.5 2.4 TURB 10.2 14.6 18.5 17.3 and so on with more chemicals.... I would like to transpose my data so that it looks like this: Chemical WellID Value BOD Well1 13.2 BOD Well2 14.2 BOD Well3 15.5 BOD
2006 Aug 11
3
An apply and rep question
Hi list, I'm sure the explanation must be laughably simple to the experts out there, but I just could figure it out. I have a simple data frame that looks like, >head(da.off) DDate OffP 1 2005-01-01 41.23 2 2005-01-02 44.86 3 2005-01-03 44.86 4 2005-01-04 43.01 5 2005-01-05 45.47 6 2005-01-06 48.62 where the first column DDate currently is character, and OffP is numeric. I want
2007 Sep 07
3
Delete query in sqldf?
Dear All, Is sqldf equipped with delete queries? I have tried delete queries but with no success. Thanks in advance, Paul
2009 Aug 12
2
Symbolic references - passing variable names into functions
Hello All, I am trying to write a function which would operate on columns of a dataframe specified in parameters passed to that function. f = function(dataf, col1 = "column1", col2 = "column2") { dataf$col1 = dataf$col2 # just as an example } The above, of course, does not work as intended. In some languages one can force evaluation of a variable, and then
2006 Oct 25
1
sourcing dput output
Is this not supposed to work? > dput(BOD, file = "/BOD.R") > source("/BOD.R") Error in attributes(.Data) <- c(attributes(.Data), attrib) : row names must be 'character' or 'integer', not 'double' > dput(iris, file = "/iris.R") > source("/iris.R") Error in attributes(.Data) <- c(attributes(.Data), attrib) :
2007 Nov 24
5
how to calculate the return?
Hi, R-users, data is a matrix like this AMR BS GE HR MO UK SP500 1974 -0.3505 -0.1154 -0.4246 -0.2107 -0.0758 0.2331 -0.2647 1975 0.7083 0.2472 0.3719 0.2227 0.0213 0.3569 0.3720 1976 0.7329 0.3665 0.2550 0.5815 0.1276 0.0781 0.2384 1977 -0.2034 -0.4271 -0.0490 -0.0938 0.0712 -0.2721 -0.0718 1978 0.1663 -0.0452 -0.0573 0.2751 0.1372 -0.1346
2009 Aug 25
1
Help with nls and error messages singular gradient
Hi All, I'm trying to run nls on the data from the study by Marske (Biochemical Oxygen Demand Interpretation Using Sum of Squares Surface. M.S. thesis, University of Wisconsin, Madison, 1967) and was reported in Bates and Watts (1988). Data is as follows, (stored as mydata) time bod 1 1 0.47 2 2 0.74 3 3 1.17 4 4 1.42 5 5 1.60 6 7 1.84 7 9 2.19 8 11 2.17 I then
2011 Nov 07
1
RpgSQL row names
Hello, Using the RpgSQL package, there must be a way to get the row names into the table automatically. In the example below, I'm trying to get rid of the cbind line, yet have the row names of the data frame populate a column. > bentest = matrix(1:4,2,2) > dimnames(bentest) = list(c('ra','rb'),c('ca','cb')) > bentest ca cb ra 1 3 rb 2 4 >
2007 Oct 24
3
scoping problem
I would like to write a function that computes Tukey's 1 df for nonadditivity. Here is a simplified version of the function I'd like to write: (m is an object created by lm): tukey.test <- function(m) { m1 <- update(m, ~.+I(predict(m)^2)) summary(m1)$coef } The t-test for the added variable is Tukey's test. This won't work: data(BOD) m1 <- lm(demand~Time,BOD)
2010 Jun 27
2
Ways to work with R and Postgres
Hi, I post this message to the general r-help list hoping anyone within a wider range have suggestions: There are three ways to integration R and postgres, especially on 64bit Microsoft windows Platform, 1. via RODBC package, which has 32 bit and 64 bit version for windows 2. via RPostgres interface, which only has 32bit version currently 3. via plr for Greenplum, which only supports a
2011 Apr 05
1
Names of a data set in a package
For some reason I want to let one data set in a package be known under two different names. Is that possible, and if so, how? I do not want to have two copies of the data set in the package. Thanks, G?ran -- G?ran Brostr?m Department of Statistics Ume? University SE-90187 Ume?, Sweden
2010 Feb 07
3
using a variable name stored in another variable?
Hello, I'm trying to figure out how to create a data object, and then save it with a user-defined name that is input as a command line argument. I know how to create the object and assign it the new name, however, I can't figure out how to refer to the new name for a future operation such as save(). The code below creates an object and uses assign() to give it the user supplied name
2009 Jul 15
2
Spaces in a name
I am reading regressors from an excel file (I have no control over the file) and some of the element names have spaces: i.e. "Small Bank Aquired" but I have found that lm(SourceData ~ . - "Small Bank Aquired", mcReg) doesn't work (mcReg = modelCurrentRegressors) As they are toggles I have ran them through factor() to be treated propertly as 0 or 1 but due to the fact I
2011 Nov 08
2
multi-line query
Hello, I'm using package RpgSQL. Is there a better way to create a multi-line query/character string? I'm looking for less to type and readability. This is not very readable for large queries: s <- 'create table r.BOD("id" int primary key,"name" varchar(12))' I write a lot of code, so I'm looking to type less than this, but it is more readable from
2011 Nov 08
1
dbWriteTable with field data type
Hello, When I do: dbWriteTable(con, "r.BOD", cbind(row_names = rownames(BOD), BOD)) ...can I specify the data types such as varchar(12), float, double precision, etc. for each of the fields/columns? If not, what is the best way to create a table with specified field data types (with the RpgSQL package/R)? Regards, Ben [[alternative HTML version deleted]]
2006 Oct 22
1
least median squares
Does anyone can provide a code to implement least median squares regression in R (not using the lqs function or calling C functions)? Reason: teaching/learning purposes Thanks PM
2008 Sep 09
2
How does predict.lm work?
Hi, Please could someone explain how this element of predict.lm works? From the help file ` newdata An optional data frame in which to look for variables with which to predict. If omitted, the fitted values are used. ' Does this dataframe (newdata) need to have the same variable names as was used in the original data frame used to fit the model? Or will R just look across consecutive