similar to: Setting Values of Elements in a Dataframe

Displaying 20 results from an estimated 10000 matches similar to: "Setting Values of Elements in a Dataframe"

2011 Feb 02
1
combining vectors into list
Hi R users I have these two vectors: Row <- sample(1:25, 10) Col <- sample(1:25, 10) Is there a way to combine them into a list, whose first component is a vector containing the first element of Row and the first element of Col, the second component is a vector containing the second element of Row and the second element of Col, and so on... Thanks you Lorenzo
2010 Sep 27
3
name ONLY one column
Hi R-users I can not change the name of one column only of my matrix. my_matrix <- matrix (1:12,ncol=3) colnames(my_matrix)[1] <- 'myname' Error in dimnames(x) <- dn : length of 'dimnames' [2] not equal to array extent thank you for your help Lorenzo [[alternative HTML version deleted]]
2011 Jan 18
2
dataframe: string operations on columns
Dear all, how can I perform a string operation like strsplit(x," ") on a column of a dataframe, and put the first or the second item of the split into a new dataframe column? (so that on each row it is consistent) Thanks Boris
2011 Jan 12
3
Outputting csv file from dataframe with columns in a particular order
I have a dataframe with columns "ID",'date","estimate","actual" (but not necessarily in that order - I do a merge somewhere and that somehow messes up the order of the columns). How can I output it to a csv file with the columns in the order that I want? Thanks.
2011 Mar 11
2
'autocompletion' of named elements of a list
I had an obscure bug that boiled down to this ``feature'' in R, Read 3921 items > A = list(aa = 1) > A $aa [1] 1 > if (A$a) print("a is there") [1] "a is there" The test appear to check is A$a is TRUE, but what happen is that it auto-complete (silently), and expand to 'A$aa'. The problem was caused by the fact that I had also a element named
2010 Mar 29
3
about data export
Hello all, This is Meghana. Well, I have some analysis output in 3 dimensional array form. for example: , , type1 A B C D 1 2 3 4 1 2 3 4 , , type2 etc. This array is very big. and I want to export this to either text form or excel(csv is preffered) so that different parts of aaray should be easily extractable from that excel/text sheet. How can I go about it? Thank
2010 Dec 02
1
Arrange elements on a matrix according to rowSums + short 'apply' Q
Greetings, My goal is to create a Markov transition matrix (probability of moving from one state to another) with the 'highest traffic' portion of the matrix occupying the top-left section. Consider the following sample: inputData <- c( c(5, 3, 1, 6, 7), c(9, 7, 3, 10, 11), c(1, 2, 3, 4, 5), c(2, 4, 6, 8, 10), c(9, 5, 2, 1, 1) ) MAT <- matrix(inputData,
2011 Aug 15
3
how can I read a xlsx file
Hello, How can I read a xlsx file using xlsx package? Thanks Albert [[alternative HTML version deleted]]
2011 Feb 02
3
reshape data, adding rows to dataframe
Hello everyone, I have a data set like this: > head( fish_transect) ID_TRANSECT ID_PROJECT DE_ZONE DE_LOCALITY DE_SECTOR MES 1 42 MB Tarragona Creixell Control I 9 2 42 MB Tarragona Creixell Control I 9 3 42 MB Tarragona Creixell Control I 9 4 42 MB Tarragona Creixell Control I 9 5 42
2011 May 04
1
Str info. Thanks for helping
It looks from str(SA) that Response IPS1 is a data.frame of class "anova", which probably cannot be coerced to vector. Maybe you can use unlist() instead of as.vector() Or something like SA[["Response IPS1"]]["as.factor(WSD)",] ## to select the first row only, even maybe with unlist() Without a better REPRODUCIBLE example, I cannot tell more (maybe some others
2011 Apr 20
2
user input
Dear users, I have looked on different sources and found different functions to prompt the user to provide input. However, I couldn't find one that does exactly what I'm looking for. select.list() and menu() are nice because a graphic window appears to prompt the user. However, the user can only choose from a predefined list of choices. readline() and scan() are more free in the
2011 Feb 28
1
Replacing an element in a vector
Dear R helpers I seem to have one trivial problem but can't find solution to it. Suppose I have following input. A = c(1,  3,  0,  5,  8)                  # 3rd element is 0 B = c(100, 30,  0,  25,  40)          # 3rd element is 0 C = A/B > C [1] 0.01 0.10  NaN 0.20 0.20 Obviously, I can't divide 0/0 and hence NaN. My problem is how to replace this NaN say by 0. So that I can
2010 Dec 08
5
Summing up Non-numeric column
Dear All If I have the following dataset V1 V2 x y y x z b a c b j d l c o How do I use R command to get the total number of different letter in column "V1" column "V1" has 7 different letters. Thank you -- View this message in context: http://r.789695.n4.nabble.com/Summing-up-Non-numeric-column-tp3077710p3077710.html Sent from the R help mailing list archive
2011 Jan 25
4
Subtracting elements of data.frame
Dear R helpers I have a dataframe as df = data.frame(x = c(1, 14, 3, 21, 11), y = c(102, 500, 40, 101, 189)) > df    x   y 1  1 102 2 14 500 3  3  40 4 21 101 5 11 189 # Actually I am having dataframe having multiple columns. I am just giving an example. I need to subtract all the rows of df by the first row of df i.e. I need to subtract each element of 'x' column by 1. Likewise I
2011 Jun 27
2
Add use of dput() to the instructions at bottom of post?
It's often difficult to figure out what a problem data set looks like when someone pastes a mess of output from R into an e-mail. The dput command, used judiciously?I would hope no one would send a 1 M data set?can make life much easier. I wonder if it would be useful to add a hint in the instructions at the bottom of the posting page, where the list asks for self-contained reproducible
2011 Apr 06
1
syntax to subset for multiple values from a single variable
Hi All, Is it possible to use the subset() function to select data based on multiple values of a single variable from a data frame. My actual data set is much bigger and would like to illustrate with following dataset > df = data.frame(x = c('a','b','c','d','e','f','g','h','a','a','b','b'), y =
2010 Dec 13
7
descriptive statistics
Hi. In a data set I have a variable that takes values from 1 to 14. For each subgroup of values of this variable, I would like to obtain some descriptive statistics of other variables present in the data set. I've been trying with a "for" loop but I couldn't get nothing. Could you please suggest me some lines? -- View this message in context:
2019 Jul 09
3
[R] Curl4, Quantmod, tseries and forecast
Hi Ralf, I tried the following > install.packages("RCurl") which went OK, but then same story when I tried to install tseries. > sessionInfo() R version 3.6.1 (2019-07-05) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Debian GNU/Linux 10 (buster) Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.8.0 LAPACK:
2013 Mar 24
3
Parallelizing GBM
Dear All, I am far from being a guru about parallel programming. Most of the time, I rely or randomForest for data mining large datasets. I would like to give a try also to the gradient boosted methods in GBM, but I have a need for parallelization. I normally rely on gbm.fit for speed reasons, and I usually call it this way gbm_model <- gbm.fit(trainRF,prices_train, offset = NULL, misc =
2013 Feb 09
3
Addressing Columns in a Data Frame
Dear All, Probably a one liner, but I am banging my head against the floor. Consider the following DF <- data.frame( x=1:10, y=10:1, z=rep(5,10), a=11:20 ) mn<-names(DF) but then I cannot retrieve a column by doing e.g, DF$mn[2] I tried to play with the quotes and so on, but so far with no avail. Any suggestion is welcome. Cheers Lorenzo