similar to: Unique Values per Column

Displaying 20 results from an estimated 50000 matches similar to: "Unique Values per Column"

2011 Apr 03
4
replace last 3 characters of string
Hi, I would like to replace the last tree characters of the values of a certain column in a dataframe. This replacement should only take place if the last three characters correspond to the value "/:/" and they should be replaced with ""(blank) I cannot perform a simple gsub because the characters /:/ might also be present somewhere else in the string values and then they
2007 Jan 05
4
Fast Removing Duplicates from Every Column
Hi, I'm looking for some lines of code that does the following: I have a dataframe with 160 Columns and a number of rows (max 30): Col1 Col2 Col3 ... Col 159 Col 160 Row 1 0 0 LD ... 0 VD Row 2 HD 0 0 0 MD Row 3 0 HD HD 0 LD Row 4 LD HD HD 0 LD ... ... LastRow HD HD LD 0 MD Now I want a dataframe that looks like this. As you see
2018 Feb 25
0
reshaping column items into rows per unique ID
I believe you need to spend time with an R tutorial or two: a data frame (presumably the "table" data structure you describe) can *not* contain "blanks" -- all columns must be the same length, which means NA's are filled in as needed. Also, 8e^5 * 7e^4 = 5.6e^10, which almost certainly will not fit into any local version of R (maybe it would in some server version --
2008 Nov 05
1
slow aggregate function
Een ingesloten tekst met niet-gespecificeerde tekenset is gescrubt ... Naam: niet beschikbaar URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20081105/cffde8e4/attachment.pl>
2012 May 31
3
RScript.exe and map directory issue
Hi, I'm trying to run on Windows 7 a scriptfile with Rscript.exe from within Excel 2010 with the following code: Call Shell(rPath & "\Rscript.exe C:\Work\Latest\_Test.R", vbHide) The good news is: the above code works perfectly, but ... If I add white spaces to my map directory, like: Call Shell(rPath & "\Rscript.exe C:\Work\Latest 1\_Test.R", vbHide) In the
2008 May 15
2
Adding columns to dataframe
Hi, I have a dataframe SDF1 that looks like this: Char1 Char2 Char 3 W.2007.02 W.2007.09 W.2007.16 W.2008.13 A C1 F1 F2 F3 A C2 F4 B C3 F5 F6 I have another dataframe SDF2 with 163 cols that has the following column names Char1 Char2 Char 3 W.2007.02 W.2007.03 W.2007.04
2010 Oct 11
2
Split rows depending on time frame
Hi, I have the following data frame, where col2 is a startdate and col3 an enddate COL1 COL2 COL3 A 40462 40482 B 40462 40478 The above timeframe of 3 weeks I would like to splits it in weeks like this COL1 COL2 COL3 COL4 A 40462 40468 1 A 40469 40475 1 A 40476 40482 1 B
2018 Feb 25
1
reshaping column items into rows per unique ID
Hi Allaisone, I took a slightly different approach but you might find this either as or more useful than your approach, or at least a start on the path to a solution you need. df1 <- data.frame(CustId=c(1,1,1,2,3,3,4,4,4),DietType=c("a","c","b","f","a","j","c","c","f"),
2018 Feb 25
4
reshaping column items into rows per unique ID
Hi All I have a datafram which looks like this : CustomerID DietType 1 a 1 c 1 b 2 f 2 a 3 j 4 c 4 c 4 f And I would like to reshape this so I can
2008 May 14
2
Dividing Two Dataframes
Hi, I have two dataframes one with 144 rows and 160 columns (SDF1) and one with 12 rows and 160 columns (SDF2). Now I'm trying to divide rows 1:12 with SDF2, rows 13:24 with SDF2, rows 25:36 with SDF 2, . In S-Plus the following code works fine: DFS = SDF1[1:144,1:60] / as.vector(SDF2[1:12,1:160]) but in R when I try to implement the formula I get the following error: "/
2010 Feb 17
2
Is the aggregate function the best way to do this?
Hi, I''m having a dataframe ''Subset1'' with a number of factor variables and 160 numerical variables Now I want to make sums for all rows that have the same values for the different factor variables, except for the factor variables: VAR1,VAR2,VAR3 who may have the same values. With the formula given below this works great, but in a situation with 15000 rows and 13
2017 Sep 19
2
remove quotes from matrix
Hi Duncan and Bert; I do appreciate for your replies. I just figured out that after x1= noquotes(x) commend my 733*22 matrix returns into n*1 vector. Is there way to keep this as matrix with the dimension of 733*22? Regards, Greg On Tue, Sep 19, 2017 at 10:04 AM, Duncan Murdoch <murdoch.duncan at gmail.com> wrote: > On 19/09/2017 9:47 AM, greg holly wrote: > >> Hi all;
2017 Jul 04
0
about adding a column for water year
Well, let's see: 1) You do not appear to understand basic flow control statements in R. Note that (from ?if): if(cond) expr if(cond) cons.expr else alt.expr where "cond A length-one logical vector that is not NA." Your cond is a vector of length nrow(DF), so you don't want if, you want ifelse(). Did you fail to show us your warning messages?? 2. Revising your code and
2017 Sep 19
0
remove quotes from matrix
Works fine for me. What do you object to in the following? Calling the above df "d", > dm <- as.matrix(d) > dm Sub_Pathways BMI_beta SAT_beta VAT_beta 1 "Alanine_and_Aspartate" " 0.23820" "-0.02409" " 0.94180" 2 "Alanine_and_Aspartate" "-0.31300" "-1.97510" "-2.22040" 3
2020 Oct 31
0
fast way to find most common value across columns dataframe
Thank you. The problem was not finding the mode but applying it the R way (I have the tendency to loop into each line of the dataframes, which I believe is NOT the R way). I'll try them. Best regards Luigi On Sat, Oct 31, 2020 at 5:40 PM Bert Gunter <bgunter.4567 at gmail.com> wrote: > > As usual, a web search ("find statistical mode in R") brought up something that is
2016 Apr 18
0
Sum of Numeric Values in a DF Column
... and a slightly more efficient non-dplyr 1-liner: > sapply(strsplit(dd$Lower,"[^[:digit:]]"), function(x)sum(as.numeric(x), na.rm=TRUE)) [1] 105 67 60 100 80 Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On
2017 Oct 15
1
Populate one data frame with values from another dataframe for rows that match
Dear @William<mailto:wdunlap at tibco.com>, thanks for the feedback. I have tested it on the larger dataset and noticed that it created two variables, pf_raw and pf_curated. The output we were looking for, was one that takes the variable pf_mcl in curated dataset and replaces pf_mcl in matching rows within the raw dataset. @Eric<mailto:ericjberger at gmail.com>?s solution was able to
2017 Nov 23
1
assign NA to rows by test on multiple columns of a data frame
yes, it works, even if I do not really get how and why it's working the combination of logical results (could you provide some insights for that?) moreover, and most of all, I was hoping for a compact solution because I need to deal with MANY columns (more than 40) in data frame with the same basic structure as the simplified example I posted thanks m ----- Messaggio originale ----- Da:
2018 Mar 20
2
Elements of Sets as dataframe column names
Hello all, I have a set B and a dataframe df. I want to name the columns of the dataframe after the elements of the set B. For example, for set B with elements {{"P1"}, {"P2"}, {"P3", "P4"}} I want to create a new dataframe with 3 columns named {"P1"} and {"P2"} and {"P3","P4"}. I tried colnames(df)<-(B). But it
2017 Nov 22
0
assign NA to rows by test on multiple columns of a data frame
Do you mean like this: mydf <- within(mydf, { is.na(A)<- !A_flag is.na(B)<- !B_flag } ) > mydf A A_flag B B_flag 1 8 10 5 12 2 NA 0 6 9 3 10 1 NA 0 4 NA 0 1 5 5 5 2 NA 0 Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into