similar to: Converting a character string into a data frame name and performing assignments to that data frame

Displaying 20 results from an estimated 20000 matches similar to: "Converting a character string into a data frame name and performing assignments to that data frame"

2009 Aug 12
3
Obtaining the value of x at a given value of y in a smooth.spline object
I have some data fit to a smooth.spline object as follows: (x=vector of data for the predictor variable, y=vector of data for the response variable) fit <- smooth.spline(x,y) Now, given a spline fit point y_new, I want to be able to find out what value of x_new yielded this fit value. How to do so? (This problem is the inverse of the predict.smooth.spline function, which takes x_new as input
2009 Jun 28
1
applying a function to a pair of components for each row of a list
Hi, I have a set of (x,y) coordinate pairs that are stored as a list > my_list $x [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 $y [1] -8.0866819 -7.3876052 -6.6849311 -5.9837693 -5.2967432 -4.6525466 [7] -4.0999453 -3.6556190 -3.3076102 -3.0360780 -2.8220465 -2.6532085 [13] -2.5192816 -2.4086241 -2.3072977 -2.1969611 -2.0574250 -1.8737694 [19] -1.6357864
2009 Oct 02
6
split-apply question
Hi, I have a data frame that looks like this: >x x1 x2 x3 A 1 1.5 B 2 0.9 B 3 2.7 C 7 1.8 D 7 1.3 I want to "group" by the x1 column and in the case of multiple x$x1 values (e.g., "B")d, return rows that have the smallest values of x2. In the case of rows with only one value of x1 (e.g., "A"), return the row as is. How can I do that?
2009 Oct 22
1
tapply with multiple arguments that are not part of the same data frame
Hi all, I would like to invoke a function that takes multiple arguments (some of which are specified columns in the data frame, and others that are independent of the data frame) on split parts of a data frame, how do I do this? For example, let's say I have a data frame >fitness_data name height weight country rob 5.8 200 usa nancy 5.5 140 germany jen
2016 Apr 06
4
CentOS 7.2 rootfs for i386
Hi I want to build a small rootfs for 32 bit CentOS to the same I plan to build the entire OS but I see https://wiki.centos.org/HowTos/I_need_the_Kernel_Source kernel_build for 32 bit is not supported . Please let me know anybody has built the same Thanks Kavitha
2012 Oct 10
2
Summary using by() returns character arrays in a list
I use by() to generate a summary statistics like so: Lbys <- by(dat[Nidx], dat$LipTest, summary) where Nidx is an index vector with names picking out the columns in the data frame dat. This returns a list of character arrays (see below for str() output) where the columns are named correctly but the rownames are empty strings and the values are strings prepended with the summary
2005 Apr 25
3
Data frames
I have two questions about data frames: (1) How can one extract a simple matrix from a data frame? I tried Matrixfromdf = function (frame,without=1) {a=frame[colnames(frame)[-without]] v=unlist(a,use.names=F) matrix(v,ncol=ncol(a))} but it works well only for without=1, perhaps also because the function in (2) gives probably a different meaning to the first column. (2)
2010 Mar 02
2
turn character string into unevaluated R object
Hi, How to turn a character string into an unevaluated R object? I want to load some files in a directory into data matrix R objects. I could do this with read.table and assign (see below). Then, I want to turn the character string representing a file name (the evaluated expression of i) into an unevaluated R object. Basically, I want to create matrices whose names are the same as the related file
2009 May 12
1
lattice histogram for multiple variables : adjusting x axis
Hello all, I have a large data frame and I want to look at the distribution of each variable very quickly by plotting an individual histogram for each variable. I'd like to do so using lattice. Here is a small example using the iris data set: histogram(as.formula(paste("~",paste(colnames(iris[,!sapply(iris,is.factor)]),collapse="+"))),data=iris[,!sapply(iris,is.factor)])
2011 Aug 10
2
round() a data frame containing 'character' variables?
Dear all It is difficult to use round(..., digits=2) on a data frame since one has to first take care to remove non-numeric variables such as 'character' or 'factor': > head(round(iris, 2)) Error in Math.data.frame(list(Sepal.Length = c(5.1, 4.9, 4.7, 4.6, 5, : non-numeric variable in data frame: Species > head(round(iris[1:4], 2)) Sepal.Length Sepal.Width Petal.Length
2009 May 31
2
renaming column names
I am trying to rename the column names of a data frame called "data". It has 177 columns. I have used : colnames(data) <- a where a is a vector with 177 character names. I don''t get any error message, but the column names don''t change because when I then type : colnames(data) I get the same set of names as before, so the assignment doesnt seem to have
2008 Oct 01
2
an unsophisticated question about recoding in a data frame with control structure if {}
Hello all, I apologize for a terribly simple question. I'm used to using Stata and am trying to `switch' over to R. I would like to recode a vector in a data frame when the value of it meets the following condition: if (dataframe$factor=='3'){dataframe$thevector<-(an arithmetic mean). What I would like to result is the creation of a new variable within the data frame for
2005 Jul 08
5
Help with Mahalanobis
Dear R list, I'm trying to calculate Mahalanobis distances for 'Species' of 'iris' data as obtained below: Squared Distance to Species From Species: Setosa Versicolor Virginica Setosa 0 89.86419 179.38471 Versicolor 89.86419 0 17.20107 Virginica 179.38471 17.20107 0 These distances were obtained with proc 'CANDISC'
2004 Jul 29
2
unwanted as.integer
> a <- sqlQuery(irrdb, "select count(field) from mytable where field = 1") > print(a) count(field) 1 8 > paste(a) [1] "as.integer(8)" Why the as.integer() representation? I later pass the result into this write.html.table(), and what I get is rows of as.integer()... when all I want is the integer itself. as.integer(31) as.integer(21)
2011 Apr 28
2
changing a specific column name
Hi, Can someone please tell me how to change the column name of a specific column. How do I change the name of the column 'Species'? Thanks in advance d <- iris colnames(d) [1] "Sepal.Length" "Sepal.Width" "Petal.Length" "Petal.Width" "Species" ind <- which(names(d)=='Species') ind [1] 5 colnames(d[ind]) [1]
2006 Dec 14
5
Nicely formatted tables
If I use latex(summary(X)) where X is a data frame with four variables I get something like Rainfall Education Popden Nonwhite Min. :10.00 Min. : 9.00 Min. :1441 Min. : 0.80 1st Qu.:32.75 1st Qu.:10.40 1st Qu.:3104 1st Qu.: 4.95 Median :38.00 Median :11.05 Median :3567 Median :10.40 Mean :37.37 Mean :10.97 Mean :3866
2010 Jun 21
2
ctree
Hello, This is a re-submittal of question I submitted last week, but haven't rec'd any responses. I need to extract the probabilities used to construct the barplots displayed as part of the graph produced by plot("ctree"). For example, library(party) iris.ct <- ctree(Species ~ . , data = iris) plot(iris.ct) Instead of a simple example with only 4 terminal nodes, my
2005 Nov 27
4
Counting the occurence of each unique "charecter string"
LS, I would really like to know how to count the frequency/occurrence of chachters inside a dataset. I am working with extreemly large datasets of forest inventory data with a large variety of different species inside it. Each row inside the dataframe represents one individual tree and the simplified dataframe looks something like this: num species dbh 1 sp1
2005 Nov 27
4
Counting the occurence of each unique "charecter string"
LS, I would really like to know how to count the frequency/occurrence of chachters inside a dataset. I am working with extreemly large datasets of forest inventory data with a large variety of different species inside it. Each row inside the dataframe represents one individual tree and the simplified dataframe looks something like this: num species dbh 1 sp1
2008 Mar 27
2
colMeans in a data.frame with numeric and character data
Hi all, I would like to know if it is posible by, someway, to get colMeans from a data.frame with numeric as well as character data, dispersed all over the object. Note that I would like to get colMeans neglecting character data. I am really in need of some function proceeding in that way… All the best Diogo André Alagador [[alternative HTML version deleted]]