How do I uninstall or update R on Linux Mint?
community, I am new to Ubuntu/Linux Mint and very excited to learn about it. I thought it's a good habit to uninstall the old before installing the new R version and double-check.
~$ sudo apt-get remove r-base ~$ R --version
I want to update R base from 3.4.4 "Someone to Lean On" to 3.6 "Action of the Toes" since it is the latest version according to cran-r.
How do I go about updating to the latest R version, and should I uninstall the old version first?
See also questions close to this topic
Plot a Dataframe on a basic R chart
I think it's a basic question but I didn't saw any answers on SO that solves this.
So, I would like to put each line of this dataframe on a chart, with respective column and row names on x and y axis.
> indicador.transposta 31-12-2017.pdf 31-12-2018.pdf 31-12-2019.pdf Liq..Imed. 0.260650162167045 0.278000595266861 0.100940099971038 Liq..Corr. 1.20707183817692 1.07611507200346 0.775547123687795 Liq..Seca 1.01127035774033 0.87978786315216 0.616295652990034 Liq..Geral 1.38911863440832 1.20904526839338 1.22121514777491 Endividamento 0.719880919620619 0.827098890456626 0.818856531399918 Retorno.s..Invest. -0.0281507369406506 -0.110425824989136 0.00682789312217763 Retorno.s..PL -0.100495606734552 -0.638664640618945 0.037693289053948 Margem.Líquida -0.0440458341645613 -0.181853784203517 0.0103531380484155
The structure is:
> str(indicador.transposta) 'data.frame': 8 obs. of 3 variables: $ 31-12-2017.pdf: chr "0.260650162167045" "1.20707183817692" "1.01127035774033" "1.38911863440832" ... $ 31-12-2018.pdf: chr "0.278000595266861" "1.07611507200346" "0.87978786315216" "1.20904526839338" ... $ 31-12-2019.pdf: chr "0.100940099971038" "0.775547123687795" "0.616295652990034" "1.22121514777491" ...
How to check if a vector is in scientific notation in R
I have a vector which prints in scientific notation in R as follows;
x <- c(1.04, 2.2223,4, 9703045, 0.003) x  1.040e+00 2.222e+00 4.000e+00 9.703e+06 3.000e-03
I would like a boolean check that returns
TRUE|FALSEif a vector is in scientific notation. I understand the display in R depends on
Select rows if their values are in list
I have a dataframe:
X Y 1 a 5 f 4 a 6 v 8 b 5 b
I want to select rows if their value in column X is in this vector:
So desired result is:
X Y 5 f 8 b
I tried this, but it didn't work:
df[!(df$Y %in% c(5,8)),]
How could i do that?
I mistakenly deleted the /usr/share/xgreeters folder with LightDM
I allow myself to send this message on this forum to try to answer a problem which I confronted. Indeed, I was looking to customize the LightDM lock screen. I was in root console, and by mistake, I deleted the /usr/share/xgreeters folder ... It must have been an important folder, because since then, the lock screen no longer works. I tried to uninstall LightDM, then reinstall it, I restarted my computer ... But nothing helps, it does not work ... Thanks in advance if you have a solution ! Clement.
How to keep my audio output state aways running on Linux Mint?
I would like to know how to keep my audio output from Linux Mint 19.3 in running state, because when I do not play any audio it automatically goes into a suspended state after a few seconds and this causes a continuous noise in my speaker .
I am using the following commands to check the state of the output:
$ pactl list sinks
$ pacmd list-sinks
Linux Mint Update Manager doesn't work after updating Python3 through PPA
This is an issue I just solved and I share my solution here in case someone runs into a similar one.
Add a private repository
>>> sudo add-apt-repository ppa:deadsnakes/ppa >>> sudo apt-get update >>> sudo apt-get install python3.7
Make Python3 point to Python3.7 (or whatever version you've updated to)
>>> sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1 >>> sudo update-alternatives --config python3
Check the installation
>>> stat $(which python3) >>> stat $(which python3.5)
Make pip point to the new Python version
>>> python3.7 -m pip install pip
In case someone follows this method: a large part of Mint relies on /usr/bin/python, which points to Python2.7, so don't change where this points to to avoid breaking the system, but python3 should be safe.
After that I noticed that mint wasn't working. When running it from the CLI, I got messages about missing packages: gi, pycurl, apturl, etc. These are not available from pip and need to be installed from apt. I tried to adapt this solution by copying and renaming the relevant packages into my local /home/[me]/.local/lib/python3.7/site-packages, but this is tedious.
It's not problematic in itself, as mintupdate is only a GUI for
sudo apt-get upgrade.
How to generate a new column in an R dataframe with ordered items from multiple columns
I have a dataframe in R that looks like this:
df <- data.frame( "first_col" = c("apple", "apple", "banana", "banana", "cacao", "dough"), "second_col" = c("apple", "apple", "banana", "banana", "apple", "dough"), "third_col" = c("banana", "apple", "banana", "banana", "banana", "apple"), stringsAsFactors = FALSE )
and I want to generate a new column that is made sorting the content of the three previous columns using base R.
If I wanted it unsorted I could have done this
df$label <- paste(df$first_col, df$second_col, df$third_col, sep = " - ")
If I try to sort the items with sort like this:
df$label <- paste(sort(df$first_col, df$second_col, df$third_col), sep = " - ")
I get this error:
Error in sort(df$first_col, df$second_col, df$third_col) : 'decreasing' must be a length-1 logical vector. Did you intend to set 'partial'?
So obviously I'm doing something wrong. Looking at the docs it seems like the method wants a vector, so I try to vectorize it doing this
df$label <- paste(sort(c(df$first_col, df$second_col, df$third_col)), sep = " - ")
but I get another error:
Error in `$<-.data.frame`(`*tmp*`, label, value = c("apple", : replacement has 18 rows, data has 6
It looks like it's generating three columns and not just one. What am I doing wrong?
From a dataframe that looks like this:
first_col second_col third_col 1 apple apple banana 2 apple apple apple 3 banana banana banana 4 banana banana banana 5 cacao apple banana 6 dough dough apple
I'd like to obtain something that looks like this:
first_col second_col third_col label 1 apple apple banana apple - apple - banana 2 apple apple apple apple - apple - apple 3 banana banana banana banana - banana - banana 4 banana banana banana banana - banana - banana 5 cacao apple banana apple - banana - cacao 6 dough dough apple apple - dough - dough
You can tell is sorted looking at rows 5 and 6.
Replace characters from data frame with NA in Rbase
I have a data frame like:
Domain Phylum Class Order ID_1 Bacteria Cyanobacteria Unclassified_c Unclassified_o ID_2 Bacteria Cyanobacteria Unclassified_c Unclassified_o ID_3 Bacteria Bacteroidetes Unclassified_c Unclassified_o ID_4 Bacteria Proteobacteria Unclassified_c Unclassified_o ID_5 Bacteria Bacteroidetes Unclassified_c Unclassified_o
and I want to replace all the character Unclassified_c, Unclassified_o, elment_3, etc, for NA, so I had tried:
df[df == "Unclassified_c" ] <- NA
this work well if I use one by one value, but sometimes could be to many; So I will like to try something like a list of patterns and then use it, something like:
Remove_list <- ("Unclassified_c", "Unclassified_o", "element_3", "element_4", "element_x")
and then use the list to replace for NA:
df[ df == Remove_list ] <- NA
It change to NA some of the values but not all. I don't want to use stringr library, because it eliminate the rownames (ID_1 .. ID_x) and I need it, so I will like to try Rbase, any suggestion
Thanks so much !!!!
Why I'm getting NA's when selecting by 'with'
As a followup to @allan-cameron 's excellent answer in Most concise way to get a value from within a tibble
If I add some
bandy <- tibble(name = c("John", "Paul", "Keith", "Eric", NA), plays = c("guitar", "bass", "guitar", NA, "kazoo")) with(bandy, plays[name == "John"]) #  "guitar" NA with(bandy, name[plays == "guitar"]) #  "John" "Keith" NA
Can someone explain why I'm getting those NA's returned? And what's the most elegant way to keep from returning them?